xrpl 4.3.0 → 4.4.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-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +1293 -1596
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.d.ts +2 -1
- package/dist/npm/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.js +3 -0
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/client/index.d.ts +3 -3
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +10 -7
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js +2 -2
- package/dist/npm/client/partialPayment.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +1 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.d.ts +1 -1
- package/dist/npm/models/ledger/AccountRoot.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/ledger/LedgerEntry.d.ts +3 -2
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/Vault.d.ts +21 -0
- package/dist/npm/models/ledger/Vault.d.ts.map +1 -0
- package/dist/npm/models/ledger/Vault.js +3 -0
- package/dist/npm/models/ledger/Vault.js.map +1 -0
- package/dist/npm/models/ledger/index.d.ts +2 -1
- package/dist/npm/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.js.map +1 -1
- package/dist/npm/models/methods/index.d.ts +5 -4
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/serverInfo.d.ts +6 -0
- package/dist/npm/models/methods/serverInfo.d.ts.map +1 -1
- package/dist/npm/models/methods/serverState.d.ts +6 -0
- package/dist/npm/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/models/methods/vaultInfo.d.ts +46 -0
- package/dist/npm/models/methods/vaultInfo.d.ts.map +1 -0
- package/dist/npm/models/methods/vaultInfo.js +3 -0
- package/dist/npm/models/methods/vaultInfo.js.map +1 -0
- package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMBid.js +7 -5
- package/dist/npm/models/transactions/AMMBid.js.map +1 -1
- package/dist/npm/models/transactions/AMMClawback.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMClawback.js +5 -6
- package/dist/npm/models/transactions/AMMClawback.js.map +1 -1
- package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMDelete.js +2 -2
- package/dist/npm/models/transactions/AMMDelete.js.map +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js +3 -3
- package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMVote.js +2 -2
- package/dist/npm/models/transactions/AMMVote.js.map +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.js +3 -3
- package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +3 -3
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js +4 -4
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.js +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.js +6 -2
- package/dist/npm/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/models/transactions/checkCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/checkCreate.js +1 -2
- package/dist/npm/models/transactions/checkCreate.js.map +1 -1
- package/dist/npm/models/transactions/clawback.d.ts +2 -2
- package/dist/npm/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/models/transactions/clawback.js +4 -6
- package/dist/npm/models/transactions/clawback.js.map +1 -1
- package/dist/npm/models/transactions/common.d.ts +9 -4
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +51 -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/escrowFinish.d.ts +1 -0
- package/dist/npm/models/transactions/escrowFinish.d.ts.map +1 -1
- package/dist/npm/models/transactions/escrowFinish.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +8 -2
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +4 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/oracleSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/oracleSet.js +22 -21
- package/dist/npm/models/transactions/oracleSet.js.map +1 -1
- package/dist/npm/models/transactions/payment.d.ts +1 -0
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/payment.js +6 -4
- package/dist/npm/models/transactions/payment.js.map +1 -1
- package/dist/npm/models/transactions/signerListSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/signerListSet.js +10 -16
- package/dist/npm/models/transactions/signerListSet.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +7 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +28 -35
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/transactions/vaultClawback.d.ts +10 -0
- package/dist/npm/models/transactions/vaultClawback.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultClawback.js +12 -0
- package/dist/npm/models/transactions/vaultClawback.js.map +1 -0
- package/dist/npm/models/transactions/vaultCreate.d.ts +24 -0
- package/dist/npm/models/transactions/vaultCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultCreate.js +51 -0
- package/dist/npm/models/transactions/vaultCreate.js.map +1 -0
- package/dist/npm/models/transactions/vaultDelete.d.ts +7 -0
- package/dist/npm/models/transactions/vaultDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultDelete.js +10 -0
- package/dist/npm/models/transactions/vaultDelete.js.map +1 -0
- package/dist/npm/models/transactions/vaultDeposit.d.ts +9 -0
- package/dist/npm/models/transactions/vaultDeposit.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultDeposit.js +11 -0
- package/dist/npm/models/transactions/vaultDeposit.js.map +1 -0
- package/dist/npm/models/transactions/vaultSet.d.ts +10 -0
- package/dist/npm/models/transactions/vaultSet.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultSet.js +25 -0
- package/dist/npm/models/transactions/vaultSet.js.map +1 -0
- package/dist/npm/models/transactions/vaultWithdraw.d.ts +10 -0
- package/dist/npm/models/transactions/vaultWithdraw.d.ts.map +1 -0
- package/dist/npm/models/transactions/vaultWithdraw.js +12 -0
- package/dist/npm/models/transactions/vaultWithdraw.js.map +1 -0
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +2 -0
- 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 +2 -1
- package/dist/npm/src/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js +3 -0
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/client/index.d.ts +3 -3
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +10 -7
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js +2 -2
- package/dist/npm/src/client/partialPayment.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +1 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.d.ts +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.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/ledger/LedgerEntry.d.ts +3 -2
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Vault.d.ts +21 -0
- package/dist/npm/src/models/ledger/Vault.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/Vault.js +3 -0
- package/dist/npm/src/models/ledger/Vault.js.map +1 -0
- package/dist/npm/src/models/ledger/index.d.ts +2 -1
- package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.js.map +1 -1
- package/dist/npm/src/models/methods/index.d.ts +5 -4
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/serverInfo.d.ts +6 -0
- package/dist/npm/src/models/methods/serverInfo.d.ts.map +1 -1
- package/dist/npm/src/models/methods/serverState.d.ts +6 -0
- package/dist/npm/src/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/src/models/methods/vaultInfo.d.ts +46 -0
- package/dist/npm/src/models/methods/vaultInfo.d.ts.map +1 -0
- package/dist/npm/src/models/methods/vaultInfo.js +3 -0
- package/dist/npm/src/models/methods/vaultInfo.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMBid.js +7 -5
- package/dist/npm/src/models/transactions/AMMBid.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMClawback.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMClawback.js +5 -6
- package/dist/npm/src/models/transactions/AMMClawback.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMDelete.js +2 -2
- package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js +3 -3
- package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMVote.js +2 -2
- package/dist/npm/src/models/transactions/AMMVote.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.js +3 -3
- package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +3 -3
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js +4 -4
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.js +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js +6 -2
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/checkCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/checkCreate.js +1 -2
- package/dist/npm/src/models/transactions/checkCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/clawback.d.ts +2 -2
- package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/clawback.js +4 -6
- package/dist/npm/src/models/transactions/clawback.js.map +1 -1
- package/dist/npm/src/models/transactions/common.d.ts +9 -4
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +51 -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/escrowFinish.d.ts +1 -0
- package/dist/npm/src/models/transactions/escrowFinish.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/escrowFinish.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +8 -2
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +4 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/oracleSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/oracleSet.js +22 -21
- package/dist/npm/src/models/transactions/oracleSet.js.map +1 -1
- package/dist/npm/src/models/transactions/payment.d.ts +1 -0
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/payment.js +6 -4
- package/dist/npm/src/models/transactions/payment.js.map +1 -1
- package/dist/npm/src/models/transactions/signerListSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/signerListSet.js +10 -16
- package/dist/npm/src/models/transactions/signerListSet.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +7 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +28 -35
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/transactions/vaultClawback.d.ts +10 -0
- package/dist/npm/src/models/transactions/vaultClawback.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultClawback.js +12 -0
- package/dist/npm/src/models/transactions/vaultClawback.js.map +1 -0
- package/dist/npm/src/models/transactions/vaultCreate.d.ts +24 -0
- package/dist/npm/src/models/transactions/vaultCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultCreate.js +51 -0
- package/dist/npm/src/models/transactions/vaultCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/vaultDelete.d.ts +7 -0
- package/dist/npm/src/models/transactions/vaultDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultDelete.js +10 -0
- package/dist/npm/src/models/transactions/vaultDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/vaultDeposit.d.ts +9 -0
- package/dist/npm/src/models/transactions/vaultDeposit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultDeposit.js +11 -0
- package/dist/npm/src/models/transactions/vaultDeposit.js.map +1 -0
- package/dist/npm/src/models/transactions/vaultSet.d.ts +10 -0
- package/dist/npm/src/models/transactions/vaultSet.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultSet.js +25 -0
- package/dist/npm/src/models/transactions/vaultSet.js.map +1 -0
- package/dist/npm/src/models/transactions/vaultWithdraw.d.ts +10 -0
- package/dist/npm/src/models/transactions/vaultWithdraw.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/vaultWithdraw.js +12 -0
- package/dist/npm/src/models/transactions/vaultWithdraw.js.map +1 -0
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +2 -0
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +32 -11
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +32 -11
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/package.json +5 -4
- package/src/Wallet/defaultFaucets.ts +5 -0
- package/src/client/index.ts +43 -38
- package/src/client/partialPayment.ts +1 -2
- package/src/models/common/index.ts +2 -0
- package/src/models/ledger/AccountRoot.ts +1 -1
- package/src/models/ledger/Escrow.ts +4 -0
- package/src/models/ledger/FeeSettings.ts +4 -0
- package/src/models/ledger/LedgerEntry.ts +3 -0
- package/src/models/ledger/Vault.ts +83 -0
- package/src/models/ledger/index.ts +3 -1
- package/src/models/methods/index.ts +10 -0
- package/src/models/methods/serverInfo.ts +9 -0
- package/src/models/methods/serverState.ts +10 -0
- package/src/models/methods/vaultInfo.ts +193 -0
- package/src/models/transactions/AMMBid.ts +12 -20
- package/src/models/transactions/AMMClawback.ts +8 -11
- package/src/models/transactions/AMMDelete.ts +7 -3
- package/src/models/transactions/AMMDeposit.ts +4 -4
- package/src/models/transactions/AMMVote.ts +7 -3
- package/src/models/transactions/AMMWithdraw.ts +4 -4
- package/src/models/transactions/MPTokenIssuanceCreate.ts +3 -1
- package/src/models/transactions/MPTokenIssuanceSet.ts +1 -1
- package/src/models/transactions/NFTokenCancelOffer.ts +2 -2
- package/src/models/transactions/NFTokenCreateOffer.ts +8 -4
- package/src/models/transactions/checkCreate.ts +2 -6
- package/src/models/transactions/clawback.ts +9 -10
- package/src/models/transactions/common.ts +114 -41
- package/src/models/transactions/escrowCreate.ts +10 -2
- package/src/models/transactions/escrowFinish.ts +2 -0
- package/src/models/transactions/index.ts +13 -2
- package/src/models/transactions/oracleSet.ts +32 -39
- package/src/models/transactions/payment.ts +13 -7
- package/src/models/transactions/signerListSet.ts +21 -21
- package/src/models/transactions/transaction.ts +46 -43
- package/src/models/transactions/vaultClawback.ts +55 -0
- package/src/models/transactions/vaultCreate.ts +142 -0
- package/src/models/transactions/vaultDelete.ts +32 -0
- package/src/models/transactions/vaultDeposit.ts +41 -0
- package/src/models/transactions/vaultSet.ts +71 -0
- package/src/models/transactions/vaultWithdraw.ts +50 -0
- package/src/models/utils/flags.ts +2 -0
- package/src/sugar/autofill.ts +44 -31
@@ -7,31 +7,42 @@ import { ValidationError } from '../../errors'
|
|
7
7
|
import {
|
8
8
|
Amount,
|
9
9
|
AuthorizeCredential,
|
10
|
+
ClawbackAmount,
|
10
11
|
Currency,
|
12
|
+
IssuedCurrency,
|
11
13
|
IssuedCurrencyAmount,
|
12
14
|
MPTAmount,
|
13
15
|
Memo,
|
14
16
|
Signer,
|
15
17
|
XChainBridge,
|
16
18
|
} from '../common'
|
17
|
-
import { onlyHasFields } from '../utils'
|
19
|
+
import { isHex, onlyHasFields } from '../utils'
|
18
20
|
|
19
21
|
const MEMO_SIZE = 3
|
20
22
|
export const MAX_AUTHORIZED_CREDENTIALS = 8
|
21
23
|
const MAX_CREDENTIAL_BYTE_LENGTH = 64
|
22
24
|
const MAX_CREDENTIAL_TYPE_LENGTH = MAX_CREDENTIAL_BYTE_LENGTH * 2
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
// Used for Vault transactions
|
27
|
+
export const VAULT_DATA_MAX_BYTE_LENGTH = 256
|
28
|
+
|
29
|
+
function isMemo(obj: unknown): obj is Memo {
|
30
|
+
if (!isRecord(obj)) {
|
31
|
+
return false
|
32
|
+
}
|
33
|
+
|
34
|
+
const memo = obj.Memo
|
35
|
+
if (!isRecord(memo)) {
|
26
36
|
return false
|
27
37
|
}
|
28
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
29
|
-
const memo = obj.Memo as Record<string, unknown>
|
30
38
|
const size = Object.keys(memo).length
|
31
|
-
const validData =
|
39
|
+
const validData =
|
40
|
+
memo.MemoData == null || (isString(memo.MemoData) && isHex(memo.MemoData))
|
32
41
|
const validFormat =
|
33
|
-
memo.MemoFormat == null ||
|
34
|
-
|
42
|
+
memo.MemoFormat == null ||
|
43
|
+
(isString(memo.MemoFormat) && isHex(memo.MemoFormat))
|
44
|
+
const validType =
|
45
|
+
memo.MemoType == null || (isString(memo.MemoType) && isHex(memo.MemoType))
|
35
46
|
|
36
47
|
return (
|
37
48
|
size >= 1 &&
|
@@ -45,20 +56,21 @@ function isMemo(obj: { Memo?: unknown }): boolean {
|
|
45
56
|
|
46
57
|
const SIGNER_SIZE = 3
|
47
58
|
|
48
|
-
function isSigner(obj: unknown):
|
49
|
-
|
50
|
-
|
59
|
+
function isSigner(obj: unknown): obj is Signer {
|
60
|
+
if (!isRecord(obj)) {
|
61
|
+
return false
|
62
|
+
}
|
51
63
|
|
52
|
-
|
64
|
+
const signer = obj.Signer
|
65
|
+
if (!isRecord(signer)) {
|
53
66
|
return false
|
54
67
|
}
|
55
|
-
|
56
|
-
const signer = signerWrapper.Signer as Record<string, unknown>
|
68
|
+
|
57
69
|
return (
|
58
70
|
Object.keys(signer).length === SIGNER_SIZE &&
|
59
|
-
|
60
|
-
|
61
|
-
|
71
|
+
isString(signer.Account) &&
|
72
|
+
isString(signer.TxnSignature) &&
|
73
|
+
isString(signer.SigningPubKey)
|
62
74
|
)
|
63
75
|
}
|
64
76
|
|
@@ -76,7 +88,7 @@ const AUTHORIZE_CREDENTIAL_SIZE = 1
|
|
76
88
|
* @returns Whether the Record/Object is properly formed.
|
77
89
|
*/
|
78
90
|
export function isRecord(value: unknown): value is Record<string, unknown> {
|
79
|
-
return value !== null && typeof value === 'object'
|
91
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
80
92
|
}
|
81
93
|
|
82
94
|
/**
|
@@ -99,18 +111,50 @@ export function isNumber(num: unknown): num is number {
|
|
99
111
|
return typeof num === 'number'
|
100
112
|
}
|
101
113
|
|
114
|
+
/**
|
115
|
+
* Checks whether the given value is a valid XRPL number string.
|
116
|
+
* Accepts integer, decimal, or scientific notation strings.
|
117
|
+
*
|
118
|
+
* Examples of valid input:
|
119
|
+
* - "123"
|
120
|
+
* - "-987.654"
|
121
|
+
* - "+3.14e10"
|
122
|
+
* - "-7.2e-9"
|
123
|
+
*
|
124
|
+
* @param value - The value to check.
|
125
|
+
* @returns True if value is a string that matches the XRPL number format, false otherwise.
|
126
|
+
*/
|
127
|
+
export function isXRPLNumber(value: unknown): value is XRPLNumber {
|
128
|
+
// Matches optional sign, digits, optional decimal, optional exponent (scientific)
|
129
|
+
// Allows leading zeros, but not empty string, lone sign, or missing digits
|
130
|
+
return (
|
131
|
+
typeof value === 'string' &&
|
132
|
+
/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/u.test(value.trim())
|
133
|
+
)
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Verify the form and type of a Currency at runtime.
|
138
|
+
*
|
139
|
+
* @param input - The input to check the form and type of.
|
140
|
+
* @returns Whether the Currency is properly formed.
|
141
|
+
*/
|
142
|
+
export function isCurrency(input: unknown): input is Currency {
|
143
|
+
return isString(input) || isIssuedCurrency(input)
|
144
|
+
}
|
145
|
+
|
102
146
|
/**
|
103
147
|
* Verify the form and type of an IssuedCurrency at runtime.
|
104
148
|
*
|
105
149
|
* @param input - The input to check the form and type of.
|
106
150
|
* @returns Whether the IssuedCurrency is properly formed.
|
107
151
|
*/
|
108
|
-
export function
|
152
|
+
export function isIssuedCurrency(input: unknown): input is IssuedCurrency {
|
109
153
|
return (
|
110
154
|
isRecord(input) &&
|
111
155
|
((Object.keys(input).length === ISSUE_SIZE &&
|
112
|
-
|
113
|
-
|
156
|
+
isString(input.issuer) &&
|
157
|
+
isString(input.currency)) ||
|
114
158
|
(Object.keys(input).length === XRP_CURRENCY_SIZE &&
|
115
159
|
input.currency === 'XRP'))
|
116
160
|
)
|
@@ -122,15 +166,15 @@ export function isCurrency(input: unknown): input is Currency {
|
|
122
166
|
* @param input - The input to check the form and type of.
|
123
167
|
* @returns Whether the IssuedCurrencyAmount is properly formed.
|
124
168
|
*/
|
125
|
-
export function
|
169
|
+
export function isIssuedCurrencyAmount(
|
126
170
|
input: unknown,
|
127
171
|
): input is IssuedCurrencyAmount {
|
128
172
|
return (
|
129
173
|
isRecord(input) &&
|
130
174
|
Object.keys(input).length === ISSUED_CURRENCY_SIZE &&
|
131
|
-
|
132
|
-
|
133
|
-
|
175
|
+
isString(input.value) &&
|
176
|
+
isString(input.issuer) &&
|
177
|
+
isString(input.currency)
|
134
178
|
)
|
135
179
|
}
|
136
180
|
|
@@ -167,11 +211,33 @@ export function isMPTAmount(input: unknown): input is MPTAmount {
|
|
167
211
|
)
|
168
212
|
}
|
169
213
|
|
214
|
+
/**
|
215
|
+
* Type guard to verify if the input is a valid ClawbackAmount.
|
216
|
+
*
|
217
|
+
* A ClawbackAmount can be either an {@link IssuedCurrencyAmount} or an {@link MPTAmount}.
|
218
|
+
* This function checks if the input matches either type.
|
219
|
+
*
|
220
|
+
* @param input - The value to check for ClawbackAmount structure.
|
221
|
+
* @returns True if the input is an IssuedCurrencyAmount or MPTAmount, otherwise false.
|
222
|
+
*/
|
223
|
+
export function isClawbackAmount(input: unknown): input is ClawbackAmount {
|
224
|
+
return isIssuedCurrencyAmount(input) || isMPTAmount(input)
|
225
|
+
}
|
226
|
+
|
170
227
|
/**
|
171
228
|
* Must be a valid account address
|
172
229
|
*/
|
173
230
|
export type Account = string
|
174
231
|
|
232
|
+
/**
|
233
|
+
* XRPL Number type represented as a string.
|
234
|
+
*
|
235
|
+
* This string can be an integer (e.g., "123"), a decimal (e.g., "123.45"),
|
236
|
+
* or in scientific notation (e.g., "1.23e5", "-4.56e-7").
|
237
|
+
* Used for fields that accept arbitrary-precision numbers in XRPL transactions and ledger objects.
|
238
|
+
*/
|
239
|
+
export type XRPLNumber = string
|
240
|
+
|
175
241
|
/**
|
176
242
|
* Verify a string is in fact a valid account address.
|
177
243
|
*
|
@@ -194,7 +260,7 @@ export function isAccount(account: unknown): account is Account {
|
|
194
260
|
export function isAmount(amount: unknown): amount is Amount {
|
195
261
|
return (
|
196
262
|
typeof amount === 'string' ||
|
197
|
-
|
263
|
+
isIssuedCurrencyAmount(amount) ||
|
198
264
|
isMPTAmount(amount)
|
199
265
|
)
|
200
266
|
}
|
@@ -210,9 +276,9 @@ export function isXChainBridge(input: unknown): input is XChainBridge {
|
|
210
276
|
isRecord(input) &&
|
211
277
|
Object.keys(input).length === XCHAIN_BRIDGE_SIZE &&
|
212
278
|
typeof input.LockingChainDoor === 'string' &&
|
213
|
-
|
279
|
+
isIssuedCurrency(input.LockingChainIssue) &&
|
214
280
|
typeof input.IssuingChainDoor === 'string' &&
|
215
|
-
|
281
|
+
isIssuedCurrency(input.IssuingChainIssue)
|
216
282
|
)
|
217
283
|
}
|
218
284
|
|
@@ -223,7 +289,7 @@ export function isXChainBridge(input: unknown): input is XChainBridge {
|
|
223
289
|
* @returns Whether the Array is properly formed.
|
224
290
|
*/
|
225
291
|
export function isArray<T = unknown>(input: unknown): input is T[] {
|
226
|
-
return Array.isArray(input)
|
292
|
+
return input != null && Array.isArray(input)
|
227
293
|
}
|
228
294
|
|
229
295
|
/* eslint-disable @typescript-eslint/restrict-template-expressions -- tx.TransactionType is checked before any calls */
|
@@ -402,8 +468,14 @@ export interface BaseTransaction extends Record<string, unknown> {
|
|
402
468
|
*/
|
403
469
|
// eslint-disable-next-line max-statements, max-lines-per-function -- lines required for validation
|
404
470
|
export function validateBaseTransaction(
|
405
|
-
common:
|
471
|
+
common: unknown,
|
406
472
|
): asserts common is BaseTransaction {
|
473
|
+
if (!isRecord(common)) {
|
474
|
+
throw new ValidationError(
|
475
|
+
'BaseTransaction: invalid, expected a valid object',
|
476
|
+
)
|
477
|
+
}
|
478
|
+
|
407
479
|
if (common.TransactionType === undefined) {
|
408
480
|
throw new ValidationError('BaseTransaction: missing field TransactionType')
|
409
481
|
}
|
@@ -428,18 +500,16 @@ export function validateBaseTransaction(
|
|
428
500
|
|
429
501
|
validateOptionalField(common, 'LastLedgerSequence', isNumber)
|
430
502
|
|
431
|
-
|
432
|
-
|
433
|
-
if (memos !== undefined && !memos.every(isMemo)) {
|
503
|
+
const memos = common.Memos
|
504
|
+
if (memos != null && (!isArray(memos) || !memos.every(isMemo))) {
|
434
505
|
throw new ValidationError('BaseTransaction: invalid Memos')
|
435
506
|
}
|
436
507
|
|
437
|
-
|
438
|
-
const signers = common.Signers as Array<Record<string, unknown>> | undefined
|
508
|
+
const signers = common.Signers
|
439
509
|
|
440
510
|
if (
|
441
|
-
signers
|
442
|
-
(signers.length === 0 || !signers.every(isSigner))
|
511
|
+
signers != null &&
|
512
|
+
(!isArray(signers) || signers.length === 0 || !signers.every(isSigner))
|
443
513
|
) {
|
444
514
|
throw new ValidationError('BaseTransaction: invalid Signers')
|
445
515
|
}
|
@@ -486,7 +556,9 @@ export function parseAmountValue(amount: unknown): number {
|
|
486
556
|
* @param tx A CredentialType Transaction.
|
487
557
|
* @throws when the CredentialType is malformed.
|
488
558
|
*/
|
489
|
-
export function validateCredentialType
|
559
|
+
export function validateCredentialType<
|
560
|
+
T extends BaseTransaction & Record<string, unknown>,
|
561
|
+
>(tx: T): void {
|
490
562
|
if (typeof tx.TransactionType !== 'string') {
|
491
563
|
throw new ValidationError('Invalid TransactionType')
|
492
564
|
}
|
@@ -528,7 +600,7 @@ export function validateCredentialType(tx: Record<string, unknown>): void {
|
|
528
600
|
* PermissionedDomainSet transaction uses 10, other transactions use 8.
|
529
601
|
* @throws Validation Error if the formatting is incorrect
|
530
602
|
*/
|
531
|
-
// eslint-disable-next-line max-lines-per-function
|
603
|
+
// eslint-disable-next-line max-params, max-lines-per-function -- separating logic further will add unnecessary complexity
|
532
604
|
export function validateCredentialsList(
|
533
605
|
credentials: unknown,
|
534
606
|
transactionType: string,
|
@@ -538,7 +610,7 @@ export function validateCredentialsList(
|
|
538
610
|
if (credentials == null) {
|
539
611
|
return
|
540
612
|
}
|
541
|
-
if (!
|
613
|
+
if (!isArray(credentials)) {
|
542
614
|
throw new ValidationError(
|
543
615
|
`${transactionType}: Credentials must be an array`,
|
544
616
|
)
|
@@ -565,7 +637,8 @@ export function validateCredentialsList(
|
|
565
637
|
)
|
566
638
|
}
|
567
639
|
})
|
568
|
-
|
640
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- checked above
|
641
|
+
if (containsDuplicates(credentials as string[] | AuthorizeCredential[])) {
|
569
642
|
throw new ValidationError(
|
570
643
|
`${transactionType}: Credentials cannot contain duplicate elements`,
|
571
644
|
)
|
@@ -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
|
|
@@ -95,14 +95,25 @@ export {
|
|
95
95
|
} from './paymentChannelClaim'
|
96
96
|
export { PaymentChannelCreate } from './paymentChannelCreate'
|
97
97
|
export { PaymentChannelFund } from './paymentChannelFund'
|
98
|
+
export { PermissionedDomainSet } from './permissionedDomainSet'
|
99
|
+
export { PermissionedDomainDelete } from './permissionedDomainDelete'
|
98
100
|
export { SetFee, SetFeePreAmendment, SetFeePostAmendment } from './setFee'
|
99
101
|
export { SetRegularKey } from './setRegularKey'
|
100
102
|
export { SignerListSet } from './signerListSet'
|
101
103
|
export { TicketCreate } from './ticketCreate'
|
102
104
|
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
103
105
|
export { UNLModify } from './UNLModify'
|
104
|
-
export {
|
105
|
-
export {
|
106
|
+
export { VaultClawback } from './vaultClawback'
|
107
|
+
export {
|
108
|
+
VaultCreate,
|
109
|
+
VaultCreateFlags,
|
110
|
+
VaultCreateFlagsInterface,
|
111
|
+
VaultWithdrawalPolicy,
|
112
|
+
} from './vaultCreate'
|
113
|
+
export { VaultDelete } from './vaultDelete'
|
114
|
+
export { VaultDeposit } from './vaultDeposit'
|
115
|
+
export { VaultSet } from './vaultSet'
|
116
|
+
export { VaultWithdraw } from './vaultWithdraw'
|
106
117
|
export { XChainAddAccountCreateAttestation } from './XChainAddAccountCreateAttestation'
|
107
118
|
export { XChainAddClaimAttestation } from './XChainAddClaimAttestation'
|
108
119
|
export { XChainClaim } from './XChainClaim'
|
@@ -4,7 +4,9 @@ import { isHex } from '../utils'
|
|
4
4
|
|
5
5
|
import {
|
6
6
|
BaseTransaction,
|
7
|
+
isArray,
|
7
8
|
isNumber,
|
9
|
+
isRecord,
|
8
10
|
isString,
|
9
11
|
validateBaseTransaction,
|
10
12
|
validateOptionalField,
|
@@ -90,7 +92,7 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
90
92
|
tx,
|
91
93
|
'PriceDataSeries',
|
92
94
|
(value: unknown): value is PriceData => {
|
93
|
-
if (!
|
95
|
+
if (!isArray(value)) {
|
94
96
|
throw new ValidationError('OracleSet: PriceDataSeries must be an array')
|
95
97
|
}
|
96
98
|
|
@@ -102,14 +104,15 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
102
104
|
|
103
105
|
// TODO: add support for handling inner objects easier (similar to validateRequiredField/validateOptionalField)
|
104
106
|
for (const priceData of value) {
|
105
|
-
if (
|
107
|
+
if (!isRecord(priceData)) {
|
106
108
|
throw new ValidationError(
|
107
109
|
'OracleSet: PriceDataSeries must be an array of objects',
|
108
110
|
)
|
109
111
|
}
|
110
112
|
|
111
|
-
|
112
|
-
|
113
|
+
const priceDataInner = priceData.PriceData
|
114
|
+
|
115
|
+
if (!isRecord(priceDataInner)) {
|
113
116
|
throw new ValidationError(
|
114
117
|
'OracleSet: PriceDataSeries must have a `PriceData` object',
|
115
118
|
)
|
@@ -122,15 +125,16 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
122
125
|
)
|
123
126
|
}
|
124
127
|
|
125
|
-
|
126
|
-
|
128
|
+
if (
|
129
|
+
priceDataInner.BaseAsset == null ||
|
130
|
+
typeof priceDataInner.BaseAsset !== 'string'
|
131
|
+
) {
|
127
132
|
throw new ValidationError(
|
128
133
|
'OracleSet: PriceDataSeries must have a `BaseAsset` string',
|
129
134
|
)
|
130
135
|
}
|
131
136
|
|
132
|
-
|
133
|
-
if (typeof priceData.PriceData.QuoteAsset !== 'string') {
|
137
|
+
if (typeof priceDataInner.QuoteAsset !== 'string') {
|
134
138
|
throw new ValidationError(
|
135
139
|
'OracleSet: PriceDataSeries must have a `QuoteAsset` string',
|
136
140
|
)
|
@@ -138,34 +142,31 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
138
142
|
|
139
143
|
// Either AssetPrice and Scale are both present or both excluded
|
140
144
|
if (
|
141
|
-
|
142
|
-
(
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we are validating the type
|
144
|
-
(priceData.PriceData.Scale == null)
|
145
|
+
(priceDataInner.AssetPrice == null) !==
|
146
|
+
(priceDataInner.Scale == null)
|
145
147
|
) {
|
146
148
|
throw new ValidationError(
|
147
149
|
'OracleSet: PriceDataSeries must have both `AssetPrice` and `Scale` if any are present',
|
148
150
|
)
|
149
151
|
}
|
150
152
|
|
151
|
-
/* eslint-disable
|
152
|
-
we need to validate
|
153
|
-
if ('AssetPrice' in
|
154
|
-
if (!isNumber(
|
155
|
-
if (typeof
|
153
|
+
/* eslint-disable max-depth --
|
154
|
+
we need to validate priceDataInner.AssetPrice value */
|
155
|
+
if ('AssetPrice' in priceDataInner) {
|
156
|
+
if (!isNumber(priceDataInner.AssetPrice)) {
|
157
|
+
if (typeof priceDataInner.AssetPrice !== 'string') {
|
156
158
|
throw new ValidationError(
|
157
159
|
'OracleSet: Field AssetPrice must be a string or a number',
|
158
160
|
)
|
159
161
|
}
|
160
|
-
if (!isHex(
|
162
|
+
if (!isHex(priceDataInner.AssetPrice)) {
|
161
163
|
throw new ValidationError(
|
162
164
|
'OracleSet: Field AssetPrice must be a valid hex string',
|
163
165
|
)
|
164
166
|
}
|
165
167
|
if (
|
166
|
-
|
167
|
-
|
168
|
-
priceData.PriceData.AssetPrice.length > MAXIMUM_ASSET_PRICE_LENGTH
|
168
|
+
priceDataInner.AssetPrice.length < MINIMUM_ASSET_PRICE_LENGTH ||
|
169
|
+
priceDataInner.AssetPrice.length > MAXIMUM_ASSET_PRICE_LENGTH
|
169
170
|
) {
|
170
171
|
throw new ValidationError(
|
171
172
|
`OracleSet: Length of AssetPrice field must be between ${MINIMUM_ASSET_PRICE_LENGTH} and ${MAXIMUM_ASSET_PRICE_LENGTH} characters long`,
|
@@ -173,26 +174,18 @@ export function validateOracleSet(tx: Record<string, unknown>): void {
|
|
173
174
|
}
|
174
175
|
}
|
175
176
|
}
|
176
|
-
/* eslint-enable @typescript-eslint/no-unsafe-member-access, max-depth */
|
177
177
|
|
178
|
-
if (
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
!isNumber(priceData.PriceData.Scale)
|
183
|
-
) {
|
184
|
-
throw new ValidationError('OracleSet: invalid field Scale')
|
185
|
-
}
|
178
|
+
if ('Scale' in priceDataInner) {
|
179
|
+
if (!isNumber(priceDataInner.Scale)) {
|
180
|
+
throw new ValidationError('OracleSet: invalid field Scale')
|
181
|
+
}
|
186
182
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
throw new ValidationError(
|
194
|
-
`OracleSet: Scale must be in range 0-${SCALE_MAX}`,
|
195
|
-
)
|
183
|
+
if (priceDataInner.Scale < 0 || priceDataInner.Scale > SCALE_MAX) {
|
184
|
+
throw new ValidationError(
|
185
|
+
`OracleSet: Scale must be in range 0-${SCALE_MAX}`,
|
186
|
+
)
|
187
|
+
}
|
188
|
+
/* eslint-enable max-depth */
|
196
189
|
}
|
197
190
|
}
|
198
191
|
return true
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
Account,
|
15
15
|
validateCredentialsList,
|
16
16
|
MAX_AUTHORIZED_CREDENTIALS,
|
17
|
+
isArray,
|
17
18
|
} from './common'
|
18
19
|
import type { TransactionMetadataBase } from './metadata'
|
19
20
|
|
@@ -119,6 +120,9 @@ export interface Payment extends BaseTransaction {
|
|
119
120
|
* to this amount instead.
|
120
121
|
*/
|
121
122
|
Amount: Amount | MPTAmount
|
123
|
+
|
124
|
+
DeliverMax?: Amount | MPTAmount
|
125
|
+
|
122
126
|
/** The unique address of the account receiving the payment. */
|
123
127
|
Destination: Account
|
124
128
|
/**
|
@@ -195,11 +199,7 @@ export function validatePayment(tx: Record<string, unknown>): void {
|
|
195
199
|
throw new ValidationError('PaymentTransaction: InvoiceID must be a string')
|
196
200
|
}
|
197
201
|
|
198
|
-
if (
|
199
|
-
tx.Paths !== undefined &&
|
200
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
201
|
-
!isPaths(tx.Paths as Array<Array<Record<string, unknown>>>)
|
202
|
-
) {
|
202
|
+
if (tx.Paths !== undefined && !isPaths(tx.Paths)) {
|
203
203
|
throw new ValidationError('PaymentTransaction: invalid Paths')
|
204
204
|
}
|
205
205
|
|
@@ -208,6 +208,12 @@ export function validatePayment(tx: Record<string, unknown>): void {
|
|
208
208
|
}
|
209
209
|
|
210
210
|
checkPartialPayment(tx)
|
211
|
+
|
212
|
+
if (tx.DeliverMax != null) {
|
213
|
+
throw new ValidationError(
|
214
|
+
'PaymentTransaction: Cannot have DeliverMax in a submitted transaction',
|
215
|
+
)
|
216
|
+
}
|
211
217
|
}
|
212
218
|
|
213
219
|
function checkPartialPayment(tx: Record<string, unknown>): void {
|
@@ -276,12 +282,12 @@ function isPath(path: unknown): path is Path {
|
|
276
282
|
}
|
277
283
|
|
278
284
|
function isPaths(paths: unknown): paths is Path[] {
|
279
|
-
if (!
|
285
|
+
if (!isArray(paths) || paths.length === 0) {
|
280
286
|
return false
|
281
287
|
}
|
282
288
|
|
283
289
|
for (const path of paths) {
|
284
|
-
if (!
|
290
|
+
if (!isArray(path) || path.length === 0) {
|
285
291
|
return false
|
286
292
|
}
|
287
293
|
|
@@ -1,7 +1,15 @@
|
|
1
1
|
import { ValidationError } from '../../errors'
|
2
2
|
import { SignerEntry } from '../common'
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
BaseTransaction,
|
6
|
+
isArray,
|
7
|
+
isNumber,
|
8
|
+
isRecord,
|
9
|
+
isString,
|
10
|
+
validateBaseTransaction,
|
11
|
+
validateRequiredField,
|
12
|
+
} from './common'
|
5
13
|
|
6
14
|
/**
|
7
15
|
* The SignerListSet transaction creates, replaces, or removes a list of
|
@@ -39,27 +47,14 @@ const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u
|
|
39
47
|
export function validateSignerListSet(tx: Record<string, unknown>): void {
|
40
48
|
validateBaseTransaction(tx)
|
41
49
|
|
42
|
-
|
43
|
-
throw new ValidationError('SignerListSet: missing field SignerQuorum')
|
44
|
-
}
|
45
|
-
|
46
|
-
if (typeof tx.SignerQuorum !== 'number') {
|
47
|
-
throw new ValidationError('SignerListSet: invalid SignerQuorum')
|
48
|
-
}
|
50
|
+
validateRequiredField(tx, 'SignerQuorum', isNumber)
|
49
51
|
|
50
52
|
// All other checks are for if SignerQuorum is greater than 0
|
51
53
|
if (tx.SignerQuorum === 0) {
|
52
54
|
return
|
53
55
|
}
|
54
56
|
|
55
|
-
|
56
|
-
throw new ValidationError('SignerListSet: missing field SignerEntries')
|
57
|
-
}
|
58
|
-
|
59
|
-
if (!isArray(tx.SignerEntries)) {
|
60
|
-
throw new ValidationError('SignerListSet: invalid SignerEntries')
|
61
|
-
}
|
62
|
-
|
57
|
+
validateRequiredField(tx, 'SignerEntries', isArray)
|
63
58
|
if (tx.SignerEntries.length === 0) {
|
64
59
|
throw new ValidationError(
|
65
60
|
'SignerListSet: need at least 1 member in SignerEntries',
|
@@ -73,12 +68,17 @@ export function validateSignerListSet(tx: Record<string, unknown>): void {
|
|
73
68
|
}
|
74
69
|
|
75
70
|
for (const entry of tx.SignerEntries) {
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
if (!isRecord(entry) || !isRecord(entry.SignerEntry)) {
|
72
|
+
throw new ValidationError(
|
73
|
+
'SignerListSet: SignerEntries must be an array of SignerEntry objects',
|
74
|
+
)
|
75
|
+
}
|
76
|
+
const signerEntry = entry.SignerEntry
|
77
|
+
const { WalletLocator } = signerEntry
|
79
78
|
if (
|
80
|
-
WalletLocator
|
81
|
-
!
|
79
|
+
WalletLocator != null &&
|
80
|
+
(!isString(WalletLocator) ||
|
81
|
+
!HEX_WALLET_LOCATOR_REGEX.test(WalletLocator))
|
82
82
|
) {
|
83
83
|
throw new ValidationError(
|
84
84
|
`SignerListSet: WalletLocator in SignerEntry must be a 256-bit (32-byte) hexadecimal value`,
|