xrpl 4.3.0-smartescrow.3 → 4.3.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/README.md +2 -2
- package/build/xrpl-latest-min.js +3 -0
- package/build/xrpl-latest-min.js.map +1 -0
- package/build/xrpl-latest.js +395 -140
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/batchSigner.d.ts +8 -0
- package/dist/npm/Wallet/batchSigner.d.ts.map +1 -0
- package/dist/npm/Wallet/batchSigner.js +111 -0
- package/dist/npm/Wallet/batchSigner.js.map +1 -0
- package/dist/npm/Wallet/defaultFaucets.d.ts +4 -4
- package/dist/npm/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.js +15 -17
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/Wallet/fundWallet.js +8 -16
- package/dist/npm/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/Wallet/index.d.ts.map +1 -1
- package/dist/npm/Wallet/index.js +10 -4
- package/dist/npm/Wallet/index.js.map +1 -1
- package/dist/npm/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/Wallet/signer.js +4 -20
- package/dist/npm/Wallet/signer.js.map +1 -1
- package/dist/npm/Wallet/utils.d.ts +9 -0
- package/dist/npm/Wallet/utils.d.ts.map +1 -0
- package/dist/npm/Wallet/utils.js +28 -0
- package/dist/npm/Wallet/utils.js.map +1 -0
- 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 +6 -9
- 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.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 +0 -2
- package/dist/npm/models/ledger/Escrow.d.ts.map +1 -1
- package/dist/npm/models/ledger/FeeSettings.d.ts +0 -2
- package/dist/npm/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts +1 -2
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts.map +1 -1
- package/dist/npm/models/methods/baseMethod.d.ts +1 -0
- package/dist/npm/models/methods/baseMethod.d.ts.map +1 -1
- package/dist/npm/models/methods/serverInfo.d.ts +0 -6
- package/dist/npm/models/methods/serverInfo.d.ts.map +1 -1
- package/dist/npm/models/methods/serverState.d.ts +0 -6
- package/dist/npm/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMBid.js.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/XChainAddAccountCreateAttestation.js.map +1 -1
- package/dist/npm/models/transactions/XChainAddClaimAttestation.js.map +1 -1
- package/dist/npm/models/transactions/XChainClaim.js.map +1 -1
- package/dist/npm/models/transactions/XChainCommit.js.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/accountDelete.d.ts.map +1 -1
- package/dist/npm/models/transactions/accountDelete.js.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/batch.d.ts +39 -0
- package/dist/npm/models/transactions/batch.d.ts.map +1 -0
- package/dist/npm/models/transactions/batch.js +64 -0
- package/dist/npm/models/transactions/batch.js.map +1 -0
- package/dist/npm/models/transactions/common.d.ts +22 -6
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +25 -10
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/delegateSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/delegateSet.js +1 -0
- package/dist/npm/models/transactions/delegateSet.js.map +1 -1
- package/dist/npm/models/transactions/depositPreauth.d.ts.map +1 -1
- package/dist/npm/models/transactions/depositPreauth.js.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.d.ts +0 -2
- package/dist/npm/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.js +2 -4
- package/dist/npm/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/models/transactions/escrowFinish.d.ts +0 -1
- 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 +3 -2
- 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 +1 -0
- 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.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/payment.js +3 -0
- package/dist/npm/models/transactions/payment.js.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/permissionedDomainSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/permissionedDomainSet.js +1 -1
- package/dist/npm/models/transactions/permissionedDomainSet.js.map +1 -1
- package/dist/npm/models/transactions/signerListSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/signerListSet.js +1 -1
- package/dist/npm/models/transactions/signerListSet.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +2 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +7 -0
- 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.map +1 -1
- package/dist/npm/models/utils/flags.js +24 -9
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/models/utils/index.d.ts +2 -0
- package/dist/npm/models/utils/index.d.ts.map +1 -1
- package/dist/npm/models/utils/index.js +11 -1
- package/dist/npm/models/utils/index.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/batchSigner.d.ts +8 -0
- package/dist/npm/src/Wallet/batchSigner.d.ts.map +1 -0
- package/dist/npm/src/Wallet/batchSigner.js +111 -0
- package/dist/npm/src/Wallet/batchSigner.js.map +1 -0
- package/dist/npm/src/Wallet/defaultFaucets.d.ts +4 -4
- package/dist/npm/src/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js +15 -17
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.js +8 -16
- package/dist/npm/src/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/src/Wallet/index.d.ts.map +1 -1
- package/dist/npm/src/Wallet/index.js +10 -4
- package/dist/npm/src/Wallet/index.js.map +1 -1
- package/dist/npm/src/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/src/Wallet/signer.js +4 -20
- package/dist/npm/src/Wallet/signer.js.map +1 -1
- package/dist/npm/src/Wallet/utils.d.ts +9 -0
- package/dist/npm/src/Wallet/utils.d.ts.map +1 -0
- package/dist/npm/src/Wallet/utils.js +28 -0
- package/dist/npm/src/Wallet/utils.js.map +1 -0
- 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 +6 -9
- 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.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 +0 -2
- package/dist/npm/src/models/ledger/Escrow.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/FeeSettings.d.ts +0 -2
- package/dist/npm/src/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts +1 -2
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts.map +1 -1
- package/dist/npm/src/models/methods/baseMethod.d.ts +1 -0
- package/dist/npm/src/models/methods/baseMethod.d.ts.map +1 -1
- package/dist/npm/src/models/methods/serverInfo.d.ts +0 -6
- package/dist/npm/src/models/methods/serverInfo.d.ts.map +1 -1
- package/dist/npm/src/models/methods/serverState.d.ts +0 -6
- package/dist/npm/src/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMBid.js.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/XChainAddAccountCreateAttestation.js.map +1 -1
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js.map +1 -1
- package/dist/npm/src/models/transactions/XChainClaim.js.map +1 -1
- package/dist/npm/src/models/transactions/XChainCommit.js.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/accountDelete.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/accountDelete.js.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/batch.d.ts +39 -0
- package/dist/npm/src/models/transactions/batch.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/batch.js +64 -0
- package/dist/npm/src/models/transactions/batch.js.map +1 -0
- package/dist/npm/src/models/transactions/common.d.ts +22 -6
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +25 -10
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/delegateSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/delegateSet.js +1 -0
- package/dist/npm/src/models/transactions/delegateSet.js.map +1 -1
- package/dist/npm/src/models/transactions/depositPreauth.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/depositPreauth.js.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.d.ts +0 -2
- package/dist/npm/src/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.js +2 -4
- package/dist/npm/src/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/escrowFinish.d.ts +0 -1
- 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 +3 -2
- 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 +1 -0
- 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.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/payment.js +3 -0
- package/dist/npm/src/models/transactions/payment.js.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/permissionedDomainSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/permissionedDomainSet.js +1 -1
- package/dist/npm/src/models/transactions/permissionedDomainSet.js.map +1 -1
- package/dist/npm/src/models/transactions/signerListSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/signerListSet.js +1 -1
- package/dist/npm/src/models/transactions/signerListSet.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +2 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +7 -0
- 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.map +1 -1
- package/dist/npm/src/models/utils/flags.js +24 -9
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/models/utils/index.d.ts +2 -0
- package/dist/npm/src/models/utils/index.d.ts.map +1 -1
- package/dist/npm/src/models/utils/index.js +11 -1
- package/dist/npm/src/models/utils/index.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +4 -2
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +114 -42
- 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 +4 -1
- package/dist/npm/src/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts +4 -2
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +114 -42
- 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 +4 -1
- package/dist/npm/utils/hashes/hashLedger.js.map +1 -1
- package/package.json +5 -5
- package/src/Wallet/batchSigner.ts +198 -0
- package/src/Wallet/defaultFaucets.ts +17 -20
- package/src/Wallet/fundWallet.ts +17 -28
- package/src/Wallet/index.ts +9 -3
- package/src/Wallet/signer.ts +4 -39
- package/src/Wallet/utils.ts +58 -0
- package/src/client/RequestManager.ts +4 -1
- package/src/client/connection.ts +0 -1
- package/src/client/index.ts +9 -30
- package/src/client/partialPayment.ts +3 -4
- package/src/models/ledger/Credential.ts +2 -2
- package/src/models/ledger/Escrow.ts +0 -4
- package/src/models/ledger/FeeSettings.ts +0 -4
- package/src/models/ledger/XChainOwnedClaimID.ts +1 -3
- package/src/models/methods/baseMethod.ts +1 -0
- package/src/models/methods/serverInfo.ts +0 -9
- package/src/models/methods/serverState.ts +0 -10
- package/src/models/transactions/AMMBid.ts +1 -2
- 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 +3 -2
- 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/XChainAddAccountCreateAttestation.ts +2 -2
- package/src/models/transactions/XChainAddClaimAttestation.ts +2 -2
- package/src/models/transactions/XChainClaim.ts +1 -1
- package/src/models/transactions/XChainCommit.ts +1 -1
- package/src/models/transactions/XChainModifyBridge.ts +2 -2
- package/src/models/transactions/accountDelete.ts +1 -2
- package/src/models/transactions/accountSet.ts +2 -1
- package/src/models/transactions/batch.ts +151 -0
- package/src/models/transactions/common.ts +82 -30
- package/src/models/transactions/delegateSet.ts +1 -0
- package/src/models/transactions/depositPreauth.ts +2 -4
- package/src/models/transactions/escrowCreate.ts +2 -10
- package/src/models/transactions/escrowFinish.ts +1 -4
- package/src/models/transactions/index.ts +3 -3
- package/src/models/transactions/metadata.ts +2 -0
- package/src/models/transactions/offerCreate.ts +2 -2
- package/src/models/transactions/oracleSet.ts +95 -91
- package/src/models/transactions/payment.ts +8 -6
- package/src/models/transactions/paymentChannelClaim.ts +4 -4
- package/src/models/transactions/permissionedDomainSet.ts +3 -7
- package/src/models/transactions/signerListSet.ts +2 -2
- package/src/models/transactions/transaction.ts +15 -0
- package/src/models/transactions/trustSet.ts +2 -2
- package/src/models/utils/flags.ts +28 -10
- package/src/models/utils/index.ts +24 -0
- package/src/sugar/autofill.ts +178 -61
- package/src/sugar/submit.ts +1 -2
- package/src/utils/hashes/hashLedger.ts +5 -2
@@ -85,11 +85,6 @@ export interface ServerInfoResponse extends BaseResponse {
|
|
85
85
|
hash: string
|
86
86
|
reserve_base_xrp: number
|
87
87
|
reserve_inc_xrp: number
|
88
|
-
|
89
|
-
extension_compute: number
|
90
|
-
extension_size: number
|
91
|
-
gas_price: number
|
92
|
-
|
93
88
|
seq: number
|
94
89
|
}
|
95
90
|
/**
|
@@ -257,10 +252,6 @@ export interface ServerInfoResponse extends BaseResponse {
|
|
257
252
|
* object an account owns in the ledger.
|
258
253
|
*/
|
259
254
|
reserve_inc_xrp: number
|
260
|
-
|
261
|
-
extension_compute: number
|
262
|
-
extension_size: number
|
263
|
-
gas_price: number
|
264
255
|
/** The ledger index of the latest validated ledger. */
|
265
256
|
seq: number
|
266
257
|
}
|
@@ -30,11 +30,6 @@ export interface ServerStateResponse extends BaseResponse {
|
|
30
30
|
hash: string
|
31
31
|
reserve_base: number
|
32
32
|
reserve_inc: number
|
33
|
-
|
34
|
-
extension_compute: number
|
35
|
-
extension_size: number
|
36
|
-
gas_price: number
|
37
|
-
|
38
33
|
seq: number
|
39
34
|
}
|
40
35
|
io_latency_ms: number
|
@@ -74,11 +69,6 @@ export interface ServerStateResponse extends BaseResponse {
|
|
74
69
|
hash: string
|
75
70
|
reserve_base: number
|
76
71
|
reserve_inc: number
|
77
|
-
|
78
|
-
extension_compute: number
|
79
|
-
extension_size: number
|
80
|
-
gas_price: number
|
81
|
-
|
82
72
|
seq: number
|
83
73
|
}
|
84
74
|
validation_quorum: number
|
@@ -97,8 +97,7 @@ export function validateAMMBid(tx: Record<string, unknown>): void {
|
|
97
97
|
)
|
98
98
|
}
|
99
99
|
validateAuthAccounts(
|
100
|
-
|
101
|
-
tx.Account as string,
|
100
|
+
tx.Account,
|
102
101
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
103
102
|
tx.AuthAccounts as Array<Record<string, unknown>>,
|
104
103
|
)
|
@@ -4,7 +4,7 @@ import { Currency, IssuedCurrency, IssuedCurrencyAmount } from '../common'
|
|
4
4
|
import {
|
5
5
|
Account,
|
6
6
|
BaseTransaction,
|
7
|
-
|
7
|
+
GlobalFlagsInterface,
|
8
8
|
isAccount,
|
9
9
|
isAmount,
|
10
10
|
isCurrency,
|
@@ -28,7 +28,7 @@ export enum AMMClawbackFlags {
|
|
28
28
|
*
|
29
29
|
* @category Transaction Flags
|
30
30
|
*/
|
31
|
-
export interface AMMClawbackFlagsInterface extends
|
31
|
+
export interface AMMClawbackFlagsInterface extends GlobalFlagsInterface {
|
32
32
|
tfClawTwoAssets?: boolean
|
33
33
|
}
|
34
34
|
|
@@ -3,7 +3,7 @@ import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
|
-
|
6
|
+
GlobalFlagsInterface,
|
7
7
|
isAmount,
|
8
8
|
isCurrency,
|
9
9
|
isIssuedCurrency,
|
@@ -24,7 +24,7 @@ export enum AMMDepositFlags {
|
|
24
24
|
tfTwoAssetIfEmpty = 0x00800000,
|
25
25
|
}
|
26
26
|
|
27
|
-
export interface AMMDepositFlagsInterface extends
|
27
|
+
export interface AMMDepositFlagsInterface extends GlobalFlagsInterface {
|
28
28
|
tfLPToken?: boolean
|
29
29
|
tfSingleAsset?: boolean
|
30
30
|
tfTwoAsset?: boolean
|
@@ -3,7 +3,7 @@ import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
|
-
|
6
|
+
GlobalFlagsInterface,
|
7
7
|
isAmount,
|
8
8
|
isCurrency,
|
9
9
|
isIssuedCurrency,
|
@@ -25,7 +25,7 @@ export enum AMMWithdrawFlags {
|
|
25
25
|
tfLimitLPToken = 0x00400000,
|
26
26
|
}
|
27
27
|
|
28
|
-
export interface AMMWithdrawFlagsInterface extends
|
28
|
+
export interface AMMWithdrawFlagsInterface extends GlobalFlagsInterface {
|
29
29
|
tfLPToken?: boolean
|
30
30
|
tfWithdrawAll?: boolean
|
31
31
|
tfOneAssetWithdrawAll?: boolean
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
Account,
|
7
7
|
validateOptionalField,
|
8
8
|
isAccount,
|
9
|
-
|
9
|
+
GlobalFlagsInterface,
|
10
10
|
} from './common'
|
11
11
|
|
12
12
|
/**
|
@@ -32,7 +32,7 @@ export enum MPTokenAuthorizeFlags {
|
|
32
32
|
*
|
33
33
|
* @category Transaction Flags
|
34
34
|
*/
|
35
|
-
export interface MPTokenAuthorizeFlagsInterface extends
|
35
|
+
export interface MPTokenAuthorizeFlagsInterface extends GlobalFlagsInterface {
|
36
36
|
tfMPTUnauthorize?: boolean
|
37
37
|
}
|
38
38
|
|
@@ -3,7 +3,7 @@ import { isHex, INTEGER_SANITY_CHECK, isFlagEnabled } from '../utils'
|
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
|
-
|
6
|
+
GlobalFlagsInterface,
|
7
7
|
validateBaseTransaction,
|
8
8
|
validateOptionalField,
|
9
9
|
isString,
|
@@ -58,7 +58,8 @@ export enum MPTokenIssuanceCreateFlags {
|
|
58
58
|
*
|
59
59
|
* @category Transaction Flags
|
60
60
|
*/
|
61
|
-
export interface MPTokenIssuanceCreateFlagsInterface
|
61
|
+
export interface MPTokenIssuanceCreateFlagsInterface
|
62
|
+
extends GlobalFlagsInterface {
|
62
63
|
tfMPTCanLock?: boolean
|
63
64
|
tfMPTRequireAuth?: boolean
|
64
65
|
tfMPTCanEscrow?: boolean
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
Account,
|
10
10
|
validateOptionalField,
|
11
11
|
isAccount,
|
12
|
-
|
12
|
+
GlobalFlagsInterface,
|
13
13
|
} from './common'
|
14
14
|
|
15
15
|
/**
|
@@ -34,7 +34,7 @@ export enum MPTokenIssuanceSetFlags {
|
|
34
34
|
*
|
35
35
|
* @category Transaction Flags
|
36
36
|
*/
|
37
|
-
export interface MPTokenIssuanceSetFlagsInterface extends
|
37
|
+
export interface MPTokenIssuanceSetFlagsInterface extends GlobalFlagsInterface {
|
38
38
|
tfMPTLock?: boolean
|
39
39
|
tfMPTUnlock?: boolean
|
40
40
|
}
|
@@ -4,7 +4,7 @@ import { isFlagEnabled } from '../utils'
|
|
4
4
|
|
5
5
|
import {
|
6
6
|
BaseTransaction,
|
7
|
-
|
7
|
+
GlobalFlagsInterface,
|
8
8
|
validateBaseTransaction,
|
9
9
|
isAmount,
|
10
10
|
parseAmountValue,
|
@@ -33,7 +33,7 @@ export enum NFTokenCreateOfferFlags {
|
|
33
33
|
*
|
34
34
|
* @category Transaction Flags
|
35
35
|
*/
|
36
|
-
export interface NFTokenCreateOfferFlagsInterface extends
|
36
|
+
export interface NFTokenCreateOfferFlagsInterface extends GlobalFlagsInterface {
|
37
37
|
tfSellNFToken?: boolean
|
38
38
|
}
|
39
39
|
|
@@ -5,7 +5,7 @@ import { isHex } from '../utils'
|
|
5
5
|
import {
|
6
6
|
Account,
|
7
7
|
BaseTransaction,
|
8
|
-
|
8
|
+
GlobalFlagsInterface,
|
9
9
|
isAccount,
|
10
10
|
isAmount,
|
11
11
|
isNumber,
|
@@ -53,7 +53,7 @@ export enum NFTokenMintFlags {
|
|
53
53
|
*
|
54
54
|
* @category Transaction Flags
|
55
55
|
*/
|
56
|
-
export interface NFTokenMintFlagsInterface extends
|
56
|
+
export interface NFTokenMintFlagsInterface extends GlobalFlagsInterface {
|
57
57
|
tfBurnable?: boolean
|
58
58
|
tfOnlyXRP?: boolean
|
59
59
|
tfTrustLine?: boolean
|
@@ -110,13 +110,13 @@ export function validateXChainAddAccountCreateAttestation(
|
|
110
110
|
validateRequiredField(
|
111
111
|
tx,
|
112
112
|
'WasLockingChainSend',
|
113
|
-
(inp) => inp === 0 || inp === 1,
|
113
|
+
(inp: unknown): inp is 0 | 1 => inp === 0 || inp === 1,
|
114
114
|
)
|
115
115
|
|
116
116
|
validateRequiredField(
|
117
117
|
tx,
|
118
118
|
'XChainAccountCreateCount',
|
119
|
-
(inp) => isNumber(inp) || isString(inp),
|
119
|
+
(inp: unknown): inp is number | string => isNumber(inp) || isString(inp),
|
120
120
|
)
|
121
121
|
|
122
122
|
validateRequiredField(tx, 'XChainBridge', isXChainBridge)
|
@@ -104,7 +104,7 @@ export function validateXChainAddClaimAttestation(
|
|
104
104
|
validateRequiredField(
|
105
105
|
tx,
|
106
106
|
'WasLockingChainSend',
|
107
|
-
(inp) => inp === 0 || inp === 1,
|
107
|
+
(inp: unknown): inp is 0 | 1 => inp === 0 || inp === 1,
|
108
108
|
)
|
109
109
|
|
110
110
|
validateRequiredField(tx, 'XChainBridge', isXChainBridge)
|
@@ -112,6 +112,6 @@ export function validateXChainAddClaimAttestation(
|
|
112
112
|
validateRequiredField(
|
113
113
|
tx,
|
114
114
|
'XChainClaimID',
|
115
|
-
(inp) => isNumber(inp) || isString(inp),
|
115
|
+
(inp: unknown): inp is number | string => isNumber(inp) || isString(inp),
|
116
116
|
)
|
117
117
|
}
|
@@ -68,7 +68,7 @@ export function validateXChainClaim(tx: Record<string, unknown>): void {
|
|
68
68
|
validateRequiredField(
|
69
69
|
tx,
|
70
70
|
'XChainClaimID',
|
71
|
-
(inp) => isNumber(inp) || isString(inp),
|
71
|
+
(inp: unknown): inp is number | string => isNumber(inp) || isString(inp),
|
72
72
|
)
|
73
73
|
|
74
74
|
validateRequiredField(tx, 'Destination', isAccount)
|
@@ -67,7 +67,7 @@ export function validateXChainCommit(tx: Record<string, unknown>): void {
|
|
67
67
|
validateRequiredField(
|
68
68
|
tx,
|
69
69
|
'XChainClaimID',
|
70
|
-
(inp) => isNumber(inp) || isString(inp),
|
70
|
+
(inp: unknown): inp is number | string => isNumber(inp) || isString(inp),
|
71
71
|
)
|
72
72
|
|
73
73
|
validateOptionalField(tx, 'OtherChainDestination', isAccount)
|
@@ -2,7 +2,7 @@ import { Amount, XChainBridge } from '../common'
|
|
2
2
|
|
3
3
|
import {
|
4
4
|
BaseTransaction,
|
5
|
-
|
5
|
+
GlobalFlagsInterface,
|
6
6
|
isAmount,
|
7
7
|
isXChainBridge,
|
8
8
|
validateBaseTransaction,
|
@@ -26,7 +26,7 @@ export enum XChainModifyBridgeFlags {
|
|
26
26
|
*
|
27
27
|
* @category Transaction Flags
|
28
28
|
*/
|
29
|
-
export interface XChainModifyBridgeFlagsInterface extends
|
29
|
+
export interface XChainModifyBridgeFlagsInterface extends GlobalFlagsInterface {
|
30
30
|
/** Clears the MinAccountCreateAmount of the bridge. */
|
31
31
|
tfClearAccountCreateAmount?: boolean
|
32
32
|
}
|
@@ -52,8 +52,7 @@ export function validateAccountDelete(tx: Record<string, unknown>): void {
|
|
52
52
|
|
53
53
|
validateCredentialsList(
|
54
54
|
tx.CredentialIDs,
|
55
|
-
|
56
|
-
tx.TransactionType as string,
|
55
|
+
tx.TransactionType,
|
57
56
|
true,
|
58
57
|
MAX_AUTHORIZED_CREDENTIALS,
|
59
58
|
)
|
@@ -3,6 +3,7 @@ import { ValidationError } from '../../errors'
|
|
3
3
|
import {
|
4
4
|
Account,
|
5
5
|
BaseTransaction,
|
6
|
+
GlobalFlagsInterface,
|
6
7
|
isAccount,
|
7
8
|
validateBaseTransaction,
|
8
9
|
validateOptionalField,
|
@@ -112,7 +113,7 @@ export enum AccountSetTfFlags {
|
|
112
113
|
* // }
|
113
114
|
* ```
|
114
115
|
*/
|
115
|
-
export interface AccountSetFlagsInterface {
|
116
|
+
export interface AccountSetFlagsInterface extends GlobalFlagsInterface {
|
116
117
|
tfRequireDestTag?: boolean
|
117
118
|
tfOptionalDestTag?: boolean
|
118
119
|
tfRequireAuth?: boolean
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Signer } from '../common'
|
3
|
+
import { hasFlag } from '../utils'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
GlobalFlags,
|
8
|
+
GlobalFlagsInterface,
|
9
|
+
isArray,
|
10
|
+
isRecord,
|
11
|
+
isString,
|
12
|
+
validateBaseTransaction,
|
13
|
+
validateOptionalField,
|
14
|
+
validateRequiredField,
|
15
|
+
} from './common'
|
16
|
+
import type { SubmittableTransaction } from './transaction'
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Enum representing values of {@link Batch} transaction flags.
|
20
|
+
*
|
21
|
+
* @category Transaction Flags
|
22
|
+
*/
|
23
|
+
export enum BatchFlags {
|
24
|
+
tfAllOrNothing = 0x00010000,
|
25
|
+
tfOnlyOne = 0x00020000,
|
26
|
+
tfUntilFailure = 0x00040000,
|
27
|
+
tfIndependent = 0x00080000,
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Map of flags to boolean values representing {@link Batch} transaction
|
32
|
+
* flags.
|
33
|
+
*
|
34
|
+
* @category Transaction Flags
|
35
|
+
*/
|
36
|
+
export interface BatchFlagsInterface extends GlobalFlagsInterface {
|
37
|
+
tfAllOrNothing?: boolean
|
38
|
+
tfOnlyOne?: boolean
|
39
|
+
tfUntilFailure?: boolean
|
40
|
+
tfIndependent?: boolean
|
41
|
+
}
|
42
|
+
|
43
|
+
export type BatchInnerTransaction = SubmittableTransaction & {
|
44
|
+
Fee?: '0'
|
45
|
+
|
46
|
+
SigningPubKey?: ''
|
47
|
+
|
48
|
+
TxnSignature?: never
|
49
|
+
|
50
|
+
Signers?: never
|
51
|
+
|
52
|
+
LastLedgerSequence?: never
|
53
|
+
}
|
54
|
+
|
55
|
+
export interface BatchSigner {
|
56
|
+
BatchSigner: {
|
57
|
+
Account: string
|
58
|
+
|
59
|
+
SigningPubKey?: string
|
60
|
+
|
61
|
+
TxnSignature?: string
|
62
|
+
|
63
|
+
Signers?: Signer[]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @category Transaction Models
|
69
|
+
*/
|
70
|
+
export interface Batch extends BaseTransaction {
|
71
|
+
TransactionType: 'Batch'
|
72
|
+
|
73
|
+
BatchSigners?: BatchSigner[]
|
74
|
+
|
75
|
+
RawTransactions: Array<{
|
76
|
+
RawTransaction: BatchInnerTransaction
|
77
|
+
}>
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Verify the form and type of a Batch at runtime.
|
82
|
+
*
|
83
|
+
* @param tx - A Batch Transaction.
|
84
|
+
* @throws When the Batch is malformed.
|
85
|
+
*/
|
86
|
+
// eslint-disable-next-line max-lines-per-function -- needed here due to the complexity
|
87
|
+
export function validateBatch(tx: Record<string, unknown>): void {
|
88
|
+
validateBaseTransaction(tx)
|
89
|
+
|
90
|
+
validateRequiredField(tx, 'RawTransactions', isArray)
|
91
|
+
|
92
|
+
tx.RawTransactions.forEach((rawTxObj, index) => {
|
93
|
+
if (!isRecord(rawTxObj)) {
|
94
|
+
throw new ValidationError(
|
95
|
+
`Batch: RawTransactions[${index}] is not object.`,
|
96
|
+
)
|
97
|
+
}
|
98
|
+
validateRequiredField(rawTxObj, 'RawTransaction', isRecord, {
|
99
|
+
paramName: `RawTransactions[${index}].RawTransaction`,
|
100
|
+
txType: 'Batch',
|
101
|
+
})
|
102
|
+
|
103
|
+
const rawTx = rawTxObj.RawTransaction
|
104
|
+
if (rawTx.TransactionType === 'Batch') {
|
105
|
+
throw new ValidationError(
|
106
|
+
`Batch: RawTransactions[${index}] is a Batch transaction. Cannot nest Batch transactions.`,
|
107
|
+
)
|
108
|
+
}
|
109
|
+
|
110
|
+
// Check for the `tfInnerBatchTxn` flag in the inner transactions
|
111
|
+
if (!hasFlag(rawTx, GlobalFlags.tfInnerBatchTxn, 'tfInnerBatchTxn')) {
|
112
|
+
throw new ValidationError(
|
113
|
+
`Batch: RawTransactions[${index}] must contain the \`tfInnerBatchTxn\` flag.`,
|
114
|
+
)
|
115
|
+
}
|
116
|
+
|
117
|
+
// Full validation of each `RawTransaction` object is done in `validate` to avoid dependency cycles
|
118
|
+
})
|
119
|
+
|
120
|
+
validateOptionalField(tx, 'BatchSigners', isArray)
|
121
|
+
|
122
|
+
tx.BatchSigners?.forEach((signerObj, index) => {
|
123
|
+
if (!isRecord(signerObj)) {
|
124
|
+
throw new ValidationError(`Batch: BatchSigners[${index}] is not object.`)
|
125
|
+
}
|
126
|
+
|
127
|
+
const signerRecord = signerObj
|
128
|
+
validateRequiredField(signerRecord, 'BatchSigner', isRecord, {
|
129
|
+
paramName: `BatchSigners[${index}].BatchSigner`,
|
130
|
+
txType: 'Batch',
|
131
|
+
})
|
132
|
+
|
133
|
+
const signer = signerRecord.BatchSigner
|
134
|
+
validateRequiredField(signer, 'Account', isString, {
|
135
|
+
paramName: `BatchSigners[${index}].Account`,
|
136
|
+
txType: 'Batch',
|
137
|
+
})
|
138
|
+
validateOptionalField(signer, 'SigningPubKey', isString, {
|
139
|
+
paramName: `BatchSigners[${index}].SigningPubKey`,
|
140
|
+
txType: 'Batch',
|
141
|
+
})
|
142
|
+
validateOptionalField(signer, 'TxnSignature', isString, {
|
143
|
+
paramName: `BatchSigners[${index}].TxnSignature`,
|
144
|
+
txType: 'Batch',
|
145
|
+
})
|
146
|
+
validateOptionalField(signer, 'Signers', isArray, {
|
147
|
+
paramName: `BatchSigners[${index}].Signers`,
|
148
|
+
txType: 'Batch',
|
149
|
+
})
|
150
|
+
})
|
151
|
+
}
|
@@ -69,7 +69,13 @@ const XCHAIN_BRIDGE_SIZE = 4
|
|
69
69
|
const MPTOKEN_SIZE = 2
|
70
70
|
const AUTHORIZE_CREDENTIAL_SIZE = 1
|
71
71
|
|
72
|
-
|
72
|
+
/**
|
73
|
+
* Verify the form and type of a Record/Object at runtime.
|
74
|
+
*
|
75
|
+
* @param value - The object to check the form and type of.
|
76
|
+
* @returns Whether the Record/Object is properly formed.
|
77
|
+
*/
|
78
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
73
79
|
return value !== null && typeof value === 'object'
|
74
80
|
}
|
75
81
|
|
@@ -210,30 +216,54 @@ export function isXChainBridge(input: unknown): input is XChainBridge {
|
|
210
216
|
)
|
211
217
|
}
|
212
218
|
|
219
|
+
/**
|
220
|
+
* Verify the form and type of an Array at runtime.
|
221
|
+
*
|
222
|
+
* @param input - The object to check the form and type of.
|
223
|
+
* @returns Whether the Array is properly formed.
|
224
|
+
*/
|
225
|
+
export function isArray<T = unknown>(input: unknown): input is T[] {
|
226
|
+
return Array.isArray(input)
|
227
|
+
}
|
228
|
+
|
213
229
|
/* eslint-disable @typescript-eslint/restrict-template-expressions -- tx.TransactionType is checked before any calls */
|
214
230
|
|
215
231
|
/**
|
216
232
|
* Verify the form and type of a required type for a transaction at runtime.
|
217
233
|
*
|
218
|
-
* @param tx - The
|
219
|
-
* @param
|
234
|
+
* @param tx - The object input to check the form and type of.
|
235
|
+
* @param param - The object parameter.
|
220
236
|
* @param checkValidity - The function to use to check the type.
|
221
|
-
* @
|
237
|
+
* @param errorOpts - Extra values to make the error message easier to understand.
|
238
|
+
* @param errorOpts.txType - The transaction type throwing the error.
|
239
|
+
* @param errorOpts.paramName - The name of the parameter in the transaction with the error.
|
240
|
+
* @throws ValidationError if the parameter is missing or invalid.
|
222
241
|
*/
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
242
|
+
// eslint-disable-next-line max-params -- helper function
|
243
|
+
export function validateRequiredField<
|
244
|
+
T extends Record<string, unknown>,
|
245
|
+
K extends keyof T,
|
246
|
+
V,
|
247
|
+
>(
|
248
|
+
tx: T,
|
249
|
+
param: K,
|
250
|
+
checkValidity: (inp: unknown) => inp is V,
|
251
|
+
errorOpts: {
|
252
|
+
txType?: string
|
253
|
+
paramName?: string
|
254
|
+
} = {},
|
255
|
+
): asserts tx is T & { [P in K]: V } {
|
256
|
+
const paramNameStr = errorOpts.paramName ?? param
|
257
|
+
const txType = errorOpts.txType ?? tx.TransactionType
|
258
|
+
if (tx[param] == null) {
|
229
259
|
throw new ValidationError(
|
230
|
-
`${
|
260
|
+
`${txType}: missing field ${String(paramNameStr)}`,
|
231
261
|
)
|
232
262
|
}
|
233
263
|
|
234
|
-
if (!checkValidity(tx[
|
264
|
+
if (!checkValidity(tx[param])) {
|
235
265
|
throw new ValidationError(
|
236
|
-
`${
|
266
|
+
`${txType}: invalid field ${String(paramNameStr)}`,
|
237
267
|
)
|
238
268
|
}
|
239
269
|
}
|
@@ -242,31 +272,50 @@ export function validateRequiredField(
|
|
242
272
|
* Verify the form and type of an optional type for a transaction at runtime.
|
243
273
|
*
|
244
274
|
* @param tx - The transaction input to check the form and type of.
|
245
|
-
* @param
|
275
|
+
* @param param - The object parameter.
|
246
276
|
* @param checkValidity - The function to use to check the type.
|
247
|
-
* @
|
277
|
+
* @param errorOpts - Extra values to make the error message easier to understand.
|
278
|
+
* @param errorOpts.txType - The transaction type throwing the error.
|
279
|
+
* @param errorOpts.paramName - The name of the parameter in the transaction with the error.
|
280
|
+
* @throws ValidationError if the parameter is invalid.
|
248
281
|
*/
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
282
|
+
// eslint-disable-next-line max-params -- helper function
|
283
|
+
export function validateOptionalField<
|
284
|
+
T extends Record<string, unknown>,
|
285
|
+
K extends keyof T,
|
286
|
+
V,
|
287
|
+
>(
|
288
|
+
tx: T,
|
289
|
+
param: K,
|
290
|
+
checkValidity: (inp: unknown) => inp is V,
|
291
|
+
errorOpts: {
|
292
|
+
txType?: string
|
293
|
+
paramName?: string
|
294
|
+
} = {},
|
295
|
+
): asserts tx is T & { [P in K]: V | undefined } {
|
296
|
+
const paramNameStr = errorOpts.paramName ?? param
|
297
|
+
const txType = errorOpts.txType ?? tx.TransactionType
|
298
|
+
if (tx[param] !== undefined && !checkValidity(tx[param])) {
|
255
299
|
throw new ValidationError(
|
256
|
-
`${
|
300
|
+
`${txType}: invalid field ${String(paramNameStr)}`,
|
257
301
|
)
|
258
302
|
}
|
259
303
|
}
|
260
304
|
|
261
305
|
/* eslint-enable @typescript-eslint/restrict-template-expressions -- checked before */
|
262
306
|
|
263
|
-
|
264
|
-
|
307
|
+
export enum GlobalFlags {
|
308
|
+
tfInnerBatchTxn = 0x40000000,
|
309
|
+
}
|
310
|
+
|
311
|
+
export interface GlobalFlagsInterface {
|
312
|
+
tfInnerBatchTxn?: boolean
|
313
|
+
}
|
265
314
|
|
266
315
|
/**
|
267
316
|
* Every transaction has the same set of common fields.
|
268
317
|
*/
|
269
|
-
export interface BaseTransaction {
|
318
|
+
export interface BaseTransaction extends Record<string, unknown> {
|
270
319
|
/** The unique address of the transaction sender. */
|
271
320
|
Account: Account
|
272
321
|
/**
|
@@ -294,7 +343,7 @@ export interface BaseTransaction {
|
|
294
343
|
*/
|
295
344
|
AccountTxnID?: string
|
296
345
|
/** Set of bit-flags for this transaction. */
|
297
|
-
Flags?: number |
|
346
|
+
Flags?: number | GlobalFlagsInterface
|
298
347
|
/**
|
299
348
|
* Highest ledger index this transaction can appear in. Specifying this field
|
300
349
|
* places a strict upper limit on how long the transaction can wait to be
|
@@ -351,8 +400,10 @@ export interface BaseTransaction {
|
|
351
400
|
* @param common - An interface w/ common transaction fields.
|
352
401
|
* @throws When the common param is malformed.
|
353
402
|
*/
|
354
|
-
// eslint-disable-next-line max-statements -- lines required for validation
|
355
|
-
export function validateBaseTransaction(
|
403
|
+
// eslint-disable-next-line max-statements, max-lines-per-function -- lines required for validation
|
404
|
+
export function validateBaseTransaction(
|
405
|
+
common: Record<string, unknown>,
|
406
|
+
): asserts common is BaseTransaction {
|
356
407
|
if (common.TransactionType === undefined) {
|
357
408
|
throw new ValidationError('BaseTransaction: missing field TransactionType')
|
358
409
|
}
|
@@ -362,7 +413,9 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
|
|
362
413
|
}
|
363
414
|
|
364
415
|
if (!TRANSACTION_TYPES.includes(common.TransactionType)) {
|
365
|
-
throw new ValidationError(
|
416
|
+
throw new ValidationError(
|
417
|
+
`BaseTransaction: Unknown TransactionType ${common.TransactionType}`,
|
418
|
+
)
|
366
419
|
}
|
367
420
|
|
368
421
|
validateRequiredField(common, 'Account', isString)
|
@@ -548,7 +601,6 @@ export function containsDuplicates(
|
|
548
601
|
if (isAuthorizeCredentialArray(objectList)) {
|
549
602
|
for (const item of objectList) {
|
550
603
|
const key = `${item.Credential.Issuer}-${item.Credential.CredentialType}`
|
551
|
-
// eslint-disable-next-line max-depth -- necessary to check for type-guards
|
552
604
|
if (seen.has(key)) {
|
553
605
|
return true
|
554
606
|
}
|
@@ -70,16 +70,14 @@ export function validateDepositPreauth(tx: Record<string, unknown>): void {
|
|
70
70
|
} else if (tx.AuthorizeCredentials !== undefined) {
|
71
71
|
validateCredentialsList(
|
72
72
|
tx.AuthorizeCredentials,
|
73
|
-
|
74
|
-
tx.TransactionType as string,
|
73
|
+
tx.TransactionType,
|
75
74
|
false,
|
76
75
|
MAX_AUTHORIZED_CREDENTIALS,
|
77
76
|
)
|
78
77
|
} else if (tx.UnauthorizeCredentials !== undefined) {
|
79
78
|
validateCredentialsList(
|
80
79
|
tx.UnauthorizeCredentials,
|
81
|
-
|
82
|
-
tx.TransactionType as string,
|
80
|
+
tx.TransactionType,
|
83
81
|
false,
|
84
82
|
MAX_AUTHORIZED_CREDENTIALS,
|
85
83
|
)
|