xrpl 2.10.0 → 2.12.0-beta.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 +1308 -33
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/walletFromSecretNumbers.d.ts +7 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.js +27 -0
- package/dist/npm/Wallet/walletFromSecretNumbers.js.map +1 -0
- package/dist/npm/client/index.d.ts +2 -1
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/index.d.ts +1 -0
- package/dist/npm/index.d.ts.map +1 -1
- package/dist/npm/index.js +3 -1
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +11 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/AMM.d.ts +27 -0
- package/dist/npm/models/ledger/AMM.d.ts.map +1 -0
- package/dist/npm/models/ledger/AMM.js +3 -0
- package/dist/npm/models/ledger/AMM.js.map +1 -0
- package/dist/npm/models/ledger/AccountRoot.d.ts +2 -0
- 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/Bridge.d.ts +17 -0
- package/dist/npm/models/ledger/Bridge.d.ts.map +1 -0
- package/dist/npm/models/ledger/Bridge.js +3 -0
- package/dist/npm/models/ledger/Bridge.js.map +1 -0
- package/dist/npm/models/ledger/LedgerEntry.d.ts +5 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts +16 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.js +3 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.js.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
- package/dist/npm/models/ledger/index.d.ts +4 -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/accountObjects.d.ts +3 -3
- package/dist/npm/models/methods/accountObjects.d.ts.map +1 -1
- package/dist/npm/models/methods/ammInfo.d.ts +39 -0
- package/dist/npm/models/methods/ammInfo.d.ts.map +1 -0
- package/dist/npm/models/methods/ammInfo.js +3 -0
- package/dist/npm/models/methods/ammInfo.js.map +1 -0
- package/dist/npm/models/methods/index.d.ts +4 -3
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledgerEntry.d.ts +27 -0
- package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMBid.d.ts +12 -0
- package/dist/npm/models/transactions/AMMBid.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMBid.js +56 -0
- package/dist/npm/models/transactions/AMMBid.js.map +1 -0
- package/dist/npm/models/transactions/AMMCreate.d.ts +11 -0
- package/dist/npm/models/transactions/AMMCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMCreate.js +32 -0
- package/dist/npm/models/transactions/AMMCreate.js.map +1 -0
- package/dist/npm/models/transactions/AMMDelete.d.ts +9 -0
- package/dist/npm/models/transactions/AMMDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMDelete.js +22 -0
- package/dist/npm/models/transactions/AMMDelete.js.map +1 -0
- package/dist/npm/models/transactions/AMMDeposit.d.ts +27 -0
- package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMDeposit.js +51 -0
- package/dist/npm/models/transactions/AMMDeposit.js.map +1 -0
- package/dist/npm/models/transactions/AMMVote.d.ts +10 -0
- package/dist/npm/models/transactions/AMMVote.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMVote.js +32 -0
- package/dist/npm/models/transactions/AMMVote.js.map +1 -0
- package/dist/npm/models/transactions/AMMWithdraw.d.ts +31 -0
- package/dist/npm/models/transactions/AMMWithdraw.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMWithdraw.js +50 -0
- package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.js +35 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.js.map +1 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.js +68 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.js.map +1 -0
- package/dist/npm/models/transactions/XChainClaim.d.ts +12 -0
- package/dist/npm/models/transactions/XChainClaim.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainClaim.js +39 -0
- package/dist/npm/models/transactions/XChainClaim.js.map +1 -0
- package/dist/npm/models/transactions/XChainCommit.d.ts +11 -0
- package/dist/npm/models/transactions/XChainCommit.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCommit.js +33 -0
- package/dist/npm/models/transactions/XChainCommit.js.map +1 -0
- package/dist/npm/models/transactions/XChainCreateBridge.d.ts +10 -0
- package/dist/npm/models/transactions/XChainCreateBridge.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCreateBridge.js +26 -0
- package/dist/npm/models/transactions/XChainCreateBridge.js.map +1 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.d.ts +10 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.js +28 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.js.map +1 -0
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts +17 -0
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainModifyBridge.js +27 -0
- package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -0
- package/dist/npm/models/transactions/common.d.ts +3 -1
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +22 -1
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +15 -1
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +7 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +15 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +56 -0
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +18 -21
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/snippets/src/bridgeTransfer.d.ts +2 -0
- package/dist/npm/snippets/src/bridgeTransfer.d.ts.map +1 -0
- package/dist/npm/snippets/src/bridgeTransfer.js +124 -0
- package/dist/npm/snippets/src/bridgeTransfer.js.map +1 -0
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts +7 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.d.ts.map +1 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js +27 -0
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -0
- package/dist/npm/src/client/index.d.ts +2 -1
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/index.d.ts +1 -0
- package/dist/npm/src/index.d.ts.map +1 -1
- package/dist/npm/src/index.js +3 -1
- package/dist/npm/src/index.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +11 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/AMM.d.ts +27 -0
- package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/AMM.js +3 -0
- package/dist/npm/src/models/ledger/AMM.js.map +1 -0
- package/dist/npm/src/models/ledger/AccountRoot.d.ts +2 -0
- 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/Bridge.d.ts +17 -0
- package/dist/npm/src/models/ledger/Bridge.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/Bridge.js +3 -0
- package/dist/npm/src/models/ledger/Bridge.js.map +1 -0
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts +5 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts +16 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.js +3 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.js.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
- package/dist/npm/src/models/ledger/index.d.ts +4 -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/accountObjects.d.ts +3 -3
- package/dist/npm/src/models/methods/accountObjects.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ammInfo.d.ts +39 -0
- package/dist/npm/src/models/methods/ammInfo.d.ts.map +1 -0
- package/dist/npm/src/models/methods/ammInfo.js +3 -0
- package/dist/npm/src/models/methods/ammInfo.js.map +1 -0
- package/dist/npm/src/models/methods/index.d.ts +4 -3
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledgerEntry.d.ts +27 -0
- package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMBid.d.ts +12 -0
- package/dist/npm/src/models/transactions/AMMBid.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMBid.js +56 -0
- package/dist/npm/src/models/transactions/AMMBid.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMCreate.d.ts +11 -0
- package/dist/npm/src/models/transactions/AMMCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMCreate.js +32 -0
- package/dist/npm/src/models/transactions/AMMCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMDelete.d.ts +9 -0
- package/dist/npm/src/models/transactions/AMMDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMDelete.js +22 -0
- package/dist/npm/src/models/transactions/AMMDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts +27 -0
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMDeposit.js +51 -0
- package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMVote.d.ts +10 -0
- package/dist/npm/src/models/transactions/AMMVote.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMVote.js +32 -0
- package/dist/npm/src/models/transactions/AMMVote.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts +31 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.js +50 -0
- package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js +35 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js +68 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainClaim.d.ts +12 -0
- package/dist/npm/src/models/transactions/XChainClaim.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainClaim.js +39 -0
- package/dist/npm/src/models/transactions/XChainClaim.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCommit.d.ts +11 -0
- package/dist/npm/src/models/transactions/XChainCommit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCommit.js +33 -0
- package/dist/npm/src/models/transactions/XChainCommit.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts +10 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.js +26 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts +10 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.js +28 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts +17 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.js +27 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -0
- package/dist/npm/src/models/transactions/common.d.ts +3 -1
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +22 -1
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +15 -1
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +7 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +15 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +56 -0
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +18 -21
- 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 +4 -3
- 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 +4 -3
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/package.json +8 -6
- package/src/ECDSA.ts +6 -0
- package/src/Wallet/defaultFaucets.ts +82 -0
- package/src/Wallet/fundWallet.ts +344 -0
- package/src/Wallet/index.ts +504 -0
- package/src/Wallet/rfc1751.ts +190 -0
- package/src/Wallet/rfc1751Words.json +243 -0
- package/src/Wallet/signer.ts +173 -0
- package/src/Wallet/walletFromSecretNumbers.ts +37 -0
- package/src/client/BroadcastClient.ts +84 -0
- package/src/client/ConnectionManager.ts +40 -0
- package/src/client/ExponentialBackoff.ts +71 -0
- package/src/client/RequestManager.ts +194 -0
- package/src/client/WSWrapper.ts +106 -0
- package/src/client/connection.ts +593 -0
- package/src/client/index.ts +712 -0
- package/src/client/partialPayment.ts +153 -0
- package/src/errors.ts +161 -0
- package/src/index.ts +20 -0
- package/src/models/common/index.ts +156 -0
- package/src/models/index.ts +16 -0
- package/src/models/ledger/AMM.ts +78 -0
- package/src/models/ledger/AccountRoot.ts +217 -0
- package/src/models/ledger/Amendments.ts +45 -0
- package/src/models/ledger/BaseLedgerEntry.ts +3 -0
- package/src/models/ledger/Bridge.ts +84 -0
- package/src/models/ledger/Check.ts +70 -0
- package/src/models/ledger/DepositPreauth.ts +35 -0
- package/src/models/ledger/DirectoryNode.ts +46 -0
- package/src/models/ledger/Escrow.ts +74 -0
- package/src/models/ledger/FeeSettings.ts +52 -0
- package/src/models/ledger/Ledger.ts +65 -0
- package/src/models/ledger/LedgerEntry.ts +40 -0
- package/src/models/ledger/LedgerHashes.ts +24 -0
- package/src/models/ledger/NFTokenOffer.ts +16 -0
- package/src/models/ledger/NFTokenPage.ts +20 -0
- package/src/models/ledger/NegativeUNL.ts +34 -0
- package/src/models/ledger/Offer.ts +52 -0
- package/src/models/ledger/PayChannel.ts +107 -0
- package/src/models/ledger/RippleState.ts +88 -0
- package/src/models/ledger/SignerList.ts +56 -0
- package/src/models/ledger/Ticket.ts +36 -0
- package/src/models/ledger/XChainOwnedClaimID.ts +73 -0
- package/src/models/ledger/XChainOwnedCreateAccountClaimID.ts +60 -0
- package/src/models/ledger/index.ts +64 -0
- package/src/models/methods/accountChannels.ts +93 -0
- package/src/models/methods/accountCurrencies.ts +45 -0
- package/src/models/methods/accountInfo.ts +182 -0
- package/src/models/methods/accountLines.ts +137 -0
- package/src/models/methods/accountNFTs.ts +72 -0
- package/src/models/methods/accountObjects.ts +129 -0
- package/src/models/methods/accountOffers.ts +100 -0
- package/src/models/methods/accountTx.ts +109 -0
- package/src/models/methods/ammInfo.ts +145 -0
- package/src/models/methods/baseMethod.ts +58 -0
- package/src/models/methods/bookOffers.ts +96 -0
- package/src/models/methods/channelVerify.ts +41 -0
- package/src/models/methods/depositAuthorized.ts +56 -0
- package/src/models/methods/fee.ts +91 -0
- package/src/models/methods/gatewayBalances.ts +85 -0
- package/src/models/methods/index.ts +391 -0
- package/src/models/methods/ledger.ts +125 -0
- package/src/models/methods/ledgerClosed.ts +32 -0
- package/src/models/methods/ledgerCurrent.ts +31 -0
- package/src/models/methods/ledgerData.ts +78 -0
- package/src/models/methods/ledgerEntry.ts +202 -0
- package/src/models/methods/manifest.ts +54 -0
- package/src/models/methods/nftBuyOffers.ts +37 -0
- package/src/models/methods/nftHistory.ts +113 -0
- package/src/models/methods/nftInfo.ts +25 -0
- package/src/models/methods/nftSellOffers.ts +37 -0
- package/src/models/methods/norippleCheck.ts +82 -0
- package/src/models/methods/pathFind.ts +116 -0
- package/src/models/methods/ping.ts +21 -0
- package/src/models/methods/random.ts +23 -0
- package/src/models/methods/ripplePathFind.ts +81 -0
- package/src/models/methods/serverInfo.ts +257 -0
- package/src/models/methods/serverState.ts +77 -0
- package/src/models/methods/submit.ts +94 -0
- package/src/models/methods/submitMultisigned.ts +51 -0
- package/src/models/methods/subscribe.ts +435 -0
- package/src/models/methods/transactionEntry.ts +47 -0
- package/src/models/methods/tx.ts +69 -0
- package/src/models/methods/unsubscribe.ts +49 -0
- package/src/models/transactions/AMMBid.ts +140 -0
- package/src/models/transactions/AMMCreate.ts +80 -0
- package/src/models/transactions/AMMDelete.ts +55 -0
- package/src/models/transactions/AMMDeposit.ts +130 -0
- package/src/models/transactions/AMMVote.ts +71 -0
- package/src/models/transactions/AMMWithdraw.ts +126 -0
- package/src/models/transactions/NFTokenAcceptOffer.ts +104 -0
- package/src/models/transactions/NFTokenBurn.ts +48 -0
- package/src/models/transactions/NFTokenCancelOffer.ts +45 -0
- package/src/models/transactions/NFTokenCreateOffer.ts +145 -0
- package/src/models/transactions/NFTokenMint.ts +123 -0
- package/src/models/transactions/UNLModify.ts +20 -0
- package/src/models/transactions/XChainAccountCreateCommit.ts +107 -0
- package/src/models/transactions/XChainAddAccountCreateAttestation.ts +225 -0
- package/src/models/transactions/XChainAddClaimAttestation.ts +198 -0
- package/src/models/transactions/XChainClaim.ts +103 -0
- package/src/models/transactions/XChainCommit.ts +95 -0
- package/src/models/transactions/XChainCreateBridge.ts +78 -0
- package/src/models/transactions/XChainCreateClaimID.ts +78 -0
- package/src/models/transactions/XChainModifyBridge.ts +93 -0
- package/src/models/transactions/accountDelete.ts +50 -0
- package/src/models/transactions/accountSet.ts +228 -0
- package/src/models/transactions/checkCancel.ts +34 -0
- package/src/models/transactions/checkCash.ts +73 -0
- package/src/models/transactions/checkCreate.ts +90 -0
- package/src/models/transactions/clawback.ts +49 -0
- package/src/models/transactions/common.ts +320 -0
- package/src/models/transactions/depositPreauth.ts +68 -0
- package/src/models/transactions/enableAmendment.ts +26 -0
- package/src/models/transactions/escrowCancel.ts +45 -0
- package/src/models/transactions/escrowCreate.ts +100 -0
- package/src/models/transactions/escrowFinish.ts +63 -0
- package/src/models/transactions/index.ts +78 -0
- package/src/models/transactions/metadata.ts +69 -0
- package/src/models/transactions/offerCancel.ts +37 -0
- package/src/models/transactions/offerCreate.ts +144 -0
- package/src/models/transactions/payment.ts +278 -0
- package/src/models/transactions/paymentChannelClaim.ts +165 -0
- package/src/models/transactions/paymentChannelCreate.ts +116 -0
- package/src/models/transactions/paymentChannelFund.ts +65 -0
- package/src/models/transactions/setFee.ts +48 -0
- package/src/models/transactions/setRegularKey.ts +33 -0
- package/src/models/transactions/signerListSet.ts +89 -0
- package/src/models/transactions/ticketCreate.ts +50 -0
- package/src/models/transactions/transaction.ts +370 -0
- package/src/models/transactions/trustSet.ts +146 -0
- package/src/models/utils/flags.ts +103 -0
- package/src/models/utils/index.ts +37 -0
- package/src/sugar/autofill.ts +373 -0
- package/src/sugar/balances.ts +123 -0
- package/src/sugar/getFeeXrp.ts +45 -0
- package/src/sugar/getLedgerIndex.ts +15 -0
- package/src/sugar/getOrderbook.ts +152 -0
- package/src/sugar/index.ts +11 -0
- package/src/sugar/submit.ts +305 -0
- package/src/sugar/utils.ts +29 -0
- package/src/utils/derive.ts +23 -0
- package/src/utils/getBalanceChanges.ts +186 -0
- package/src/utils/getNFTokenID.ts +97 -0
- package/src/utils/hashes/HashPrefix.ts +40 -0
- package/src/utils/hashes/README.md +65 -0
- package/src/utils/hashes/SHAMap/InnerNode.ts +124 -0
- package/src/utils/hashes/SHAMap/LeafNode.ts +69 -0
- package/src/utils/hashes/SHAMap/index.ts +41 -0
- package/src/utils/hashes/SHAMap/node.ts +14 -0
- package/src/utils/hashes/hashLedger.ts +236 -0
- package/src/utils/hashes/index.ts +187 -0
- package/src/utils/hashes/ledgerSpaces.ts +34 -0
- package/src/utils/hashes/sha512Half.ts +19 -0
- package/src/utils/index.ts +223 -0
- package/src/utils/parseNFTokenID.ts +84 -0
- package/src/utils/quality.ts +169 -0
- package/src/utils/signPaymentChannelClaim.ts +27 -0
- package/src/utils/stringConversion.ts +27 -0
- package/src/utils/timeConversion.ts +53 -0
- package/src/utils/verifyPaymentChannelClaim.ts +30 -0
- package/src/utils/xrpConversion.ts +104 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
export { BaseTransaction } from './common'
|
2
|
+
export { validate, TransactionAndMetadata, Transaction } from './transaction'
|
3
|
+
export * from './metadata'
|
4
|
+
export {
|
5
|
+
AccountSetAsfFlags,
|
6
|
+
AccountSetTfFlags,
|
7
|
+
AccountSetFlagsInterface,
|
8
|
+
AccountSet,
|
9
|
+
} from './accountSet'
|
10
|
+
export { AccountDelete } from './accountDelete'
|
11
|
+
export { AMMBid } from './AMMBid'
|
12
|
+
export { AMMDelete } from './AMMDelete'
|
13
|
+
export {
|
14
|
+
AMMDepositFlags,
|
15
|
+
AMMDepositFlagsInterface,
|
16
|
+
AMMDeposit,
|
17
|
+
} from './AMMDeposit'
|
18
|
+
export { AMMCreate } from './AMMCreate'
|
19
|
+
export { AMMVote } from './AMMVote'
|
20
|
+
export {
|
21
|
+
AMMWithdrawFlags,
|
22
|
+
AMMWithdrawFlagsInterface,
|
23
|
+
AMMWithdraw,
|
24
|
+
} from './AMMWithdraw'
|
25
|
+
export { CheckCancel } from './checkCancel'
|
26
|
+
export { CheckCash } from './checkCash'
|
27
|
+
export { CheckCreate } from './checkCreate'
|
28
|
+
export { Clawback } from './clawback'
|
29
|
+
export { DepositPreauth } from './depositPreauth'
|
30
|
+
export { EscrowCancel } from './escrowCancel'
|
31
|
+
export { EscrowCreate } from './escrowCreate'
|
32
|
+
export { EscrowFinish } from './escrowFinish'
|
33
|
+
export { EnableAmendment, EnableAmendmentFlags } from './enableAmendment'
|
34
|
+
export { NFTokenAcceptOffer } from './NFTokenAcceptOffer'
|
35
|
+
export { NFTokenBurn } from './NFTokenBurn'
|
36
|
+
export { NFTokenCancelOffer } from './NFTokenCancelOffer'
|
37
|
+
export {
|
38
|
+
NFTokenCreateOffer,
|
39
|
+
NFTokenCreateOfferFlags,
|
40
|
+
NFTokenCreateOfferFlagsInterface,
|
41
|
+
} from './NFTokenCreateOffer'
|
42
|
+
export {
|
43
|
+
NFTokenMint,
|
44
|
+
NFTokenMintFlags,
|
45
|
+
NFTokenMintFlagsInterface,
|
46
|
+
} from './NFTokenMint'
|
47
|
+
export { OfferCancel } from './offerCancel'
|
48
|
+
export {
|
49
|
+
OfferCreateFlags,
|
50
|
+
OfferCreateFlagsInterface,
|
51
|
+
OfferCreate,
|
52
|
+
} from './offerCreate'
|
53
|
+
export { PaymentFlags, PaymentFlagsInterface, Payment } from './payment'
|
54
|
+
export {
|
55
|
+
PaymentChannelClaimFlags,
|
56
|
+
PaymentChannelClaimFlagsInterface,
|
57
|
+
PaymentChannelClaim,
|
58
|
+
} from './paymentChannelClaim'
|
59
|
+
export { PaymentChannelCreate } from './paymentChannelCreate'
|
60
|
+
export { PaymentChannelFund } from './paymentChannelFund'
|
61
|
+
export { SetFee, SetFeePreAmendment, SetFeePostAmendment } from './setFee'
|
62
|
+
export { SetRegularKey } from './setRegularKey'
|
63
|
+
export { SignerListSet } from './signerListSet'
|
64
|
+
export { TicketCreate } from './ticketCreate'
|
65
|
+
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
66
|
+
export { UNLModify } from './UNLModify'
|
67
|
+
export { XChainAddAccountCreateAttestation } from './XChainAddAccountCreateAttestation'
|
68
|
+
export { XChainAddClaimAttestation } from './XChainAddClaimAttestation'
|
69
|
+
export { XChainClaim } from './XChainClaim'
|
70
|
+
export { XChainCommit } from './XChainCommit'
|
71
|
+
export { XChainCreateBridge } from './XChainCreateBridge'
|
72
|
+
export { XChainCreateClaimID } from './XChainCreateClaimID'
|
73
|
+
export { XChainAccountCreateCommit } from './XChainAccountCreateCommit'
|
74
|
+
export {
|
75
|
+
XChainModifyBridge,
|
76
|
+
XChainModifyBridgeFlags,
|
77
|
+
XChainModifyBridgeFlagsInterface,
|
78
|
+
} from './XChainModifyBridge'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { Amount } from '../common'
|
2
|
+
|
3
|
+
export interface CreatedNode {
|
4
|
+
CreatedNode: {
|
5
|
+
LedgerEntryType: string
|
6
|
+
LedgerIndex: string
|
7
|
+
NewFields: { [field: string]: unknown }
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface ModifiedNode {
|
12
|
+
ModifiedNode: {
|
13
|
+
LedgerEntryType: string
|
14
|
+
LedgerIndex: string
|
15
|
+
FinalFields?: { [field: string]: unknown }
|
16
|
+
PreviousFields?: { [field: string]: unknown }
|
17
|
+
PreviousTxnID?: string
|
18
|
+
PreviousTxnLgrSeq?: number
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
export interface DeletedNode {
|
23
|
+
DeletedNode: {
|
24
|
+
LedgerEntryType: string
|
25
|
+
LedgerIndex: string
|
26
|
+
FinalFields: { [field: string]: unknown }
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
export type Node = CreatedNode | ModifiedNode | DeletedNode
|
31
|
+
|
32
|
+
/**
|
33
|
+
* A typeguard to check if a node is a CreatedNode.
|
34
|
+
*
|
35
|
+
* @param node - A node from metadata.
|
36
|
+
* @returns whether the given node is a CreatedNode.
|
37
|
+
*/
|
38
|
+
export function isCreatedNode(node: Node): node is CreatedNode {
|
39
|
+
return Object.prototype.hasOwnProperty.call(node, `CreatedNode`)
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* A typeguard to check if a node is a ModifiedNode.
|
44
|
+
*
|
45
|
+
* @param node - A node from metadata.
|
46
|
+
* @returns whether the given node is a ModifiedNode.
|
47
|
+
*/
|
48
|
+
export function isModifiedNode(node: Node): node is ModifiedNode {
|
49
|
+
return Object.prototype.hasOwnProperty.call(node, `ModifiedNode`)
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* A typeguard to check if a node is a DeletedNode.
|
54
|
+
*
|
55
|
+
* @param node - A node from metadata.
|
56
|
+
* @returns whether the given node is a DeletedNode.
|
57
|
+
*/
|
58
|
+
export function isDeletedNode(node: Node): node is DeletedNode {
|
59
|
+
return Object.prototype.hasOwnProperty.call(node, `DeletedNode`)
|
60
|
+
}
|
61
|
+
|
62
|
+
export interface TransactionMetadata {
|
63
|
+
AffectedNodes: Node[]
|
64
|
+
DeliveredAmount?: Amount
|
65
|
+
// "unavailable" possible for transactions before 2014-01-20
|
66
|
+
delivered_amount?: Amount | 'unavailable'
|
67
|
+
TransactionIndex: number
|
68
|
+
TransactionResult: string
|
69
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
|
3
|
+
import { BaseTransaction, validateBaseTransaction } from './common'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* An OfferCancel transaction removes an Offer object from the XRP Ledger.
|
7
|
+
*
|
8
|
+
* @category Transaction Models
|
9
|
+
*/
|
10
|
+
export interface OfferCancel extends BaseTransaction {
|
11
|
+
TransactionType: 'OfferCancel'
|
12
|
+
/**
|
13
|
+
* The sequence number (or Ticket number) of a previous OfferCreate
|
14
|
+
* transaction. If specified, cancel any offer object in the ledger that was
|
15
|
+
* created by that transaction. It is not considered an error if the offer.
|
16
|
+
* specified does not exist.
|
17
|
+
*/
|
18
|
+
OfferSequence: number
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Verify the form and type of an OfferCancel at runtime.
|
23
|
+
*
|
24
|
+
* @param tx - An OfferCancel Transaction.
|
25
|
+
* @throws When the OfferCancel is Malformed.
|
26
|
+
*/
|
27
|
+
export function validateOfferCancel(tx: Record<string, unknown>): void {
|
28
|
+
validateBaseTransaction(tx)
|
29
|
+
|
30
|
+
if (tx.OfferSequence === undefined) {
|
31
|
+
throw new ValidationError('OfferCancel: missing field OfferSequence')
|
32
|
+
}
|
33
|
+
|
34
|
+
if (typeof tx.OfferSequence !== 'number') {
|
35
|
+
throw new ValidationError('OfferCancel: OfferSequence must be a number')
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
/* eslint-disable complexity -- Necessary for validateOfferCreate */
|
2
|
+
import { ValidationError } from '../../errors'
|
3
|
+
import { Amount } from '../common'
|
4
|
+
|
5
|
+
import {
|
6
|
+
BaseTransaction,
|
7
|
+
GlobalFlags,
|
8
|
+
validateBaseTransaction,
|
9
|
+
isAmount,
|
10
|
+
} from './common'
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Transaction Flags for an OfferCreate Transaction.
|
14
|
+
*
|
15
|
+
* @category Transaction Flags
|
16
|
+
*/
|
17
|
+
export enum OfferCreateFlags {
|
18
|
+
/**
|
19
|
+
* If enabled, the offer does not consume offers that exactly match it, and
|
20
|
+
* instead becomes an Offer object in the ledger. It still consumes offers
|
21
|
+
* that cross it.
|
22
|
+
*/
|
23
|
+
tfPassive = 0x00010000,
|
24
|
+
/**
|
25
|
+
* Treat the offer as an Immediate or Cancel order. If enabled, the offer
|
26
|
+
* never becomes a ledger object: it only tries to match existing offers in
|
27
|
+
* the ledger. If the offer cannot match any offers immediately, it executes
|
28
|
+
* "successfully" without trading any currency. In this case, the transaction
|
29
|
+
* has the result code tesSUCCESS, but creates no Offer objects in the ledger.
|
30
|
+
*/
|
31
|
+
tfImmediateOrCancel = 0x00020000,
|
32
|
+
/**
|
33
|
+
* Treat the offer as a Fill or Kill order . Only try to match existing
|
34
|
+
* offers in the ledger, and only do so if the entire TakerPays quantity can
|
35
|
+
* be obtained. If the fix1578 amendment is enabled and the offer cannot be
|
36
|
+
* executed when placed, the transaction has the result code tecKILLED;
|
37
|
+
* otherwise, the transaction uses the result code tesSUCCESS even when it was
|
38
|
+
* killed without trading any currency.
|
39
|
+
*/
|
40
|
+
tfFillOrKill = 0x00040000,
|
41
|
+
/**
|
42
|
+
* Exchange the entire TakerGets amount, even if it means obtaining more than
|
43
|
+
* the TakerPays amount in exchange.
|
44
|
+
*/
|
45
|
+
tfSell = 0x00080000,
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Map of flags to boolean values representing {@link OfferCreate} transaction
|
50
|
+
* flags.
|
51
|
+
*
|
52
|
+
* @category Transaction Flags
|
53
|
+
*
|
54
|
+
* @example
|
55
|
+
* ```typescript
|
56
|
+
* const tx: OfferCreate = {
|
57
|
+
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
58
|
+
* TakerGets: '43000.51',
|
59
|
+
* TakerPays: '12928290425',
|
60
|
+
* TransactionType: 'OfferCreate',
|
61
|
+
* Flags: {
|
62
|
+
* tfPassive: true,
|
63
|
+
* tfFillOrKill: true,
|
64
|
+
* },
|
65
|
+
* }
|
66
|
+
*
|
67
|
+
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
68
|
+
* const autofilledTx = await client.autofill(tx)
|
69
|
+
* console.log(autofilledTx)
|
70
|
+
* // {
|
71
|
+
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
72
|
+
* // TakerGets: '43000.51',
|
73
|
+
* // TakerPays: '12928290425',
|
74
|
+
* // TransactionType: 'OfferCreate',
|
75
|
+
* // Flags: 327680,
|
76
|
+
* // Sequence: 21970384,
|
77
|
+
* // Fee: '12',
|
78
|
+
* // LastLedgerSequence: 21970404
|
79
|
+
* // }
|
80
|
+
* ```
|
81
|
+
*/
|
82
|
+
export interface OfferCreateFlagsInterface extends GlobalFlags {
|
83
|
+
tfPassive?: boolean
|
84
|
+
tfImmediateOrCancel?: boolean
|
85
|
+
tfFillOrKill?: boolean
|
86
|
+
tfSell?: boolean
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* An OfferCreate transaction is effectively a limit order . It defines an
|
91
|
+
* intent to exchange currencies, and creates an Offer object if not completely.
|
92
|
+
* Fulfilled when placed. Offers can be partially fulfilled.
|
93
|
+
*
|
94
|
+
* @category Transaction Models
|
95
|
+
*/
|
96
|
+
export interface OfferCreate extends BaseTransaction {
|
97
|
+
TransactionType: 'OfferCreate'
|
98
|
+
Flags?: number | OfferCreateFlagsInterface
|
99
|
+
/**
|
100
|
+
* Time after which the offer is no longer active, in seconds since the.
|
101
|
+
* Ripple Epoch.
|
102
|
+
*/
|
103
|
+
Expiration?: number
|
104
|
+
/** An offer to delete first, specified in the same way as OfferCancel. */
|
105
|
+
OfferSequence?: number
|
106
|
+
/** The amount and type of currency being provided by the offer creator. */
|
107
|
+
TakerGets: Amount
|
108
|
+
/** The amount and type of currency being requested by the offer creator. */
|
109
|
+
TakerPays: Amount
|
110
|
+
}
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Verify the form and type of an OfferCreate at runtime.
|
114
|
+
*
|
115
|
+
* @param tx - An OfferCreate Transaction.
|
116
|
+
* @throws When the OfferCreate is Malformed.
|
117
|
+
*/
|
118
|
+
export function validateOfferCreate(tx: Record<string, unknown>): void {
|
119
|
+
validateBaseTransaction(tx)
|
120
|
+
|
121
|
+
if (tx.TakerGets === undefined) {
|
122
|
+
throw new ValidationError('OfferCreate: missing field TakerGets')
|
123
|
+
}
|
124
|
+
|
125
|
+
if (tx.TakerPays === undefined) {
|
126
|
+
throw new ValidationError('OfferCreate: missing field TakerPays')
|
127
|
+
}
|
128
|
+
|
129
|
+
if (typeof tx.TakerGets !== 'string' && !isAmount(tx.TakerGets)) {
|
130
|
+
throw new ValidationError('OfferCreate: invalid TakerGets')
|
131
|
+
}
|
132
|
+
|
133
|
+
if (typeof tx.TakerPays !== 'string' && !isAmount(tx.TakerPays)) {
|
134
|
+
throw new ValidationError('OfferCreate: invalid TakerPays')
|
135
|
+
}
|
136
|
+
|
137
|
+
if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
|
138
|
+
throw new ValidationError('OfferCreate: invalid Expiration')
|
139
|
+
}
|
140
|
+
|
141
|
+
if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
|
142
|
+
throw new ValidationError('OfferCreate: invalid OfferSequence')
|
143
|
+
}
|
144
|
+
}
|
@@ -0,0 +1,278 @@
|
|
1
|
+
/* eslint-disable complexity -- Necessary for validatePayment */
|
2
|
+
import { ValidationError } from '../../errors'
|
3
|
+
import { Amount, Path } from '../common'
|
4
|
+
import { isFlagEnabled } from '../utils'
|
5
|
+
|
6
|
+
import {
|
7
|
+
BaseTransaction,
|
8
|
+
isAmount,
|
9
|
+
GlobalFlags,
|
10
|
+
validateBaseTransaction,
|
11
|
+
} from './common'
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Enum representing values for Payment Transaction Flags.
|
15
|
+
*
|
16
|
+
* @category Transaction Flags
|
17
|
+
*/
|
18
|
+
export enum PaymentFlags {
|
19
|
+
/**
|
20
|
+
* Do not use the default path; only use paths included in the Paths field.
|
21
|
+
* This is intended to force the transaction to take arbitrage opportunities.
|
22
|
+
* Most clients do not need this.
|
23
|
+
*/
|
24
|
+
tfNoDirectRipple = 0x00010000,
|
25
|
+
/**
|
26
|
+
* If the specified Amount cannot be sent without spending more than SendMax,
|
27
|
+
* reduce the received amount instead of failing outright. See Partial.
|
28
|
+
* Payments for more details.
|
29
|
+
*/
|
30
|
+
tfPartialPayment = 0x00020000,
|
31
|
+
/**
|
32
|
+
* Only take paths where all the conversions have an input:output ratio that
|
33
|
+
* is equal or better than the ratio of Amount:SendMax. See Limit Quality for
|
34
|
+
* details.
|
35
|
+
*/
|
36
|
+
tfLimitQuality = 0x00040000,
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Map of flags to boolean values representing {@link Payment} transaction
|
41
|
+
* flags.
|
42
|
+
*
|
43
|
+
* @category Transaction Flags
|
44
|
+
*
|
45
|
+
* @example
|
46
|
+
* ```typescript
|
47
|
+
* const partialPayment: Payment = {
|
48
|
+
* TransactionType: 'Payment',
|
49
|
+
* Account: 'rM9WCfJU6udpFkvKThRaFHDMsp7L8rpgN',
|
50
|
+
* Amount: {
|
51
|
+
* currency: 'FOO',
|
52
|
+
* value: '4000',
|
53
|
+
* issuer: 'rPzwM2JfCSDjhbesdTCqFjWWdK7eFtTwZz',
|
54
|
+
* },
|
55
|
+
* Destination: 'rPzwM2JfCSDjhbesdTCqFjWWdK7eFtTwZz',
|
56
|
+
* Flags: {
|
57
|
+
* tfPartialPayment: true
|
58
|
+
* }
|
59
|
+
* }
|
60
|
+
*
|
61
|
+
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
62
|
+
* const autofilledTx = await client.autofill(partialPayment)
|
63
|
+
* console.log(autofilledTx)
|
64
|
+
* // {
|
65
|
+
* // TransactionType: 'Payment',
|
66
|
+
* // Account: 'rM9WCfJU6udpFkvKThRaFHDMsp7L8rpgN',
|
67
|
+
* // Amount: {
|
68
|
+
* // currency: 'FOO',
|
69
|
+
* // value: '4000',
|
70
|
+
* // issuer: 'rPzwM2JfCSDjhbesdTCqFjWWdK7eFtTwZz'
|
71
|
+
* // },
|
72
|
+
* // Destination: 'rPzwM2JfCSDjhbesdTCqFjWWdK7eFtTwZz',
|
73
|
+
* // Flags: 131072,
|
74
|
+
* // Sequence: 21970996,
|
75
|
+
* // Fee: '12',
|
76
|
+
* // LastLedgerSequence: 21971016
|
77
|
+
* // }
|
78
|
+
* ```
|
79
|
+
*/
|
80
|
+
export interface PaymentFlagsInterface extends GlobalFlags {
|
81
|
+
/**
|
82
|
+
* Do not use the default path; only use paths included in the Paths field.
|
83
|
+
* This is intended to force the transaction to take arbitrage opportunities.
|
84
|
+
* Most clients do not need this.
|
85
|
+
*/
|
86
|
+
tfNoDirectRipple?: boolean
|
87
|
+
/**
|
88
|
+
* If the specified Amount cannot be sent without spending more than SendMax,
|
89
|
+
* reduce the received amount instead of failing outright. See Partial.
|
90
|
+
* Payments for more details.
|
91
|
+
*/
|
92
|
+
tfPartialPayment?: boolean
|
93
|
+
/**
|
94
|
+
* Only take paths where all the conversions have an input:output ratio that
|
95
|
+
* is equal or better than the ratio of Amount:SendMax. See Limit Quality for
|
96
|
+
* details.
|
97
|
+
*/
|
98
|
+
tfLimitQuality?: boolean
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* A Payment transaction represents a transfer of value from one account to
|
103
|
+
* another.
|
104
|
+
*
|
105
|
+
* @category Transaction Models
|
106
|
+
*/
|
107
|
+
export interface Payment extends BaseTransaction {
|
108
|
+
TransactionType: 'Payment'
|
109
|
+
/**
|
110
|
+
* The amount of currency to deliver. For non-XRP amounts, the nested field
|
111
|
+
* names MUST be lower-case. If the tfPartialPayment flag is set, deliver up
|
112
|
+
* to this amount instead.
|
113
|
+
*/
|
114
|
+
Amount: Amount
|
115
|
+
/** The unique address of the account receiving the payment. */
|
116
|
+
Destination: string
|
117
|
+
/**
|
118
|
+
* Arbitrary tag that identifies the reason for the payment to the
|
119
|
+
* destination, or a hosted recipient to pay.
|
120
|
+
*/
|
121
|
+
DestinationTag?: number
|
122
|
+
/**
|
123
|
+
* Arbitrary 256-bit hash representing a specific reason or identifier for
|
124
|
+
* this payment.
|
125
|
+
*/
|
126
|
+
InvoiceID?: string
|
127
|
+
/**
|
128
|
+
* Array of payment paths to be used for this transaction. Must be omitted
|
129
|
+
* for XRP-to-XRP transactions.
|
130
|
+
*/
|
131
|
+
Paths?: Path[]
|
132
|
+
/**
|
133
|
+
* Highest amount of source currency this transaction is allowed to cost,
|
134
|
+
* including transfer fees, exchange rates, and slippage . Does not include
|
135
|
+
* the XRP destroyed as a cost for submitting the transaction. For non-XRP
|
136
|
+
* amounts, the nested field names MUST be lower-case. Must be supplied for
|
137
|
+
* cross-currency/cross-issue payments. Must be omitted for XRP-to-XRP
|
138
|
+
* Payments.
|
139
|
+
*/
|
140
|
+
SendMax?: Amount
|
141
|
+
/**
|
142
|
+
* Minimum amount of destination currency this transaction should deliver.
|
143
|
+
* Only valid if this is a partial payment. For non-XRP amounts, the nested
|
144
|
+
* field names are lower-case.
|
145
|
+
*/
|
146
|
+
DeliverMin?: Amount
|
147
|
+
Flags?: number | PaymentFlagsInterface
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Verify the form and type of a Payment at runtime.
|
152
|
+
*
|
153
|
+
* @param tx - A Payment Transaction.
|
154
|
+
* @throws When the Payment is malformed.
|
155
|
+
*/
|
156
|
+
export function validatePayment(tx: Record<string, unknown>): void {
|
157
|
+
validateBaseTransaction(tx)
|
158
|
+
|
159
|
+
if (tx.Amount === undefined) {
|
160
|
+
throw new ValidationError('PaymentTransaction: missing field Amount')
|
161
|
+
}
|
162
|
+
|
163
|
+
if (!isAmount(tx.Amount)) {
|
164
|
+
throw new ValidationError('PaymentTransaction: invalid Amount')
|
165
|
+
}
|
166
|
+
|
167
|
+
if (tx.Destination === undefined) {
|
168
|
+
throw new ValidationError('PaymentTransaction: missing field Destination')
|
169
|
+
}
|
170
|
+
|
171
|
+
if (!isAmount(tx.Destination)) {
|
172
|
+
throw new ValidationError('PaymentTransaction: invalid Destination')
|
173
|
+
}
|
174
|
+
|
175
|
+
if (tx.DestinationTag != null && typeof tx.DestinationTag !== 'number') {
|
176
|
+
throw new ValidationError(
|
177
|
+
'PaymentTransaction: DestinationTag must be a number',
|
178
|
+
)
|
179
|
+
}
|
180
|
+
|
181
|
+
if (tx.InvoiceID !== undefined && typeof tx.InvoiceID !== 'string') {
|
182
|
+
throw new ValidationError('PaymentTransaction: InvoiceID must be a string')
|
183
|
+
}
|
184
|
+
|
185
|
+
if (
|
186
|
+
tx.Paths !== undefined &&
|
187
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
188
|
+
!isPaths(tx.Paths as Array<Array<Record<string, unknown>>>)
|
189
|
+
) {
|
190
|
+
throw new ValidationError('PaymentTransaction: invalid Paths')
|
191
|
+
}
|
192
|
+
|
193
|
+
if (tx.SendMax !== undefined && !isAmount(tx.SendMax)) {
|
194
|
+
throw new ValidationError('PaymentTransaction: invalid SendMax')
|
195
|
+
}
|
196
|
+
|
197
|
+
checkPartialPayment(tx)
|
198
|
+
}
|
199
|
+
|
200
|
+
function checkPartialPayment(tx: Record<string, unknown>): void {
|
201
|
+
if (tx.DeliverMin != null) {
|
202
|
+
if (tx.Flags == null) {
|
203
|
+
throw new ValidationError(
|
204
|
+
'PaymentTransaction: tfPartialPayment flag required with DeliverMin',
|
205
|
+
)
|
206
|
+
}
|
207
|
+
|
208
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Only used by JS
|
209
|
+
const flags = tx.Flags as number | PaymentFlagsInterface
|
210
|
+
const isTfPartialPayment =
|
211
|
+
typeof flags === 'number'
|
212
|
+
? isFlagEnabled(flags, PaymentFlags.tfPartialPayment)
|
213
|
+
: flags.tfPartialPayment ?? false
|
214
|
+
|
215
|
+
if (!isTfPartialPayment) {
|
216
|
+
throw new ValidationError(
|
217
|
+
'PaymentTransaction: tfPartialPayment flag required with DeliverMin',
|
218
|
+
)
|
219
|
+
}
|
220
|
+
|
221
|
+
if (!isAmount(tx.DeliverMin)) {
|
222
|
+
throw new ValidationError('PaymentTransaction: invalid DeliverMin')
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
function isPathStep(pathStep: Record<string, unknown>): boolean {
|
228
|
+
if (pathStep.account !== undefined && typeof pathStep.account !== 'string') {
|
229
|
+
return false
|
230
|
+
}
|
231
|
+
if (
|
232
|
+
pathStep.currency !== undefined &&
|
233
|
+
typeof pathStep.currency !== 'string'
|
234
|
+
) {
|
235
|
+
return false
|
236
|
+
}
|
237
|
+
if (pathStep.issuer !== undefined && typeof pathStep.issuer !== 'string') {
|
238
|
+
return false
|
239
|
+
}
|
240
|
+
if (
|
241
|
+
pathStep.account !== undefined &&
|
242
|
+
pathStep.currency === undefined &&
|
243
|
+
pathStep.issuer === undefined
|
244
|
+
) {
|
245
|
+
return true
|
246
|
+
}
|
247
|
+
if (pathStep.currency !== undefined || pathStep.issuer !== undefined) {
|
248
|
+
return true
|
249
|
+
}
|
250
|
+
return false
|
251
|
+
}
|
252
|
+
|
253
|
+
function isPath(path: Array<Record<string, unknown>>): boolean {
|
254
|
+
for (const pathStep of path) {
|
255
|
+
if (!isPathStep(pathStep)) {
|
256
|
+
return false
|
257
|
+
}
|
258
|
+
}
|
259
|
+
return true
|
260
|
+
}
|
261
|
+
|
262
|
+
function isPaths(paths: Array<Array<Record<string, unknown>>>): boolean {
|
263
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
264
|
+
return false
|
265
|
+
}
|
266
|
+
|
267
|
+
for (const path of paths) {
|
268
|
+
if (!Array.isArray(path) || path.length === 0) {
|
269
|
+
return false
|
270
|
+
}
|
271
|
+
|
272
|
+
if (!isPath(path)) {
|
273
|
+
return false
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
return true
|
278
|
+
}
|