xrpl 3.0.0 → 3.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 (122) 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 +388 -200
  4. package/build/xrpl-latest.js.map +1 -1
  5. package/dist/npm/client/index.d.ts.map +1 -1
  6. package/dist/npm/client/index.js +1 -6
  7. package/dist/npm/client/index.js.map +1 -1
  8. package/dist/npm/models/common/index.d.ts +8 -0
  9. package/dist/npm/models/common/index.d.ts.map +1 -1
  10. package/dist/npm/models/ledger/LedgerEntry.d.ts +3 -2
  11. package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
  12. package/dist/npm/models/ledger/Oracle.d.ts +12 -0
  13. package/dist/npm/models/ledger/Oracle.d.ts.map +1 -0
  14. package/dist/npm/models/ledger/Oracle.js +3 -0
  15. package/dist/npm/models/ledger/Oracle.js.map +1 -0
  16. package/dist/npm/models/ledger/RippleState.d.ts +2 -1
  17. package/dist/npm/models/ledger/RippleState.d.ts.map +1 -1
  18. package/dist/npm/models/ledger/RippleState.js +1 -0
  19. package/dist/npm/models/ledger/RippleState.js.map +1 -1
  20. package/dist/npm/models/ledger/index.d.ts +2 -1
  21. package/dist/npm/models/ledger/index.d.ts.map +1 -1
  22. package/dist/npm/models/ledger/index.js.map +1 -1
  23. package/dist/npm/models/methods/accountChannels.d.ts +1 -1
  24. package/dist/npm/models/methods/accountChannels.d.ts.map +1 -1
  25. package/dist/npm/models/methods/getAggregatePrice.d.ts +31 -0
  26. package/dist/npm/models/methods/getAggregatePrice.d.ts.map +1 -0
  27. package/dist/npm/models/methods/getAggregatePrice.js +3 -0
  28. package/dist/npm/models/methods/getAggregatePrice.js.map +1 -0
  29. package/dist/npm/models/methods/index.d.ts +5 -4
  30. package/dist/npm/models/methods/index.d.ts.map +1 -1
  31. package/dist/npm/models/transactions/AMMDeposit.d.ts +3 -1
  32. package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -1
  33. package/dist/npm/models/transactions/AMMDeposit.js +1 -0
  34. package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
  35. package/dist/npm/models/transactions/index.d.ts +2 -0
  36. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  37. package/dist/npm/models/transactions/index.js.map +1 -1
  38. package/dist/npm/models/transactions/metadata.d.ts +3 -0
  39. package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
  40. package/dist/npm/models/transactions/metadata.js.map +1 -1
  41. package/dist/npm/models/transactions/oracleDelete.d.ts +7 -0
  42. package/dist/npm/models/transactions/oracleDelete.d.ts.map +1 -0
  43. package/dist/npm/models/transactions/oracleDelete.js +10 -0
  44. package/dist/npm/models/transactions/oracleDelete.js.map +1 -0
  45. package/dist/npm/models/transactions/oracleSet.d.ts +13 -0
  46. package/dist/npm/models/transactions/oracleSet.d.ts.map +1 -0
  47. package/dist/npm/models/transactions/oracleSet.js +59 -0
  48. package/dist/npm/models/transactions/oracleSet.js.map +1 -0
  49. package/dist/npm/models/transactions/payment.d.ts +2 -2
  50. package/dist/npm/models/transactions/payment.js +1 -1
  51. package/dist/npm/models/transactions/transaction.d.ts +3 -1
  52. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  53. package/dist/npm/models/transactions/transaction.js +8 -0
  54. package/dist/npm/models/transactions/transaction.js.map +1 -1
  55. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  56. package/dist/npm/src/client/index.d.ts.map +1 -1
  57. package/dist/npm/src/client/index.js +1 -6
  58. package/dist/npm/src/client/index.js.map +1 -1
  59. package/dist/npm/src/models/common/index.d.ts +8 -0
  60. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  61. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +3 -2
  62. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  63. package/dist/npm/src/models/ledger/Oracle.d.ts +12 -0
  64. package/dist/npm/src/models/ledger/Oracle.d.ts.map +1 -0
  65. package/dist/npm/src/models/ledger/Oracle.js +3 -0
  66. package/dist/npm/src/models/ledger/Oracle.js.map +1 -0
  67. package/dist/npm/src/models/ledger/RippleState.d.ts +2 -1
  68. package/dist/npm/src/models/ledger/RippleState.d.ts.map +1 -1
  69. package/dist/npm/src/models/ledger/RippleState.js +1 -0
  70. package/dist/npm/src/models/ledger/RippleState.js.map +1 -1
  71. package/dist/npm/src/models/ledger/index.d.ts +2 -1
  72. package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
  73. package/dist/npm/src/models/ledger/index.js.map +1 -1
  74. package/dist/npm/src/models/methods/accountChannels.d.ts +1 -1
  75. package/dist/npm/src/models/methods/accountChannels.d.ts.map +1 -1
  76. package/dist/npm/src/models/methods/getAggregatePrice.d.ts +31 -0
  77. package/dist/npm/src/models/methods/getAggregatePrice.d.ts.map +1 -0
  78. package/dist/npm/src/models/methods/getAggregatePrice.js +3 -0
  79. package/dist/npm/src/models/methods/getAggregatePrice.js.map +1 -0
  80. package/dist/npm/src/models/methods/index.d.ts +5 -4
  81. package/dist/npm/src/models/methods/index.d.ts.map +1 -1
  82. package/dist/npm/src/models/transactions/AMMDeposit.d.ts +3 -1
  83. package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -1
  84. package/dist/npm/src/models/transactions/AMMDeposit.js +1 -0
  85. package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
  86. package/dist/npm/src/models/transactions/index.d.ts +2 -0
  87. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  88. package/dist/npm/src/models/transactions/index.js.map +1 -1
  89. package/dist/npm/src/models/transactions/metadata.d.ts +3 -0
  90. package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
  91. package/dist/npm/src/models/transactions/metadata.js.map +1 -1
  92. package/dist/npm/src/models/transactions/oracleDelete.d.ts +7 -0
  93. package/dist/npm/src/models/transactions/oracleDelete.d.ts.map +1 -0
  94. package/dist/npm/src/models/transactions/oracleDelete.js +10 -0
  95. package/dist/npm/src/models/transactions/oracleDelete.js.map +1 -0
  96. package/dist/npm/src/models/transactions/oracleSet.d.ts +13 -0
  97. package/dist/npm/src/models/transactions/oracleSet.d.ts.map +1 -0
  98. package/dist/npm/src/models/transactions/oracleSet.js +59 -0
  99. package/dist/npm/src/models/transactions/oracleSet.js.map +1 -0
  100. package/dist/npm/src/models/transactions/payment.d.ts +2 -2
  101. package/dist/npm/src/models/transactions/payment.js +1 -1
  102. package/dist/npm/src/models/transactions/transaction.d.ts +3 -1
  103. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  104. package/dist/npm/src/models/transactions/transaction.js +8 -0
  105. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  106. package/package.json +4 -4
  107. package/src/client/index.ts +16 -5
  108. package/src/models/common/index.ts +33 -0
  109. package/src/models/ledger/LedgerEntry.ts +3 -0
  110. package/src/models/ledger/Oracle.ts +43 -0
  111. package/src/models/ledger/RippleState.ts +2 -0
  112. package/src/models/ledger/index.ts +2 -0
  113. package/src/models/methods/accountChannels.ts +64 -1
  114. package/src/models/methods/getAggregatePrice.ts +119 -0
  115. package/src/models/methods/index.ts +12 -0
  116. package/src/models/transactions/AMMDeposit.ts +2 -0
  117. package/src/models/transactions/index.ts +2 -0
  118. package/src/models/transactions/metadata.ts +1 -0
  119. package/src/models/transactions/oracleDelete.ts +32 -0
  120. package/src/models/transactions/oracleSet.ts +176 -0
  121. package/src/models/transactions/payment.ts +2 -2
  122. package/src/models/transactions/transaction.ts +12 -0
@@ -0,0 +1,176 @@
1
+ import { ValidationError } from '../../errors'
2
+ import { PriceData } from '../common'
3
+
4
+ import {
5
+ BaseTransaction,
6
+ isNumber,
7
+ isString,
8
+ validateBaseTransaction,
9
+ validateOptionalField,
10
+ validateRequiredField,
11
+ } from './common'
12
+
13
+ const PRICE_DATA_SERIES_MAX_LENGTH = 10
14
+ const SCALE_MAX = 10
15
+
16
+ /**
17
+ * Creates a new Oracle ledger entry or updates the fields of an existing one, using the Oracle ID.
18
+ *
19
+ * The oracle provider must complete these steps before submitting this transaction:
20
+ * 1. Create or own the XRPL account in the Owner field and have enough XRP to meet the reserve and transaction fee requirements.
21
+ * 2. Publish the XRPL account public key, so it can be used for verification by dApps.
22
+ * 3. Publish a registry of available price oracles with their unique OracleDocumentID.
23
+ *
24
+ * @category Transaction Models
25
+ */
26
+ export interface OracleSet extends BaseTransaction {
27
+ TransactionType: 'OracleSet'
28
+
29
+ /**
30
+ * A unique identifier of the price oracle for the Account.
31
+ */
32
+ OracleDocumentID: number
33
+
34
+ /**
35
+ * The time the data was last updated, represented as a unix timestamp in seconds.
36
+ */
37
+ LastUpdateTime: number
38
+
39
+ /**
40
+ * An array of up to 10 PriceData objects, each representing the price information
41
+ * for a token pair. More than five PriceData objects require two owner reserves.
42
+ */
43
+ PriceDataSeries: PriceData[]
44
+
45
+ /**
46
+ * An arbitrary value that identifies an oracle provider, such as Chainlink, Band,
47
+ * or DIA. This field is a string, up to 256 ASCII hex encoded characters (0x20-0x7E).
48
+ * This field is required when creating a new Oracle ledger entry, but is optional for updates.
49
+ */
50
+ Provider?: string
51
+
52
+ /**
53
+ * An optional Universal Resource Identifier to reference price data off-chain. This field is limited to 256 bytes.
54
+ */
55
+ URI?: string
56
+
57
+ /**
58
+ * Describes the type of asset, such as "currency", "commodity", or "index". This field is a string, up to 16 ASCII
59
+ * hex encoded characters (0x20-0x7E). This field is required when creating a new Oracle ledger entry, but is optional
60
+ * for updates.
61
+ */
62
+ AssetClass?: string
63
+ }
64
+
65
+ /**
66
+ * Verify the form and type of a OracleSet at runtime.
67
+ *
68
+ * @param tx - A OracleSet Transaction.
69
+ * @throws When the OracleSet is malformed.
70
+ */
71
+ // eslint-disable-next-line max-lines-per-function -- necessary to validate many fields
72
+ export function validateOracleSet(tx: Record<string, unknown>): void {
73
+ validateBaseTransaction(tx)
74
+
75
+ validateRequiredField(tx, 'OracleDocumentID', isNumber)
76
+
77
+ validateRequiredField(tx, 'LastUpdateTime', isNumber)
78
+
79
+ validateOptionalField(tx, 'Provider', isString)
80
+
81
+ validateOptionalField(tx, 'URI', isString)
82
+
83
+ validateOptionalField(tx, 'AssetClass', isString)
84
+
85
+ // eslint-disable-next-line max-lines-per-function -- necessary to validate many fields
86
+ validateRequiredField(tx, 'PriceDataSeries', (value) => {
87
+ if (!Array.isArray(value)) {
88
+ throw new ValidationError('OracleSet: PriceDataSeries must be an array')
89
+ }
90
+
91
+ if (value.length > PRICE_DATA_SERIES_MAX_LENGTH) {
92
+ throw new ValidationError(
93
+ `OracleSet: PriceDataSeries must have at most ${PRICE_DATA_SERIES_MAX_LENGTH} PriceData objects`,
94
+ )
95
+ }
96
+
97
+ // TODO: add support for handling inner objects easier (similar to validateRequiredField/validateOptionalField)
98
+ for (const priceData of value) {
99
+ if (typeof priceData !== 'object') {
100
+ throw new ValidationError(
101
+ 'OracleSet: PriceDataSeries must be an array of objects',
102
+ )
103
+ }
104
+
105
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
106
+ if (priceData.PriceData == null) {
107
+ throw new ValidationError(
108
+ 'OracleSet: PriceDataSeries must have a `PriceData` object',
109
+ )
110
+ }
111
+
112
+ // check if priceData only has PriceData
113
+ if (Object.keys(priceData).length !== 1) {
114
+ throw new ValidationError(
115
+ 'OracleSet: PriceDataSeries must only have a single PriceData object',
116
+ )
117
+ }
118
+
119
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
120
+ if (typeof priceData.PriceData.BaseAsset !== 'string') {
121
+ throw new ValidationError(
122
+ 'OracleSet: PriceDataSeries must have a `BaseAsset` string',
123
+ )
124
+ }
125
+
126
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
127
+ if (typeof priceData.PriceData.QuoteAsset !== 'string') {
128
+ throw new ValidationError(
129
+ 'OracleSet: PriceDataSeries must have a `QuoteAsset` string',
130
+ )
131
+ }
132
+
133
+ // Either AssetPrice and Scale are both present or both excluded
134
+ if (
135
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
136
+ (priceData.PriceData.AssetPrice == null) !==
137
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
138
+ (priceData.PriceData.Scale == null)
139
+ ) {
140
+ throw new ValidationError(
141
+ 'OracleSet: PriceDataSeries must have both `AssetPrice` and `Scale` if any are present',
142
+ )
143
+ }
144
+
145
+ if (
146
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
147
+ 'AssetPrice' in priceData.PriceData &&
148
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
149
+ !isNumber(priceData.PriceData.AssetPrice)
150
+ ) {
151
+ throw new ValidationError('OracleSet: invalid field AssetPrice')
152
+ }
153
+
154
+ if (
155
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
156
+ 'Scale' in priceData.PriceData &&
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
158
+ !isNumber(priceData.PriceData.Scale)
159
+ ) {
160
+ throw new ValidationError('OracleSet: invalid field Scale')
161
+ }
162
+
163
+ if (
164
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
165
+ priceData.PriceData.Scale < 0 ||
166
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
167
+ priceData.PriceData.Scale > SCALE_MAX
168
+ ) {
169
+ throw new ValidationError(
170
+ `OracleSet: Scale must be in range 0-${SCALE_MAX}`,
171
+ )
172
+ }
173
+ }
174
+ return true
175
+ })
176
+ }
@@ -26,7 +26,7 @@ export enum PaymentFlags {
26
26
  * This is intended to force the transaction to take arbitrage opportunities.
27
27
  * Most clients do not need this.
28
28
  */
29
- tfNoDirectRipple = 0x00010000,
29
+ tfNoRippleDirect = 0x00010000,
30
30
  /**
31
31
  * If the specified Amount cannot be sent without spending more than SendMax,
32
32
  * reduce the received amount instead of failing outright. See Partial.
@@ -88,7 +88,7 @@ export interface PaymentFlagsInterface extends GlobalFlags {
88
88
  * This is intended to force the transaction to take arbitrage opportunities.
89
89
  * Most clients do not need this.
90
90
  */
91
- tfNoDirectRipple?: boolean
91
+ tfNoRippleDirect?: boolean
92
92
  /**
93
93
  * If the specified Amount cannot be sent without spending more than SendMax,
94
94
  * reduce the received amount instead of failing outright. See Partial.
@@ -43,6 +43,8 @@ import {
43
43
  import { NFTokenMint, validateNFTokenMint } from './NFTokenMint'
44
44
  import { OfferCancel, validateOfferCancel } from './offerCancel'
45
45
  import { OfferCreate, validateOfferCreate } from './offerCreate'
46
+ import { OracleDelete, validateOracleDelete } from './oracleDelete'
47
+ import { OracleSet, validateOracleSet } from './oracleSet'
46
48
  import { Payment, validatePayment } from './payment'
47
49
  import {
48
50
  PaymentChannelClaim,
@@ -120,6 +122,8 @@ export type SubmittableTransaction =
120
122
  | NFTokenMint
121
123
  | OfferCancel
122
124
  | OfferCreate
125
+ | OracleDelete
126
+ | OracleSet
123
127
  | Payment
124
128
  | PaymentChannelClaim
125
129
  | PaymentChannelCreate
@@ -330,6 +334,14 @@ export function validate(transaction: Record<string, unknown>): void {
330
334
  validateOfferCreate(tx)
331
335
  break
332
336
 
337
+ case 'OracleDelete':
338
+ validateOracleDelete(tx)
339
+ break
340
+
341
+ case 'OracleSet':
342
+ validateOracleSet(tx)
343
+ break
344
+
333
345
  case 'Payment':
334
346
  validatePayment(tx)
335
347
  break