xrpl 4.3.0 → 4.4.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 +1609 -1773
- package/build/xrpl-latest.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 +17 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.d.ts +4 -2
- package/dist/npm/models/ledger/AccountRoot.d.ts.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.js +1 -0
- package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/models/ledger/DirectoryNode.d.ts +1 -0
- package/dist/npm/models/ledger/DirectoryNode.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/LedgerEntry.d.ts +3 -2
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/MPToken.d.ts +1 -0
- package/dist/npm/models/ledger/MPToken.d.ts.map +1 -1
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts +1 -0
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts.map +1 -1
- package/dist/npm/models/ledger/Offer.d.ts +10 -1
- package/dist/npm/models/ledger/Offer.d.ts.map +1 -1
- package/dist/npm/models/ledger/Offer.js +1 -0
- package/dist/npm/models/ledger/Offer.js.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/bookOffers.d.ts +1 -0
- package/dist/npm/models/methods/bookOffers.d.ts.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/pathFind.d.ts +2 -0
- package/dist/npm/models/methods/pathFind.d.ts.map +1 -1
- package/dist/npm/models/methods/ripplePathFind.d.ts +1 -0
- package/dist/npm/models/methods/ripplePathFind.d.ts.map +1 -1
- package/dist/npm/models/methods/subscribe.d.ts +4 -0
- package/dist/npm/models/methods/subscribe.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 +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +17 -8
- 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/accountSet.d.ts +2 -1
- package/dist/npm/models/transactions/accountSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/accountSet.js +1 -0
- package/dist/npm/models/transactions/accountSet.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 +13 -4
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +184 -28
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.d.ts +2 -1
- package/dist/npm/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/escrowCreate.js +1 -6
- package/dist/npm/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +9 -3
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +5 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/offerCreate.d.ts +4 -1
- package/dist/npm/models/transactions/offerCreate.d.ts.map +1 -1
- package/dist/npm/models/transactions/offerCreate.js +10 -0
- package/dist/npm/models/transactions/offerCreate.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 +2 -0
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/payment.js +7 -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 +60 -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/src/permissionedDEX.d.ts +2 -0
- package/dist/npm/snippets/src/permissionedDEX.d.ts.map +1 -0
- package/dist/npm/snippets/src/permissionedDEX.js +173 -0
- package/dist/npm/snippets/src/permissionedDEX.js.map +1 -0
- package/dist/npm/snippets/tsconfig.tsbuildinfo +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 +17 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.d.ts +4 -2
- package/dist/npm/src/models/ledger/AccountRoot.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js +1 -0
- package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/src/models/ledger/DirectoryNode.d.ts +1 -0
- package/dist/npm/src/models/ledger/DirectoryNode.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/LedgerEntry.d.ts +3 -2
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/MPToken.d.ts +1 -0
- package/dist/npm/src/models/ledger/MPToken.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts +1 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Offer.d.ts +10 -1
- package/dist/npm/src/models/ledger/Offer.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Offer.js +1 -0
- package/dist/npm/src/models/ledger/Offer.js.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/bookOffers.d.ts +1 -0
- package/dist/npm/src/models/methods/bookOffers.d.ts.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/pathFind.d.ts +2 -0
- package/dist/npm/src/models/methods/pathFind.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ripplePathFind.d.ts +1 -0
- package/dist/npm/src/models/methods/ripplePathFind.d.ts.map +1 -1
- package/dist/npm/src/models/methods/subscribe.d.ts +4 -0
- package/dist/npm/src/models/methods/subscribe.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 +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +17 -8
- 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/accountSet.d.ts +2 -1
- package/dist/npm/src/models/transactions/accountSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/accountSet.js +1 -0
- package/dist/npm/src/models/transactions/accountSet.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 +13 -4
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +184 -28
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.d.ts +2 -1
- package/dist/npm/src/models/transactions/escrowCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/escrowCreate.js +1 -6
- package/dist/npm/src/models/transactions/escrowCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +9 -3
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +5 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/offerCreate.d.ts +4 -1
- package/dist/npm/src/models/transactions/offerCreate.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/offerCreate.js +10 -0
- package/dist/npm/src/models/transactions/offerCreate.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 +2 -0
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/payment.js +7 -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 +60 -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.map +1 -1
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/package.json +6 -5
- package/src/client/index.ts +43 -38
- package/src/client/partialPayment.ts +1 -2
- package/src/models/common/index.ts +27 -0
- package/src/models/ledger/AccountRoot.ts +11 -1
- package/src/models/ledger/DirectoryNode.ts +3 -0
- package/src/models/ledger/Escrow.ts +14 -1
- package/src/models/ledger/LedgerEntry.ts +3 -0
- package/src/models/ledger/MPToken.ts +1 -0
- package/src/models/ledger/MPTokenIssuance.ts +1 -0
- package/src/models/ledger/Offer.ts +21 -0
- package/src/models/ledger/Vault.ts +83 -0
- package/src/models/ledger/index.ts +3 -1
- package/src/models/methods/bookOffers.ts +7 -0
- package/src/models/methods/index.ts +10 -0
- package/src/models/methods/pathFind.ts +10 -0
- package/src/models/methods/ripplePathFind.ts +5 -0
- package/src/models/methods/subscribe.ts +21 -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 +36 -11
- 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/accountSet.ts +2 -0
- package/src/models/transactions/checkCreate.ts +2 -6
- package/src/models/transactions/clawback.ts +9 -10
- package/src/models/transactions/common.ts +350 -42
- package/src/models/transactions/escrowCreate.ts +8 -12
- package/src/models/transactions/index.ts +14 -3
- package/src/models/transactions/offerCreate.ts +25 -0
- package/src/models/transactions/oracleSet.ts +32 -39
- package/src/models/transactions/payment.ts +25 -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 +166 -0
- package/src/models/transactions/vaultDelete.ts +32 -0
- package/src/models/transactions/vaultDeposit.ts +42 -0
- package/src/models/transactions/vaultSet.ts +71 -0
- package/src/models/transactions/vaultWithdraw.ts +51 -0
- package/src/models/utils/flags.ts +2 -0
- package/src/sugar/autofill.ts +5 -6
@@ -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
|
@@ -8,12 +8,14 @@ import {
|
|
8
8
|
GlobalFlagsInterface,
|
9
9
|
validateBaseTransaction,
|
10
10
|
isAccount,
|
11
|
+
isDomainID,
|
11
12
|
validateRequiredField,
|
12
13
|
validateOptionalField,
|
13
14
|
isNumber,
|
14
15
|
Account,
|
15
16
|
validateCredentialsList,
|
16
17
|
MAX_AUTHORIZED_CREDENTIALS,
|
18
|
+
isArray,
|
17
19
|
} from './common'
|
18
20
|
import type { TransactionMetadataBase } from './metadata'
|
19
21
|
|
@@ -119,6 +121,9 @@ export interface Payment extends BaseTransaction {
|
|
119
121
|
* to this amount instead.
|
120
122
|
*/
|
121
123
|
Amount: Amount | MPTAmount
|
124
|
+
|
125
|
+
DeliverMax?: Amount | MPTAmount
|
126
|
+
|
122
127
|
/** The unique address of the account receiving the payment. */
|
123
128
|
Destination: Account
|
124
129
|
/**
|
@@ -156,6 +161,18 @@ export interface Payment extends BaseTransaction {
|
|
156
161
|
* The credentials included must not be expired.
|
157
162
|
*/
|
158
163
|
CredentialIDs?: string[]
|
164
|
+
/**
|
165
|
+
* The domain the sender intends to use. Both the sender and destination must
|
166
|
+
* be part of this domain. The DomainID can be included if the sender intends
|
167
|
+
* it to be a cross-currency payment (i.e. if the payment is going to interact
|
168
|
+
* with the DEX). The domain will only play it's role if there is a path that
|
169
|
+
* crossing an orderbook.
|
170
|
+
*
|
171
|
+
* Note: it's still possible that DomainID is included but the payment does
|
172
|
+
* not interact with DEX, it simply means that the DomainID will be ignored
|
173
|
+
* during payment paths.
|
174
|
+
*/
|
175
|
+
DomainID?: string
|
159
176
|
Flags?: number | PaymentFlagsInterface
|
160
177
|
}
|
161
178
|
|
@@ -195,11 +212,12 @@ export function validatePayment(tx: Record<string, unknown>): void {
|
|
195
212
|
throw new ValidationError('PaymentTransaction: InvoiceID must be a string')
|
196
213
|
}
|
197
214
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
215
|
+
validateOptionalField(tx, 'DomainID', isDomainID, {
|
216
|
+
txType: 'PaymentTransaction',
|
217
|
+
paramName: 'DomainID',
|
218
|
+
})
|
219
|
+
|
220
|
+
if (tx.Paths !== undefined && !isPaths(tx.Paths)) {
|
203
221
|
throw new ValidationError('PaymentTransaction: invalid Paths')
|
204
222
|
}
|
205
223
|
|
@@ -276,12 +294,12 @@ function isPath(path: unknown): path is Path {
|
|
276
294
|
}
|
277
295
|
|
278
296
|
function isPaths(paths: unknown): paths is Path[] {
|
279
|
-
if (!
|
297
|
+
if (!isArray(paths) || paths.length === 0) {
|
280
298
|
return false
|
281
299
|
}
|
282
300
|
|
283
301
|
for (const path of paths) {
|
284
|
-
if (!
|
302
|
+
if (!isArray(path) || path.length === 0) {
|
285
303
|
return false
|
286
304
|
}
|
287
305
|
|
@@ -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`,
|
@@ -2,8 +2,6 @@
|
|
2
2
|
/* eslint-disable max-lines-per-function -- need to work with a lot of Tx verifications */
|
3
3
|
|
4
4
|
import { ValidationError } from '../../errors'
|
5
|
-
import { IssuedCurrencyAmount, Memo } from '../common'
|
6
|
-
import { isHex } from '../utils'
|
7
5
|
import { convertTxFlagsToNumber } from '../utils/flags'
|
8
6
|
|
9
7
|
import { AccountDelete, validateAccountDelete } from './accountDelete'
|
@@ -20,7 +18,11 @@ import { CheckCancel, validateCheckCancel } from './checkCancel'
|
|
20
18
|
import { CheckCash, validateCheckCash } from './checkCash'
|
21
19
|
import { CheckCreate, validateCheckCreate } from './checkCreate'
|
22
20
|
import { Clawback, validateClawback } from './clawback'
|
23
|
-
import {
|
21
|
+
import {
|
22
|
+
BaseTransaction,
|
23
|
+
isIssuedCurrencyAmount,
|
24
|
+
validateBaseTransaction,
|
25
|
+
} from './common'
|
24
26
|
import { CredentialAccept, validateCredentialAccept } from './CredentialAccept'
|
25
27
|
import { CredentialCreate, validateCredentialCreate } from './CredentialCreate'
|
26
28
|
import { CredentialDelete, validateCredentialDelete } from './CredentialDelete'
|
@@ -92,6 +94,12 @@ import { SignerListSet, validateSignerListSet } from './signerListSet'
|
|
92
94
|
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
93
95
|
import { TrustSet, validateTrustSet } from './trustSet'
|
94
96
|
import { UNLModify } from './UNLModify'
|
97
|
+
import { VaultClawback, validateVaultClawback } from './vaultClawback'
|
98
|
+
import { VaultCreate, validateVaultCreate } from './vaultCreate'
|
99
|
+
import { VaultDelete, validateVaultDelete } from './vaultDelete'
|
100
|
+
import { VaultDeposit, validateVaultDeposit } from './vaultDeposit'
|
101
|
+
import { VaultSet, validateVaultSet } from './vaultSet'
|
102
|
+
import { VaultWithdraw, validateVaultWithdraw } from './vaultWithdraw'
|
95
103
|
import {
|
96
104
|
XChainAccountCreateCommit,
|
97
105
|
validateXChainAccountCreateCommit,
|
@@ -173,6 +181,12 @@ export type SubmittableTransaction =
|
|
173
181
|
| SignerListSet
|
174
182
|
| TicketCreate
|
175
183
|
| TrustSet
|
184
|
+
| VaultClawback
|
185
|
+
| VaultCreate
|
186
|
+
| VaultDelete
|
187
|
+
| VaultDeposit
|
188
|
+
| VaultSet
|
189
|
+
| VaultWithdraw
|
176
190
|
| XChainAccountCreateCommit
|
177
191
|
| XChainAddAccountCreateAttestation
|
178
192
|
| XChainAddClaimAttestation
|
@@ -216,50 +230,15 @@ export interface TransactionAndMetadata<
|
|
216
230
|
*/
|
217
231
|
export function validate(transaction: Record<string, unknown>): void {
|
218
232
|
const tx = { ...transaction }
|
219
|
-
if (tx.TransactionType == null) {
|
220
|
-
throw new ValidationError('Object does not have a `TransactionType`')
|
221
|
-
}
|
222
|
-
if (typeof tx.TransactionType !== 'string') {
|
223
|
-
throw new ValidationError("Object's `TransactionType` is not a string")
|
224
|
-
}
|
225
|
-
|
226
|
-
/*
|
227
|
-
* - Memos have exclusively hex data.
|
228
|
-
*/
|
229
|
-
if (tx.Memos != null && typeof tx.Memos !== 'object') {
|
230
|
-
throw new ValidationError('Memo must be array')
|
231
|
-
}
|
232
|
-
if (tx.Memos != null) {
|
233
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- needed here
|
234
|
-
;(tx.Memos as Array<Memo | null>).forEach((memo) => {
|
235
|
-
if (memo?.Memo == null) {
|
236
|
-
throw new ValidationError('Memo data must be in a `Memo` field')
|
237
|
-
}
|
238
|
-
if (memo.Memo.MemoData) {
|
239
|
-
if (!isHex(memo.Memo.MemoData)) {
|
240
|
-
throw new ValidationError('MemoData field must be a hex value')
|
241
|
-
}
|
242
|
-
}
|
243
|
-
|
244
|
-
if (memo.Memo.MemoType) {
|
245
|
-
if (!isHex(memo.Memo.MemoType)) {
|
246
|
-
throw new ValidationError('MemoType field must be a hex value')
|
247
|
-
}
|
248
|
-
}
|
249
233
|
|
250
|
-
|
251
|
-
|
252
|
-
throw new ValidationError('MemoFormat field must be a hex value')
|
253
|
-
}
|
254
|
-
}
|
255
|
-
})
|
256
|
-
}
|
234
|
+
// should already be done in the tx-specific validation, but doesn't hurt to check again
|
235
|
+
validateBaseTransaction(tx)
|
257
236
|
|
258
237
|
Object.keys(tx).forEach((key) => {
|
259
238
|
const standard_currency_code_len = 3
|
260
|
-
|
261
|
-
|
262
|
-
const txCurrency =
|
239
|
+
const value = tx[key]
|
240
|
+
if (value && isIssuedCurrencyAmount(value)) {
|
241
|
+
const txCurrency = value.currency
|
263
242
|
|
264
243
|
if (
|
265
244
|
txCurrency.length === standard_currency_code_len &&
|
@@ -476,6 +455,30 @@ export function validate(transaction: Record<string, unknown>): void {
|
|
476
455
|
validateTrustSet(tx)
|
477
456
|
break
|
478
457
|
|
458
|
+
case 'VaultClawback':
|
459
|
+
validateVaultClawback(tx)
|
460
|
+
break
|
461
|
+
|
462
|
+
case 'VaultCreate':
|
463
|
+
validateVaultCreate(tx)
|
464
|
+
break
|
465
|
+
|
466
|
+
case 'VaultDelete':
|
467
|
+
validateVaultDelete(tx)
|
468
|
+
break
|
469
|
+
|
470
|
+
case 'VaultDeposit':
|
471
|
+
validateVaultDeposit(tx)
|
472
|
+
break
|
473
|
+
|
474
|
+
case 'VaultSet':
|
475
|
+
validateVaultSet(tx)
|
476
|
+
break
|
477
|
+
|
478
|
+
case 'VaultWithdraw':
|
479
|
+
validateVaultWithdraw(tx)
|
480
|
+
break
|
481
|
+
|
479
482
|
case 'XChainAccountCreateCommit':
|
480
483
|
validateXChainAccountCreateCommit(tx)
|
481
484
|
break
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { ClawbackAmount } from '../common'
|
2
|
+
|
3
|
+
import {
|
4
|
+
BaseTransaction,
|
5
|
+
validateBaseTransaction,
|
6
|
+
validateRequiredField,
|
7
|
+
isString,
|
8
|
+
Account,
|
9
|
+
isAccount,
|
10
|
+
validateOptionalField,
|
11
|
+
isClawbackAmount,
|
12
|
+
} from './common'
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The VaultClawback transaction performs a Clawback from the Vault, exchanging the shares of an account.
|
16
|
+
*
|
17
|
+
* Conceptually, the transaction performs VaultWithdraw on behalf of the Holder, sending the funds to the
|
18
|
+
* Issuer account of the asset. In case there are insufficient funds for the entire Amount the transaction
|
19
|
+
* will perform a partial Clawback, up to the Vault.AssetsAvailable. The Clawback transaction must respect
|
20
|
+
* any future fees or penalties.
|
21
|
+
*
|
22
|
+
* @category Transaction Models
|
23
|
+
*/
|
24
|
+
export interface VaultClawback extends BaseTransaction {
|
25
|
+
TransactionType: 'VaultClawback'
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The ID of the vault from which assets are withdrawn.
|
29
|
+
*/
|
30
|
+
VaultID: string
|
31
|
+
|
32
|
+
/**
|
33
|
+
* The account ID from which to clawback the assets.
|
34
|
+
*/
|
35
|
+
Holder: Account
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The asset amount to clawback. When Amount is 0 clawback all funds, up to the total shares the Holder owns.
|
39
|
+
*/
|
40
|
+
Amount?: ClawbackAmount
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Verify the form and type of a {@link VaultClawback} at runtime.
|
45
|
+
*
|
46
|
+
* @param tx - A {@link VaultClawback} Transaction.
|
47
|
+
* @throws When the {@link VaultClawback} is malformed.
|
48
|
+
*/
|
49
|
+
export function validateVaultClawback(tx: Record<string, unknown>): void {
|
50
|
+
validateBaseTransaction(tx)
|
51
|
+
|
52
|
+
validateRequiredField(tx, 'VaultID', isString)
|
53
|
+
validateRequiredField(tx, 'Holder', isAccount)
|
54
|
+
validateOptionalField(tx, 'Amount', isClawbackAmount)
|
55
|
+
}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Currency } from '../common'
|
3
|
+
import { hasFlag, isHex } from '../utils'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
validateBaseTransaction,
|
8
|
+
GlobalFlagsInterface,
|
9
|
+
validateOptionalField,
|
10
|
+
isNumber,
|
11
|
+
isCurrency,
|
12
|
+
validateRequiredField,
|
13
|
+
isString,
|
14
|
+
VAULT_DATA_MAX_BYTE_LENGTH,
|
15
|
+
XRPLNumber,
|
16
|
+
isXRPLNumber,
|
17
|
+
MAX_MPT_META_BYTE_LENGTH,
|
18
|
+
MPT_META_WARNING_HEADER,
|
19
|
+
validateMPTokenMetadata,
|
20
|
+
} from './common'
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Enum representing withdrawal strategies for a Vault.
|
24
|
+
*/
|
25
|
+
export enum VaultWithdrawalPolicy {
|
26
|
+
vaultStrategyFirstComeFirstServe = 0x0001,
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Enum representing values of {@link VaultCreate} transaction flags.
|
31
|
+
*
|
32
|
+
* @category Transaction Flags
|
33
|
+
*/
|
34
|
+
export enum VaultCreateFlags {
|
35
|
+
tfVaultPrivate = 0x00010000,
|
36
|
+
tfVaultShareNonTransferable = 0x00020000,
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Map of flags to boolean values representing {@link VaultCreate} transaction
|
41
|
+
* flags.
|
42
|
+
*
|
43
|
+
* @category Transaction Flags
|
44
|
+
*/
|
45
|
+
export interface VaultCreateFlagsInterface extends GlobalFlagsInterface {
|
46
|
+
tfVaultPrivate?: boolean
|
47
|
+
tfVaultShareNonTransferable?: boolean
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* The VaultCreate transaction creates a new Vault object.
|
52
|
+
*
|
53
|
+
* @category Transaction Models
|
54
|
+
*/
|
55
|
+
export interface VaultCreate extends BaseTransaction {
|
56
|
+
TransactionType: 'VaultCreate'
|
57
|
+
|
58
|
+
/**
|
59
|
+
* The asset (XRP, IOU or MPT) of the Vault.
|
60
|
+
*/
|
61
|
+
Asset: Currency
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Arbitrary Vault metadata, limited to 256 bytes.
|
65
|
+
*/
|
66
|
+
Data?: string
|
67
|
+
|
68
|
+
/**
|
69
|
+
* The maximum asset amount that can be held in a vault.
|
70
|
+
*/
|
71
|
+
AssetsMaximum?: XRPLNumber
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Arbitrary metadata about the share MPT, in hex format, limited to 1024 bytes.
|
75
|
+
*
|
76
|
+
* The decoded value must be a UTF-8 encoded JSON object that adheres to the
|
77
|
+
* XLS-89d MPTokenMetadata standard.
|
78
|
+
*
|
79
|
+
* While adherence to the XLS-89d format is not mandatory, non-compliant metadata
|
80
|
+
* may not be discoverable by ecosystem tools such as explorers and indexers.
|
81
|
+
*/
|
82
|
+
MPTokenMetadata?: string
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Indicates the withdrawal strategy used by the Vault.
|
86
|
+
*/
|
87
|
+
WithdrawalPolicy?: number
|
88
|
+
|
89
|
+
/**
|
90
|
+
* The PermissionedDomain object ID associated with the shares of this Vault.
|
91
|
+
*/
|
92
|
+
DomainID?: string
|
93
|
+
}
|
94
|
+
|
95
|
+
/* eslint-disable max-lines-per-function -- Not needed to reduce function */
|
96
|
+
/* eslint-disable max-statements -- required to do all field validations */
|
97
|
+
/**
|
98
|
+
* Verify the form and type of an {@link VaultCreate} at runtime.
|
99
|
+
*
|
100
|
+
* @param tx - A {@link VaultCreate} Transaction.
|
101
|
+
* @throws When the {@link VaultCreate} is malformed.
|
102
|
+
*/
|
103
|
+
export function validateVaultCreate(tx: Record<string, unknown>): void {
|
104
|
+
validateBaseTransaction(tx)
|
105
|
+
|
106
|
+
validateRequiredField(tx, 'Asset', isCurrency)
|
107
|
+
validateOptionalField(tx, 'Data', isString)
|
108
|
+
validateOptionalField(tx, 'AssetsMaximum', isXRPLNumber)
|
109
|
+
validateOptionalField(tx, 'MPTokenMetadata', isString)
|
110
|
+
validateOptionalField(tx, 'WithdrawalPolicy', isNumber)
|
111
|
+
validateOptionalField(tx, 'DomainID', isString)
|
112
|
+
|
113
|
+
if (tx.Data !== undefined) {
|
114
|
+
const dataHex = tx.Data
|
115
|
+
if (!isHex(dataHex)) {
|
116
|
+
throw new ValidationError('VaultCreate: Data must be a valid hex string')
|
117
|
+
}
|
118
|
+
const dataByteLength = dataHex.length / 2
|
119
|
+
if (dataByteLength > VAULT_DATA_MAX_BYTE_LENGTH) {
|
120
|
+
throw new ValidationError(
|
121
|
+
`VaultCreate: Data exceeds ${VAULT_DATA_MAX_BYTE_LENGTH} bytes (actual: ${dataByteLength})`,
|
122
|
+
)
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
if (tx.MPTokenMetadata !== undefined) {
|
127
|
+
const metaHex = tx.MPTokenMetadata
|
128
|
+
if (!isHex(metaHex)) {
|
129
|
+
throw new ValidationError(
|
130
|
+
'VaultCreate: MPTokenMetadata must be a valid non-empty hex string',
|
131
|
+
)
|
132
|
+
}
|
133
|
+
const metaByteLength = metaHex.length / 2
|
134
|
+
if (metaByteLength > MAX_MPT_META_BYTE_LENGTH) {
|
135
|
+
throw new ValidationError(
|
136
|
+
`VaultCreate: MPTokenMetadata exceeds ${MAX_MPT_META_BYTE_LENGTH} bytes (actual: ${metaByteLength})`,
|
137
|
+
)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
// If DomainID present, tfVaultPrivate must be set
|
142
|
+
if (
|
143
|
+
tx.DomainID !== undefined &&
|
144
|
+
!hasFlag(tx, VaultCreateFlags.tfVaultPrivate, 'tfVaultPrivate')
|
145
|
+
) {
|
146
|
+
throw new ValidationError(
|
147
|
+
'VaultCreate: Cannot set DomainID unless tfVaultPrivate flag is set.',
|
148
|
+
)
|
149
|
+
}
|
150
|
+
|
151
|
+
if (tx.MPTokenMetadata != null) {
|
152
|
+
const validationMessages = validateMPTokenMetadata(tx.MPTokenMetadata)
|
153
|
+
|
154
|
+
if (validationMessages.length > 0) {
|
155
|
+
const message = [
|
156
|
+
MPT_META_WARNING_HEADER,
|
157
|
+
...validationMessages.map((msg) => `- ${msg}`),
|
158
|
+
].join('\n')
|
159
|
+
|
160
|
+
// eslint-disable-next-line no-console -- Required here.
|
161
|
+
console.warn(message)
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
/* eslint-enable max-lines-per-function */
|
166
|
+
/* eslint-enable max-statements */
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {
|
2
|
+
BaseTransaction,
|
3
|
+
validateBaseTransaction,
|
4
|
+
validateRequiredField,
|
5
|
+
isString,
|
6
|
+
} from './common'
|
7
|
+
|
8
|
+
/**
|
9
|
+
* The VaultDelete transaction deletes an existing vault object.
|
10
|
+
*
|
11
|
+
* @category Transaction Models
|
12
|
+
*/
|
13
|
+
export interface VaultDelete extends BaseTransaction {
|
14
|
+
TransactionType: 'VaultDelete'
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The ID of the vault to be deleted.
|
18
|
+
*/
|
19
|
+
VaultID: string
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Verify the form and type of a {@link VaultDelete} at runtime.
|
24
|
+
*
|
25
|
+
* @param tx - A {@link VaultDelete} Transaction.
|
26
|
+
* @throws When the {@link VaultDelete} is malformed.
|
27
|
+
*/
|
28
|
+
export function validateVaultDelete(tx: Record<string, unknown>): void {
|
29
|
+
validateBaseTransaction(tx)
|
30
|
+
|
31
|
+
validateRequiredField(tx, 'VaultID', isString)
|
32
|
+
}
|