xrpl 4.2.0-batch.0 → 4.3.0-smartescrow.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.
- package/build/xrpl-latest.js +525 -1525
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.d.ts +1 -2
- package/dist/npm/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.js +0 -5
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/Wallet/index.d.ts.map +1 -1
- package/dist/npm/Wallet/index.js +2 -8
- package/dist/npm/Wallet/index.js.map +1 -1
- package/dist/npm/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/client/RequestManager.js +3 -3
- package/dist/npm/client/RequestManager.js.map +1 -1
- package/dist/npm/client/connection.d.ts.map +1 -1
- package/dist/npm/client/connection.js.map +1 -1
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +8 -5
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/models/ledger/Credential.d.ts +2 -2
- package/dist/npm/models/ledger/Credential.d.ts.map +1 -1
- package/dist/npm/models/ledger/Escrow.d.ts +2 -0
- package/dist/npm/models/ledger/Escrow.d.ts.map +1 -1
- package/dist/npm/models/ledger/FeeSettings.d.ts +2 -0
- package/dist/npm/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/models/methods/baseMethod.d.ts +0 -1
- package/dist/npm/models/methods/baseMethod.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMClawback.d.ts +2 -2
- package/dist/npm/models/transactions/AMMClawback.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMDeposit.d.ts +2 -2
- package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.d.ts +2 -2
- package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts +2 -2
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts +2 -2
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts +2 -2
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts +2 -2
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.d.ts +2 -2
- package/dist/npm/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts +2 -2
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts.map +1 -1
- package/dist/npm/models/transactions/accountSet.d.ts +2 -2
- package/dist/npm/models/transactions/accountSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/models/transactions/common.d.ts +4 -16
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +10 -28
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.d.ts +2 -0
- package/dist/npm/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.js +4 -2
- package/dist/npm/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +2 -3
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/metadata.d.ts +0 -1
- package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/models/transactions/offerCreate.d.ts +2 -2
- package/dist/npm/models/transactions/offerCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/oracleSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/oracleSet.js +17 -3
- package/dist/npm/models/transactions/oracleSet.js.map +1 -1
- package/dist/npm/models/transactions/payment.d.ts +2 -2
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.d.ts +2 -2
- package/dist/npm/models/transactions/paymentChannelClaim.d.ts.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +1 -2
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +0 -7
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/transactions/trustSet.d.ts +2 -2
- package/dist/npm/models/transactions/trustSet.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.d.ts +0 -1
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +2 -22
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.d.ts +1 -2
- package/dist/npm/src/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js +0 -5
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/Wallet/index.d.ts.map +1 -1
- package/dist/npm/src/Wallet/index.js +2 -8
- package/dist/npm/src/Wallet/index.js.map +1 -1
- package/dist/npm/src/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/src/client/RequestManager.js +3 -3
- package/dist/npm/src/client/RequestManager.js.map +1 -1
- package/dist/npm/src/client/connection.d.ts.map +1 -1
- package/dist/npm/src/client/connection.js.map +1 -1
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +8 -5
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/models/ledger/Credential.d.ts +2 -2
- package/dist/npm/src/models/ledger/Credential.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Escrow.d.ts +2 -0
- package/dist/npm/src/models/ledger/Escrow.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/FeeSettings.d.ts +2 -0
- package/dist/npm/src/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/src/models/methods/baseMethod.d.ts +0 -1
- package/dist/npm/src/models/methods/baseMethod.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMClawback.d.ts +2 -2
- package/dist/npm/src/models/transactions/AMMClawback.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts +2 -2
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts +2 -2
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts +2 -2
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts +2 -2
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts +2 -2
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts +2 -2
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts +2 -2
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts +2 -2
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/accountSet.d.ts +2 -2
- package/dist/npm/src/models/transactions/accountSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/src/models/transactions/common.d.ts +4 -16
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +10 -28
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.d.ts +2 -0
- package/dist/npm/src/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.js +4 -2
- package/dist/npm/src/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +2 -3
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/metadata.d.ts +0 -1
- package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/offerCreate.d.ts +2 -2
- package/dist/npm/src/models/transactions/offerCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/oracleSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/oracleSet.js +17 -3
- package/dist/npm/src/models/transactions/oracleSet.js.map +1 -1
- package/dist/npm/src/models/transactions/payment.d.ts +2 -2
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts +2 -2
- package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +1 -2
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +0 -7
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/transactions/trustSet.d.ts +2 -2
- package/dist/npm/src/models/transactions/trustSet.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts +0 -1
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +2 -22
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +1 -3
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +8 -100
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/src/sugar/submit.d.ts.map +1 -1
- package/dist/npm/src/sugar/submit.js.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.js +1 -4
- package/dist/npm/src/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts +1 -3
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +8 -100
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/submit.d.ts.map +1 -1
- package/dist/npm/sugar/submit.js.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.js +1 -4
- package/dist/npm/utils/hashes/hashLedger.js.map +1 -1
- package/package.json +5 -8
- package/src/Wallet/defaultFaucets.ts +0 -6
- package/src/Wallet/index.ts +3 -9
- package/src/client/RequestManager.ts +1 -4
- package/src/client/connection.ts +1 -0
- package/src/client/index.ts +28 -7
- package/src/models/ledger/Credential.ts +2 -2
- package/src/models/ledger/Escrow.ts +4 -0
- package/src/models/ledger/FeeSettings.ts +4 -0
- package/src/models/methods/baseMethod.ts +0 -1
- package/src/models/transactions/AMMClawback.ts +2 -2
- package/src/models/transactions/AMMDeposit.ts +2 -2
- package/src/models/transactions/AMMWithdraw.ts +2 -2
- package/src/models/transactions/MPTokenAuthorize.ts +2 -2
- package/src/models/transactions/MPTokenIssuanceCreate.ts +2 -3
- package/src/models/transactions/MPTokenIssuanceSet.ts +2 -2
- package/src/models/transactions/NFTokenCreateOffer.ts +2 -2
- package/src/models/transactions/NFTokenMint.ts +2 -2
- package/src/models/transactions/XChainModifyBridge.ts +2 -2
- package/src/models/transactions/accountSet.ts +1 -2
- package/src/models/transactions/common.ts +22 -62
- package/src/models/transactions/escrowCreate.ts +10 -2
- package/src/models/transactions/index.ts +3 -3
- package/src/models/transactions/metadata.ts +0 -2
- package/src/models/transactions/offerCreate.ts +2 -2
- package/src/models/transactions/oracleSet.ts +30 -8
- package/src/models/transactions/payment.ts +2 -2
- package/src/models/transactions/paymentChannelClaim.ts +2 -3
- package/src/models/transactions/transaction.ts +0 -15
- package/src/models/transactions/trustSet.ts +2 -2
- package/src/models/utils/flags.ts +1 -30
- package/src/sugar/autofill.ts +15 -140
- package/src/sugar/submit.ts +2 -1
- package/src/utils/hashes/hashLedger.ts +2 -5
- package/build/xrpl-latest-min.js +0 -3
- package/build/xrpl-latest-min.js.map +0 -1
- package/dist/npm/Wallet/batchSigner.d.ts +0 -8
- package/dist/npm/Wallet/batchSigner.d.ts.map +0 -1
- package/dist/npm/Wallet/batchSigner.js +0 -124
- package/dist/npm/Wallet/batchSigner.js.map +0 -1
- package/dist/npm/models/transactions/batch.d.ts +0 -39
- package/dist/npm/models/transactions/batch.d.ts.map +0 -1
- package/dist/npm/models/transactions/batch.js +0 -62
- package/dist/npm/models/transactions/batch.js.map +0 -1
- package/dist/npm/src/Wallet/batchSigner.d.ts +0 -8
- package/dist/npm/src/Wallet/batchSigner.d.ts.map +0 -1
- package/dist/npm/src/Wallet/batchSigner.js +0 -124
- package/dist/npm/src/Wallet/batchSigner.js.map +0 -1
- package/dist/npm/src/models/transactions/batch.d.ts +0 -39
- package/dist/npm/src/models/transactions/batch.d.ts.map +0 -1
- package/dist/npm/src/models/transactions/batch.js +0 -62
- package/dist/npm/src/models/transactions/batch.js.map +0 -1
- package/src/Wallet/batchSigner.ts +0 -222
- package/src/models/transactions/batch.ts +0 -147
@@ -47,6 +47,10 @@ export interface EscrowCreate extends BaseTransaction {
|
|
47
47
|
* payment, such as a hosted recipient at the destination address.
|
48
48
|
*/
|
49
49
|
DestinationTag?: number
|
50
|
+
|
51
|
+
FinishFunction?: string
|
52
|
+
|
53
|
+
Data?: string
|
50
54
|
}
|
51
55
|
|
52
56
|
/**
|
@@ -75,9 +79,13 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
|
|
75
79
|
)
|
76
80
|
}
|
77
81
|
|
78
|
-
if (
|
82
|
+
if (
|
83
|
+
tx.FinishAfter === undefined &&
|
84
|
+
tx.Condition === undefined &&
|
85
|
+
tx.FinishFunction === undefined
|
86
|
+
) {
|
79
87
|
throw new ValidationError(
|
80
|
-
'EscrowCreate: Either Condition or
|
88
|
+
'EscrowCreate: Either FinishAfter, Condition, or FinishFunction must be specified',
|
81
89
|
)
|
82
90
|
}
|
83
91
|
|
@@ -33,7 +33,6 @@ export {
|
|
33
33
|
AMMWithdrawFlagsInterface,
|
34
34
|
AMMWithdraw,
|
35
35
|
} from './AMMWithdraw'
|
36
|
-
export { Batch } from './batch'
|
37
36
|
export { CheckCancel } from './checkCancel'
|
38
37
|
export { CheckCash } from './checkCash'
|
39
38
|
export { CheckCreate } from './checkCreate'
|
@@ -100,8 +99,6 @@ export { SignerListSet } from './signerListSet'
|
|
100
99
|
export { TicketCreate } from './ticketCreate'
|
101
100
|
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
102
101
|
export { UNLModify } from './UNLModify'
|
103
|
-
export { PermissionedDomainSet } from './permissionedDomainSet'
|
104
|
-
export { PermissionedDomainDelete } from './permissionedDomainDelete'
|
105
102
|
export { XChainAddAccountCreateAttestation } from './XChainAddAccountCreateAttestation'
|
106
103
|
export { XChainAddClaimAttestation } from './XChainAddClaimAttestation'
|
107
104
|
export { XChainClaim } from './XChainClaim'
|
@@ -114,3 +111,6 @@ export {
|
|
114
111
|
XChainModifyBridgeFlags,
|
115
112
|
XChainModifyBridgeFlagsInterface,
|
116
113
|
} from './XChainModifyBridge'
|
114
|
+
|
115
|
+
export { PermissionedDomainSet } from './permissionedDomainSet'
|
116
|
+
export { PermissionedDomainDelete } from './permissionedDomainDelete'
|
@@ -88,8 +88,6 @@ export interface TransactionMetadataBase {
|
|
88
88
|
delivered_amount?: Amount | MPTAmount | 'unavailable'
|
89
89
|
TransactionIndex: number
|
90
90
|
TransactionResult: string
|
91
|
-
|
92
|
-
ParentBatchID?: string
|
93
91
|
}
|
94
92
|
|
95
93
|
export type TransactionMetadata<T extends BaseTransaction = Transaction> =
|
@@ -3,7 +3,7 @@ import { Amount } from '../common'
|
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
|
-
|
6
|
+
GlobalFlags,
|
7
7
|
validateBaseTransaction,
|
8
8
|
isAmount,
|
9
9
|
} from './common'
|
@@ -78,7 +78,7 @@ export enum OfferCreateFlags {
|
|
78
78
|
* // }
|
79
79
|
* ```
|
80
80
|
*/
|
81
|
-
export interface OfferCreateFlagsInterface extends
|
81
|
+
export interface OfferCreateFlagsInterface extends GlobalFlags {
|
82
82
|
tfPassive?: boolean
|
83
83
|
tfImmediateOrCancel?: boolean
|
84
84
|
tfFillOrKill?: boolean
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { ValidationError } from '../../errors'
|
2
2
|
import { PriceData } from '../common'
|
3
|
+
import { isHex } from '../utils'
|
3
4
|
|
4
5
|
import {
|
5
6
|
BaseTransaction,
|
@@ -12,6 +13,8 @@ import {
|
|
12
13
|
|
13
14
|
const PRICE_DATA_SERIES_MAX_LENGTH = 10
|
14
15
|
const SCALE_MAX = 10
|
16
|
+
const MINIMUM_ASSET_PRICE_LENGTH = 1
|
17
|
+
const MAXIMUM_ASSET_PRICE_LENGTH = 16
|
15
18
|
|
16
19
|
/**
|
17
20
|
* Creates a new Oracle ledger entry or updates the fields of an existing one, using the Oracle ID.
|
@@ -82,7 +85,7 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
82
85
|
|
83
86
|
validateOptionalField(tx, 'AssetClass', isString)
|
84
87
|
|
85
|
-
|
88
|
+
/* eslint-disable max-statements, max-lines-per-function -- necessary to validate many fields */
|
86
89
|
validateRequiredField(tx, 'PriceDataSeries', (value) => {
|
87
90
|
if (!Array.isArray(value)) {
|
88
91
|
throw new ValidationError('OracleSet: PriceDataSeries must be an array')
|
@@ -142,14 +145,32 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
142
145
|
)
|
143
146
|
}
|
144
147
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access, max-depth --
|
149
|
+
we need to validate priceData.PriceData.AssetPrice value */
|
150
|
+
if ('AssetPrice' in priceData.PriceData) {
|
151
|
+
if (!isNumber(priceData.PriceData.AssetPrice)) {
|
152
|
+
if (typeof priceData.PriceData.AssetPrice !== 'string') {
|
153
|
+
throw new ValidationError(
|
154
|
+
'OracleSet: Field AssetPrice must be a string or a number',
|
155
|
+
)
|
156
|
+
}
|
157
|
+
if (!isHex(priceData.PriceData.AssetPrice)) {
|
158
|
+
throw new ValidationError(
|
159
|
+
'OracleSet: Field AssetPrice must be a valid hex string',
|
160
|
+
)
|
161
|
+
}
|
162
|
+
if (
|
163
|
+
priceData.PriceData.AssetPrice.length <
|
164
|
+
MINIMUM_ASSET_PRICE_LENGTH ||
|
165
|
+
priceData.PriceData.AssetPrice.length > MAXIMUM_ASSET_PRICE_LENGTH
|
166
|
+
) {
|
167
|
+
throw new ValidationError(
|
168
|
+
`OracleSet: Length of AssetPrice field must be between ${MINIMUM_ASSET_PRICE_LENGTH} and ${MAXIMUM_ASSET_PRICE_LENGTH} characters long`,
|
169
|
+
)
|
170
|
+
}
|
171
|
+
}
|
152
172
|
}
|
173
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access, max-depth */
|
153
174
|
|
154
175
|
if (
|
155
176
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
|
@@ -173,4 +194,5 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
173
194
|
}
|
174
195
|
return true
|
175
196
|
})
|
197
|
+
/* eslint-enable max-statements, max-lines-per-function */
|
176
198
|
}
|
@@ -5,7 +5,7 @@ import { isFlagEnabled } from '../utils'
|
|
5
5
|
import {
|
6
6
|
BaseTransaction,
|
7
7
|
isAmount,
|
8
|
-
|
8
|
+
GlobalFlags,
|
9
9
|
validateBaseTransaction,
|
10
10
|
isAccount,
|
11
11
|
validateRequiredField,
|
@@ -84,7 +84,7 @@ export enum PaymentFlags {
|
|
84
84
|
* // }
|
85
85
|
* ```
|
86
86
|
*/
|
87
|
-
export interface PaymentFlagsInterface extends
|
87
|
+
export interface PaymentFlagsInterface extends GlobalFlags {
|
88
88
|
/**
|
89
89
|
* Do not use the default path; only use paths included in the Paths field.
|
90
90
|
* This is intended to force the transaction to take arbitrage opportunities.
|
@@ -2,7 +2,7 @@ import { ValidationError } from '../../errors'
|
|
2
2
|
|
3
3
|
import {
|
4
4
|
BaseTransaction,
|
5
|
-
|
5
|
+
GlobalFlags,
|
6
6
|
validateBaseTransaction,
|
7
7
|
validateCredentialsList,
|
8
8
|
MAX_AUTHORIZED_CREDENTIALS,
|
@@ -73,8 +73,7 @@ export enum PaymentChannelClaimFlags {
|
|
73
73
|
* // }
|
74
74
|
* ```
|
75
75
|
*/
|
76
|
-
export interface PaymentChannelClaimFlagsInterface
|
77
|
-
extends GlobalFlagsInterface {
|
76
|
+
export interface PaymentChannelClaimFlagsInterface extends GlobalFlags {
|
78
77
|
/**
|
79
78
|
* Clear the channel's Expiration time. (Expiration is different from the
|
80
79
|
* channel's immutable CancelAfter time.) Only the source address of the
|
@@ -15,7 +15,6 @@ import { AMMDelete, validateAMMDelete } from './AMMDelete'
|
|
15
15
|
import { AMMDeposit, validateAMMDeposit } from './AMMDeposit'
|
16
16
|
import { AMMVote, validateAMMVote } from './AMMVote'
|
17
17
|
import { AMMWithdraw, validateAMMWithdraw } from './AMMWithdraw'
|
18
|
-
import { Batch, validateBatch } from './batch'
|
19
18
|
import { CheckCancel, validateCheckCancel } from './checkCancel'
|
20
19
|
import { CheckCash, validateCheckCash } from './checkCash'
|
21
20
|
import { CheckCreate, validateCheckCreate } from './checkCreate'
|
@@ -133,7 +132,6 @@ export type SubmittableTransaction =
|
|
133
132
|
| AMMWithdraw
|
134
133
|
| AccountDelete
|
135
134
|
| AccountSet
|
136
|
-
| Batch
|
137
135
|
| CheckCancel
|
138
136
|
| CheckCash
|
139
137
|
| CheckCreate
|
@@ -309,19 +307,6 @@ export function validate(transaction: Record<string, unknown>): void {
|
|
309
307
|
validateAccountSet(tx)
|
310
308
|
break
|
311
309
|
|
312
|
-
case 'Batch':
|
313
|
-
validateBatch(tx)
|
314
|
-
// This is done here to avoid issues with dependency cycles
|
315
|
-
|
316
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- okay here
|
317
|
-
// @ts-expect-error -- already checked
|
318
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- already checked above
|
319
|
-
tx.RawTransactions.forEach((innerTx: Record<string, unknown>) => {
|
320
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- already checked above
|
321
|
-
validate(innerTx.RawTransaction as Record<string, unknown>)
|
322
|
-
})
|
323
|
-
break
|
324
|
-
|
325
310
|
case 'CheckCancel':
|
326
311
|
validateCheckCancel(tx)
|
327
312
|
break
|
@@ -3,7 +3,7 @@ import { IssuedCurrencyAmount } from '../common'
|
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
|
-
|
6
|
+
GlobalFlags,
|
7
7
|
isAmount,
|
8
8
|
validateBaseTransaction,
|
9
9
|
} from './common'
|
@@ -77,7 +77,7 @@ export enum TrustSetFlags {
|
|
77
77
|
* // }
|
78
78
|
* ```
|
79
79
|
*/
|
80
|
-
export interface TrustSetFlagsInterface extends
|
80
|
+
export interface TrustSetFlagsInterface extends GlobalFlags {
|
81
81
|
/**
|
82
82
|
* Authorize the other party to hold currency issued by this account. (No
|
83
83
|
* effect unless using the asfRequireAuth AccountSet flag.) Cannot be unset.
|
@@ -8,8 +8,6 @@ import { AccountSetTfFlags } from '../transactions/accountSet'
|
|
8
8
|
import { AMMClawbackFlags } from '../transactions/AMMClawback'
|
9
9
|
import { AMMDepositFlags } from '../transactions/AMMDeposit'
|
10
10
|
import { AMMWithdrawFlags } from '../transactions/AMMWithdraw'
|
11
|
-
import { BatchFlags } from '../transactions/batch'
|
12
|
-
import { GlobalFlags } from '../transactions/common'
|
13
11
|
import { MPTokenAuthorizeFlags } from '../transactions/MPTokenAuthorize'
|
14
12
|
import { MPTokenIssuanceCreateFlags } from '../transactions/MPTokenIssuanceCreate'
|
15
13
|
import { MPTokenIssuanceSetFlags } from '../transactions/MPTokenIssuanceSet'
|
@@ -53,7 +51,6 @@ const txToFlag = {
|
|
53
51
|
AMMClawback: AMMClawbackFlags,
|
54
52
|
AMMDeposit: AMMDepositFlags,
|
55
53
|
AMMWithdraw: AMMWithdrawFlags,
|
56
|
-
Batch: BatchFlags,
|
57
54
|
MPTokenAuthorize: MPTokenAuthorizeFlags,
|
58
55
|
MPTokenIssuanceCreate: MPTokenIssuanceCreateFlags,
|
59
56
|
MPTokenIssuanceSet: MPTokenIssuanceSetFlags,
|
@@ -120,15 +117,7 @@ export function convertTxFlagsToNumber(tx: Transaction): number {
|
|
120
117
|
}, 0)
|
121
118
|
}
|
122
119
|
|
123
|
-
return
|
124
|
-
if (GlobalFlags[flag] == null) {
|
125
|
-
throw new ValidationError(
|
126
|
-
`Invalid flag ${flag}. Valid flags are ${JSON.stringify(GlobalFlags)}`,
|
127
|
-
)
|
128
|
-
}
|
129
|
-
|
130
|
-
return tx.Flags?.[flag] ? resultFlags | GlobalFlags[flag] : resultFlags
|
131
|
-
}, 0)
|
120
|
+
return 0
|
132
121
|
}
|
133
122
|
|
134
123
|
/**
|
@@ -159,21 +148,3 @@ export function parseTransactionFlags(tx: Transaction): object {
|
|
159
148
|
|
160
149
|
return booleanFlagMap
|
161
150
|
}
|
162
|
-
|
163
|
-
/**
|
164
|
-
* Determines whether a transaction has a certain flag enabled.
|
165
|
-
*
|
166
|
-
* @param tx The transaction.
|
167
|
-
* @param flag The flag to check.
|
168
|
-
* @returns Whether `flag` is enabled on `tx`.
|
169
|
-
*/
|
170
|
-
export function hasFlag(tx: Transaction, flag: number): boolean {
|
171
|
-
if (tx.Flags == null) {
|
172
|
-
return false
|
173
|
-
}
|
174
|
-
if (typeof tx.Flags === 'number') {
|
175
|
-
return isFlagEnabled(tx.Flags, flag)
|
176
|
-
}
|
177
|
-
const txFlagNum = convertTxFlagsToNumber(tx)
|
178
|
-
return isFlagEnabled(txFlagNum, flag)
|
179
|
-
}
|
package/src/sugar/autofill.ts
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
/* eslint-disable max-lines -- lots of helper functions needed for autofill */
|
2
1
|
import BigNumber from 'bignumber.js'
|
3
2
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
4
3
|
|
5
4
|
import { type Client } from '..'
|
6
5
|
import { ValidationError, XrplError } from '../errors'
|
7
6
|
import { AccountInfoRequest, AccountObjectsRequest } from '../models/methods'
|
8
|
-
import {
|
9
|
-
import { GlobalFlags } from '../models/transactions/common'
|
7
|
+
import { Transaction } from '../models/transactions'
|
10
8
|
import { xrpToDrops } from '../utils'
|
11
9
|
|
12
10
|
import getFeeXrp from './getFeeXrp'
|
@@ -209,20 +207,6 @@ function convertToClassicAddress(tx: Transaction, fieldName: string): void {
|
|
209
207
|
}
|
210
208
|
}
|
211
209
|
|
212
|
-
// Helper function to get the next valid sequence number for an account.
|
213
|
-
async function getNextValidSequenceNumber(
|
214
|
-
client: Client,
|
215
|
-
account: string,
|
216
|
-
): Promise<number> {
|
217
|
-
const request: AccountInfoRequest = {
|
218
|
-
command: 'account_info',
|
219
|
-
account,
|
220
|
-
ledger_index: 'current',
|
221
|
-
}
|
222
|
-
const data = await client.request(request)
|
223
|
-
return data.result.account_data.Sequence
|
224
|
-
}
|
225
|
-
|
226
210
|
/**
|
227
211
|
* Sets the next valid sequence number for a transaction.
|
228
212
|
*
|
@@ -235,8 +219,14 @@ export async function setNextValidSequenceNumber(
|
|
235
219
|
client: Client,
|
236
220
|
tx: Transaction,
|
237
221
|
): Promise<void> {
|
222
|
+
const request: AccountInfoRequest = {
|
223
|
+
command: 'account_info',
|
224
|
+
account: tx.Account,
|
225
|
+
ledger_index: 'current',
|
226
|
+
}
|
227
|
+
const data = await client.request(request)
|
238
228
|
// eslint-disable-next-line no-param-reassign, require-atomic-updates -- param reassign is safe with no race condition
|
239
|
-
tx.Sequence =
|
229
|
+
tx.Sequence = data.result.account_data.Sequence
|
240
230
|
}
|
241
231
|
|
242
232
|
/**
|
@@ -284,16 +274,17 @@ export async function calculateFeePerTransactionType(
|
|
284
274
|
scaleValue(netFeeDrops, 33 + fulfillmentBytesSize / 16),
|
285
275
|
)
|
286
276
|
baseFee = product.dp(0, BigNumber.ROUND_CEIL)
|
287
|
-
}
|
277
|
+
}
|
278
|
+
// EscrowCreate transaction with FinishFunction
|
279
|
+
if (tx.TransactionType === 'EscrowCreate' && tx.FinishFunction != null) {
|
280
|
+
baseFee = BigNumber.sum(baseFee, 1000)
|
281
|
+
}
|
282
|
+
|
283
|
+
if (
|
288
284
|
tx.TransactionType === 'AccountDelete' ||
|
289
285
|
tx.TransactionType === 'AMMCreate'
|
290
286
|
) {
|
291
287
|
baseFee = await fetchAccountDeleteFee(client)
|
292
|
-
} else if (tx.TransactionType === 'Batch') {
|
293
|
-
baseFee = BigNumber.sum(
|
294
|
-
baseFee.times(2),
|
295
|
-
baseFee.times(tx.RawTransactions.length + (tx.BatchSigners?.length ?? 0)),
|
296
|
-
)
|
297
288
|
}
|
298
289
|
|
299
290
|
/*
|
@@ -372,119 +363,3 @@ export async function checkAccountDeleteBlockers(
|
|
372
363
|
resolve()
|
373
364
|
})
|
374
365
|
}
|
375
|
-
/**
|
376
|
-
* Replaces Amount with DeliverMax if needed.
|
377
|
-
*
|
378
|
-
* @param tx - The transaction object.
|
379
|
-
* @throws ValidationError if Amount and DeliverMax are both provided but do not match.
|
380
|
-
*/
|
381
|
-
export function handleDeliverMax(tx: Payment): void {
|
382
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
383
|
-
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
384
|
-
if (tx.DeliverMax != null) {
|
385
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- needed here
|
386
|
-
if (tx.Amount == null) {
|
387
|
-
// If only DeliverMax is provided, use it to populate the Amount field
|
388
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
389
|
-
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
390
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, no-param-reassign -- known RPC-level property
|
391
|
-
tx.Amount = tx.DeliverMax
|
392
|
-
}
|
393
|
-
|
394
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
395
|
-
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
396
|
-
|
397
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- needed here
|
398
|
-
if (tx.Amount != null && tx.Amount !== tx.DeliverMax) {
|
399
|
-
throw new ValidationError(
|
400
|
-
'PaymentTransaction: Amount and DeliverMax fields must be identical when both are provided',
|
401
|
-
)
|
402
|
-
}
|
403
|
-
|
404
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
405
|
-
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
406
|
-
// eslint-disable-next-line no-param-reassign -- needed here
|
407
|
-
delete tx.DeliverMax
|
408
|
-
}
|
409
|
-
}
|
410
|
-
|
411
|
-
/**
|
412
|
-
* Autofills all the relevant `x` fields.
|
413
|
-
*
|
414
|
-
* @param client - The client object.
|
415
|
-
* @param tx - The transaction object.
|
416
|
-
* @returns A promise that resolves with void if there are no blockers, or rejects with an XrplError if there are blockers.
|
417
|
-
*/
|
418
|
-
// eslint-disable-next-line complexity, max-lines-per-function, max-statements -- needed here, lots to check
|
419
|
-
export async function autofillBatchTxn(
|
420
|
-
client: Client,
|
421
|
-
tx: Batch,
|
422
|
-
): Promise<void> {
|
423
|
-
const accountSequences: Record<string, number> = {}
|
424
|
-
|
425
|
-
for await (const rawTxn of tx.RawTransactions) {
|
426
|
-
const txn = rawTxn.RawTransaction
|
427
|
-
|
428
|
-
// Flag processing
|
429
|
-
/* eslint-disable no-bitwise -- needed here for flag parsing */
|
430
|
-
if (txn.Flags == null) {
|
431
|
-
txn.Flags = GlobalFlags.tfInnerBatchTxn
|
432
|
-
} else if (typeof txn.Flags === 'number') {
|
433
|
-
if (!((txn.Flags & GlobalFlags.tfInnerBatchTxn) === 0)) {
|
434
|
-
txn.Flags |= GlobalFlags.tfInnerBatchTxn
|
435
|
-
}
|
436
|
-
} else if (!txn.Flags.tfInnerBatchTxn) {
|
437
|
-
txn.Flags.tfInnerBatchTxn = true
|
438
|
-
}
|
439
|
-
/* eslint-enable no-bitwise */
|
440
|
-
|
441
|
-
// Sequence processing
|
442
|
-
if (txn.Sequence == null && txn.TicketSequence == null) {
|
443
|
-
if (txn.Account in accountSequences) {
|
444
|
-
txn.Sequence = accountSequences[txn.Account]
|
445
|
-
accountSequences[txn.Account] += 1
|
446
|
-
} else {
|
447
|
-
const nextSequence = await getNextValidSequenceNumber(
|
448
|
-
client,
|
449
|
-
txn.Account,
|
450
|
-
)
|
451
|
-
const sequence =
|
452
|
-
txn.Account === tx.Account ? nextSequence + 1 : nextSequence
|
453
|
-
accountSequences[txn.Account] = sequence + 1
|
454
|
-
txn.Sequence = sequence
|
455
|
-
}
|
456
|
-
}
|
457
|
-
|
458
|
-
if (txn.Fee == null) {
|
459
|
-
txn.Fee = '0'
|
460
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS check
|
461
|
-
} else if (txn.Fee !== '0') {
|
462
|
-
throw new XrplError('Must have `Fee of "0" in inner Batch transaction.')
|
463
|
-
}
|
464
|
-
|
465
|
-
if (txn.SigningPubKey == null) {
|
466
|
-
txn.SigningPubKey = ''
|
467
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS check
|
468
|
-
} else if (txn.SigningPubKey !== '') {
|
469
|
-
throw new XrplError(
|
470
|
-
'Must have `SigningPubKey` of "" in inner Batch transaction.',
|
471
|
-
)
|
472
|
-
}
|
473
|
-
|
474
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- needed for JS
|
475
|
-
if (txn.TxnSignature != null) {
|
476
|
-
throw new XrplError(
|
477
|
-
'Must not have `TxnSignature` in inner Batch transaction.',
|
478
|
-
)
|
479
|
-
}
|
480
|
-
|
481
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- needed for JS
|
482
|
-
if (txn.Signers != null) {
|
483
|
-
throw new XrplError('Must not have `Signers` in inner Batch transaction.')
|
484
|
-
}
|
485
|
-
|
486
|
-
if (txn.NetworkID == null) {
|
487
|
-
txn.NetworkID = txNeedsNetworkID(client) ? client.networkID : undefined
|
488
|
-
}
|
489
|
-
}
|
490
|
-
}
|
package/src/sugar/submit.ts
CHANGED
@@ -175,6 +175,7 @@ function isSigned(transaction: SubmittableTransaction | string): boolean {
|
|
175
175
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know that tx.Signers is an array of Signers
|
176
176
|
const signers = tx.Signers as Signer[]
|
177
177
|
for (const signer of signers) {
|
178
|
+
// eslint-disable-next-line max-depth -- necessary for checking if signer is signed
|
178
179
|
if (
|
179
180
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- necessary check
|
180
181
|
signer.Signer.SigningPubKey == null ||
|
@@ -282,7 +283,7 @@ export function getLastLedgerSequence(
|
|
282
283
|
transaction: Transaction | string,
|
283
284
|
): number | null {
|
284
285
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
285
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- converts
|
286
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- converts LastLedgSeq to number if present.
|
286
287
|
return tx.LastLedgerSequence as number | null
|
287
288
|
}
|
288
289
|
|
@@ -12,8 +12,6 @@ import { APIVersion } from '../../models'
|
|
12
12
|
import { LedgerEntry } from '../../models/ledger'
|
13
13
|
import { LedgerVersionMap } from '../../models/ledger/Ledger'
|
14
14
|
import { Transaction, TransactionMetadata } from '../../models/transactions'
|
15
|
-
import { GlobalFlags } from '../../models/transactions/common'
|
16
|
-
import { hasFlag } from '../../models/utils/flags'
|
17
15
|
|
18
16
|
import HashPrefix from './HashPrefix'
|
19
17
|
import sha512Half from './sha512Half'
|
@@ -68,7 +66,7 @@ function addLengthPrefix(hex: string): string {
|
|
68
66
|
*
|
69
67
|
* @param tx - A transaction to hash. Tx may be in binary blob form. Tx must be signed.
|
70
68
|
* @returns A hash of tx.
|
71
|
-
* @throws ValidationError if the Transaction is unsigned
|
69
|
+
* @throws ValidationError if the Transaction is unsigned.\
|
72
70
|
* @category Utilities
|
73
71
|
*/
|
74
72
|
export function hashSignedTx(tx: Transaction | string): string {
|
@@ -86,8 +84,7 @@ export function hashSignedTx(tx: Transaction | string): string {
|
|
86
84
|
if (
|
87
85
|
txObject.TxnSignature === undefined &&
|
88
86
|
txObject.Signers === undefined &&
|
89
|
-
txObject.SigningPubKey === undefined
|
90
|
-
!hasFlag(txObject, GlobalFlags.tfInnerBatchTxn)
|
87
|
+
txObject.SigningPubKey === undefined
|
91
88
|
) {
|
92
89
|
throw new ValidationError('The transaction must be signed to hash it.')
|
93
90
|
}
|