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,11 @@
|
|
1
|
+
export { default as autofill } from './autofill'
|
2
|
+
|
3
|
+
export { getBalances, getXrpBalance } from './balances'
|
4
|
+
|
5
|
+
export { default as getLedgerIndex } from './getLedgerIndex'
|
6
|
+
|
7
|
+
export { default as getOrderbook } from './getOrderbook'
|
8
|
+
|
9
|
+
export * from './submit'
|
10
|
+
|
11
|
+
export * from './utils'
|
@@ -0,0 +1,305 @@
|
|
1
|
+
import { decode, encode } from 'ripple-binary-codec'
|
2
|
+
|
3
|
+
import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
|
4
|
+
import { ValidationError, XrplError } from '../errors'
|
5
|
+
import { Signer } from '../models/common'
|
6
|
+
import { TxRequest, TxResponse } from '../models/methods'
|
7
|
+
import { Transaction } from '../models/transactions'
|
8
|
+
import { BaseTransaction } from '../models/transactions/common'
|
9
|
+
import { hashes } from '../utils'
|
10
|
+
|
11
|
+
/** Approximate time for a ledger to close, in milliseconds */
|
12
|
+
const LEDGER_CLOSE_TIME = 1000
|
13
|
+
|
14
|
+
async function sleep(ms: number): Promise<void> {
|
15
|
+
return new Promise((resolve) => {
|
16
|
+
setTimeout(resolve, ms)
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Submits a signed/unsigned transaction.
|
22
|
+
* Steps performed on a transaction:
|
23
|
+
* 1. Autofill.
|
24
|
+
* 2. Sign & Encode.
|
25
|
+
* 3. Submit.
|
26
|
+
*
|
27
|
+
* @param this - A Client.
|
28
|
+
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
29
|
+
* @param opts - (Optional) Options used to sign and submit a transaction.
|
30
|
+
* @param opts.autofill - If true, autofill a transaction.
|
31
|
+
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
32
|
+
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
33
|
+
* @returns A promise that contains SubmitResponse.
|
34
|
+
* @throws RippledError if submit request fails.
|
35
|
+
*/
|
36
|
+
async function submit(
|
37
|
+
this: Client,
|
38
|
+
transaction: Transaction | string,
|
39
|
+
opts?: {
|
40
|
+
// If true, autofill a transaction.
|
41
|
+
autofill?: boolean
|
42
|
+
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
43
|
+
failHard?: boolean
|
44
|
+
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
45
|
+
wallet?: Wallet
|
46
|
+
},
|
47
|
+
): Promise<SubmitResponse> {
|
48
|
+
const signedTx = await getSignedTx(this, transaction, opts)
|
49
|
+
return submitRequest(this, signedTx, opts?.failHard)
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Asynchronously submits a transaction and verifies that it has been included in a
|
54
|
+
* validated ledger (or has errored/will not be included for some reason).
|
55
|
+
* See [Reliable Transaction Submission](https://xrpl.org/reliable-transaction-submission.html).
|
56
|
+
*
|
57
|
+
* @example
|
58
|
+
*
|
59
|
+
* ```ts
|
60
|
+
* const { Client, Wallet } = require('xrpl')
|
61
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
62
|
+
*
|
63
|
+
* async function submitTransaction() {
|
64
|
+
* const senderWallet = client.fundWallet()
|
65
|
+
* const recipientWallet = client.fundWallet()
|
66
|
+
*
|
67
|
+
* const transaction = {
|
68
|
+
* TransactionType: 'Payment',
|
69
|
+
* Account: senderWallet.address,
|
70
|
+
* Destination: recipientWallet.address,
|
71
|
+
* Amount: '10'
|
72
|
+
* }
|
73
|
+
*
|
74
|
+
* try {
|
75
|
+
* await client.submit(signedTransaction, { wallet: senderWallet })
|
76
|
+
* console.log(result)
|
77
|
+
* } catch (error) {
|
78
|
+
* console.error(`Failed to submit transaction: ${error}`)
|
79
|
+
* }
|
80
|
+
* }
|
81
|
+
*
|
82
|
+
* submitTransaction()
|
83
|
+
* ```
|
84
|
+
*
|
85
|
+
* In this example we submit a payment transaction between two newly created testnet accounts.
|
86
|
+
*
|
87
|
+
* Under the hood, `submit` will call `client.autofill` by default, and because we've passed in a `Wallet` it
|
88
|
+
* Will also sign the transaction for us before submitting the signed transaction binary blob to the ledger.
|
89
|
+
*
|
90
|
+
* This is similar to `submitAndWait` which does all of the above, but also waits to see if the transaction has been validated.
|
91
|
+
* @param this - A Client.
|
92
|
+
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
93
|
+
* @param opts - (Optional) Options used to sign and submit a transaction.
|
94
|
+
* @param opts.autofill - If true, autofill a transaction.
|
95
|
+
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
96
|
+
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
97
|
+
* @throws Connection errors: If the `Client` object is unable to establish a connection to the specified WebSocket endpoint,
|
98
|
+
* an error will be thrown.
|
99
|
+
* @throws Transaction errors: If the submitted transaction is invalid or cannot be included in a validated ledger for any
|
100
|
+
* reason, the promise returned by `submitAndWait()` will be rejected with an error. This could include issues with insufficient
|
101
|
+
* balance, invalid transaction fields, or other issues specific to the transaction being submitted.
|
102
|
+
* @throws Ledger errors: If the ledger being used to submit the transaction is undergoing maintenance or otherwise unavailable,
|
103
|
+
* an error will be thrown.
|
104
|
+
* @throws Timeout errors: If the transaction takes longer than the specified timeout period to be included in a validated
|
105
|
+
* ledger, the promise returned by `submitAndWait()` will be rejected with an error.
|
106
|
+
* @returns A promise that contains TxResponse, that will return when the transaction has been validated.
|
107
|
+
*/
|
108
|
+
async function submitAndWait<T extends Transaction = Transaction>(
|
109
|
+
this: Client,
|
110
|
+
transaction: T | string,
|
111
|
+
opts?: {
|
112
|
+
// If true, autofill a transaction.
|
113
|
+
autofill?: boolean
|
114
|
+
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
115
|
+
failHard?: boolean
|
116
|
+
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
117
|
+
wallet?: Wallet
|
118
|
+
},
|
119
|
+
): Promise<TxResponse<T>> {
|
120
|
+
const signedTx = await getSignedTx(this, transaction, opts)
|
121
|
+
|
122
|
+
const lastLedger = getLastLedgerSequence(signedTx)
|
123
|
+
if (lastLedger == null) {
|
124
|
+
throw new ValidationError(
|
125
|
+
'Transaction must contain a LastLedgerSequence value for reliable submission.',
|
126
|
+
)
|
127
|
+
}
|
128
|
+
|
129
|
+
const response = await submitRequest(this, signedTx, opts?.failHard)
|
130
|
+
|
131
|
+
const txHash = hashes.hashSignedTx(signedTx)
|
132
|
+
return waitForFinalTransactionOutcome(
|
133
|
+
this,
|
134
|
+
txHash,
|
135
|
+
lastLedger,
|
136
|
+
response.result.engine_result,
|
137
|
+
)
|
138
|
+
}
|
139
|
+
|
140
|
+
// Helper functions
|
141
|
+
|
142
|
+
// Encodes and submits a signed transaction.
|
143
|
+
async function submitRequest(
|
144
|
+
client: Client,
|
145
|
+
signedTransaction: Transaction | string,
|
146
|
+
failHard = false,
|
147
|
+
): Promise<SubmitResponse> {
|
148
|
+
if (!isSigned(signedTransaction)) {
|
149
|
+
throw new ValidationError('Transaction must be signed')
|
150
|
+
}
|
151
|
+
|
152
|
+
const signedTxEncoded =
|
153
|
+
typeof signedTransaction === 'string'
|
154
|
+
? signedTransaction
|
155
|
+
: encode(signedTransaction)
|
156
|
+
const request: SubmitRequest = {
|
157
|
+
command: 'submit',
|
158
|
+
tx_blob: signedTxEncoded,
|
159
|
+
fail_hard: isAccountDelete(signedTransaction) || failHard,
|
160
|
+
}
|
161
|
+
return client.request(request)
|
162
|
+
}
|
163
|
+
|
164
|
+
/*
|
165
|
+
* The core logic of reliable submission. This polls the ledger until the result of the
|
166
|
+
* transaction can be considered final, meaning it has either been included in a
|
167
|
+
* validated ledger, or the transaction's lastLedgerSequence has been surpassed by the
|
168
|
+
* latest ledger sequence (meaning it will never be included in a validated ledger).
|
169
|
+
*/
|
170
|
+
// eslint-disable-next-line max-params, max-lines-per-function -- this function needs to display and do with more information.
|
171
|
+
async function waitForFinalTransactionOutcome<
|
172
|
+
T extends BaseTransaction = Transaction,
|
173
|
+
>(
|
174
|
+
client: Client,
|
175
|
+
txHash: string,
|
176
|
+
lastLedger: number,
|
177
|
+
submissionResult: string,
|
178
|
+
): Promise<TxResponse<T>> {
|
179
|
+
await sleep(LEDGER_CLOSE_TIME)
|
180
|
+
|
181
|
+
const latestLedger = await client.getLedgerIndex()
|
182
|
+
|
183
|
+
if (lastLedger < latestLedger) {
|
184
|
+
throw new XrplError(
|
185
|
+
`The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger}).\n` +
|
186
|
+
`Preliminary result: ${submissionResult}`,
|
187
|
+
)
|
188
|
+
}
|
189
|
+
|
190
|
+
const txResponse = await client
|
191
|
+
.request<TxRequest, TxResponse<T>>({
|
192
|
+
command: 'tx',
|
193
|
+
transaction: txHash,
|
194
|
+
})
|
195
|
+
.catch(async (error) => {
|
196
|
+
// error is of an unknown type and hence we assert type to extract the value we need.
|
197
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions,@typescript-eslint/no-unsafe-member-access -- ^
|
198
|
+
const message = error?.data?.error as string
|
199
|
+
if (message === 'txnNotFound') {
|
200
|
+
return waitForFinalTransactionOutcome<T>(
|
201
|
+
client,
|
202
|
+
txHash,
|
203
|
+
lastLedger,
|
204
|
+
submissionResult,
|
205
|
+
)
|
206
|
+
}
|
207
|
+
throw new Error(
|
208
|
+
`${message} \n Preliminary result: ${submissionResult}.\nFull error details: ${String(
|
209
|
+
error,
|
210
|
+
)}`,
|
211
|
+
)
|
212
|
+
})
|
213
|
+
|
214
|
+
if (txResponse.result.validated) {
|
215
|
+
return txResponse
|
216
|
+
}
|
217
|
+
|
218
|
+
return waitForFinalTransactionOutcome<T>(
|
219
|
+
client,
|
220
|
+
txHash,
|
221
|
+
lastLedger,
|
222
|
+
submissionResult,
|
223
|
+
)
|
224
|
+
}
|
225
|
+
|
226
|
+
// checks if the transaction has been signed
|
227
|
+
function isSigned(transaction: Transaction | string): boolean {
|
228
|
+
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
229
|
+
if (typeof tx === 'string') {
|
230
|
+
return false
|
231
|
+
}
|
232
|
+
if (tx.Signers != null) {
|
233
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know that tx.Signers is an array of Signers
|
234
|
+
const signers = tx.Signers as Signer[]
|
235
|
+
for (const signer of signers) {
|
236
|
+
// eslint-disable-next-line max-depth -- necessary for checking if signer is signed
|
237
|
+
if (
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- necessary check
|
239
|
+
signer.Signer.SigningPubKey == null ||
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- necessary check
|
241
|
+
signer.Signer.TxnSignature == null
|
242
|
+
) {
|
243
|
+
return false
|
244
|
+
}
|
245
|
+
}
|
246
|
+
return true
|
247
|
+
}
|
248
|
+
return tx.SigningPubKey != null && tx.TxnSignature != null
|
249
|
+
}
|
250
|
+
|
251
|
+
// initializes a transaction for a submit request
|
252
|
+
async function getSignedTx(
|
253
|
+
client: Client,
|
254
|
+
transaction: Transaction | string,
|
255
|
+
{
|
256
|
+
autofill = true,
|
257
|
+
wallet,
|
258
|
+
}: {
|
259
|
+
// If true, autofill a transaction.
|
260
|
+
autofill?: boolean
|
261
|
+
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
262
|
+
failHard?: boolean
|
263
|
+
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
264
|
+
wallet?: Wallet
|
265
|
+
} = {},
|
266
|
+
): Promise<Transaction | string> {
|
267
|
+
if (isSigned(transaction)) {
|
268
|
+
return transaction
|
269
|
+
}
|
270
|
+
|
271
|
+
if (!wallet) {
|
272
|
+
throw new ValidationError(
|
273
|
+
'Wallet must be provided when submitting an unsigned transaction',
|
274
|
+
)
|
275
|
+
}
|
276
|
+
|
277
|
+
let tx =
|
278
|
+
typeof transaction === 'string'
|
279
|
+
? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- converts JsonObject to correct Transaction type
|
280
|
+
(decode(transaction) as unknown as Transaction)
|
281
|
+
: transaction
|
282
|
+
|
283
|
+
if (autofill) {
|
284
|
+
tx = await client.autofill(tx)
|
285
|
+
}
|
286
|
+
|
287
|
+
return wallet.sign(tx).tx_blob
|
288
|
+
}
|
289
|
+
|
290
|
+
// checks if there is a LastLedgerSequence as a part of the transaction
|
291
|
+
function getLastLedgerSequence(
|
292
|
+
transaction: Transaction | string,
|
293
|
+
): number | null {
|
294
|
+
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
295
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- converts LastLedgSeq to number if present.
|
296
|
+
return tx.LastLedgerSequence as number | null
|
297
|
+
}
|
298
|
+
|
299
|
+
// checks if the transaction is an AccountDelete transaction
|
300
|
+
function isAccountDelete(transaction: Transaction | string): boolean {
|
301
|
+
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
302
|
+
return tx.TransactionType === 'AccountDelete'
|
303
|
+
}
|
304
|
+
|
305
|
+
export { submit, submitAndWait }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
2
|
+
|
3
|
+
/**
|
4
|
+
* If an address is an X-Address, converts it to a classic address.
|
5
|
+
*
|
6
|
+
* @param account - A classic address or X-address.
|
7
|
+
* @returns The account's classic address.
|
8
|
+
* @throws Error if the X-Address has an associated tag.
|
9
|
+
*/
|
10
|
+
export function ensureClassicAddress(account: string): string {
|
11
|
+
if (isValidXAddress(account)) {
|
12
|
+
const { classicAddress, tag } = xAddressToClassicAddress(account)
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Except for special cases, X-addresses used for requests
|
16
|
+
* must not have an embedded tag. In other words,
|
17
|
+
* `tag` should be `false`.
|
18
|
+
*/
|
19
|
+
if (tag !== false) {
|
20
|
+
throw new Error(
|
21
|
+
'This command does not support the use of a tag. Use an address without a tag.',
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
// For rippled requests that use an account, always use a classic address.
|
26
|
+
return classicAddress
|
27
|
+
}
|
28
|
+
return account
|
29
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { classicAddressToXAddress } from 'ripple-address-codec'
|
2
|
+
import { deriveKeypair, deriveAddress } from 'ripple-keypairs'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Derive an X-Address from a public key and a destination tag.
|
6
|
+
*
|
7
|
+
* @param options - Public key and destination tag to encode as an X-Address.
|
8
|
+
* @param options.publicKey - The public key corresponding to an address.
|
9
|
+
* @param options.tag - A destination tag to encode into an X-address. False indicates no destination tag.
|
10
|
+
* @param options.test - Whether this address is for use in Testnet.
|
11
|
+
* @returns X-Address.
|
12
|
+
* @category Utilities
|
13
|
+
*/
|
14
|
+
function deriveXAddress(options: {
|
15
|
+
publicKey: string
|
16
|
+
tag: number | false
|
17
|
+
test: boolean
|
18
|
+
}): string {
|
19
|
+
const classicAddress = deriveAddress(options.publicKey)
|
20
|
+
return classicAddressToXAddress(classicAddress, options.tag, options.test)
|
21
|
+
}
|
22
|
+
|
23
|
+
export { deriveKeypair, deriveAddress, deriveXAddress }
|
@@ -0,0 +1,186 @@
|
|
1
|
+
import BigNumber from 'bignumber.js'
|
2
|
+
import flatten from 'lodash/flatten'
|
3
|
+
import groupBy from 'lodash/groupBy'
|
4
|
+
|
5
|
+
import {
|
6
|
+
Amount,
|
7
|
+
Balance,
|
8
|
+
IssuedCurrencyAmount,
|
9
|
+
TransactionMetadata,
|
10
|
+
Node,
|
11
|
+
} from '../models'
|
12
|
+
|
13
|
+
import { dropsToXrp } from './xrpConversion'
|
14
|
+
|
15
|
+
interface BalanceChange {
|
16
|
+
account: string
|
17
|
+
balance: Balance
|
18
|
+
}
|
19
|
+
interface Fields {
|
20
|
+
Account?: string
|
21
|
+
Balance?: Amount
|
22
|
+
LowLimit?: IssuedCurrencyAmount
|
23
|
+
HighLimit?: IssuedCurrencyAmount
|
24
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering -- okay here, just some of the fields are typed to make it easier
|
25
|
+
[field: string]: unknown
|
26
|
+
}
|
27
|
+
|
28
|
+
interface NormalizedNode {
|
29
|
+
// 'CreatedNode' | 'ModifiedNode' | 'DeletedNode'
|
30
|
+
NodeType: string
|
31
|
+
LedgerEntryType: string
|
32
|
+
LedgerIndex: string
|
33
|
+
NewFields?: Fields
|
34
|
+
FinalFields?: Fields
|
35
|
+
PreviousFields?: Fields
|
36
|
+
PreviousTxnID?: string
|
37
|
+
PreviousTxnLgrSeq?: number
|
38
|
+
}
|
39
|
+
|
40
|
+
function normalizeNode(affectedNode: Node): NormalizedNode {
|
41
|
+
const diffType = Object.keys(affectedNode)[0]
|
42
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- not quite right, but close enough
|
43
|
+
const node = affectedNode[diffType] as NormalizedNode
|
44
|
+
return {
|
45
|
+
...node,
|
46
|
+
NodeType: diffType,
|
47
|
+
LedgerEntryType: node.LedgerEntryType,
|
48
|
+
LedgerIndex: node.LedgerIndex,
|
49
|
+
NewFields: node.NewFields,
|
50
|
+
FinalFields: node.FinalFields,
|
51
|
+
PreviousFields: node.PreviousFields,
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
function normalizeNodes(metadata: TransactionMetadata): NormalizedNode[] {
|
56
|
+
if (metadata.AffectedNodes.length === 0) {
|
57
|
+
return []
|
58
|
+
}
|
59
|
+
return metadata.AffectedNodes.map(normalizeNode)
|
60
|
+
}
|
61
|
+
|
62
|
+
function groupByAccount(balanceChanges: BalanceChange[]): Array<{
|
63
|
+
account: string
|
64
|
+
balances: Balance[]
|
65
|
+
}> {
|
66
|
+
const grouped = groupBy(balanceChanges, (node) => node.account)
|
67
|
+
return Object.entries(grouped).map(([account, items]) => {
|
68
|
+
return { account, balances: items.map((item) => item.balance) }
|
69
|
+
})
|
70
|
+
}
|
71
|
+
|
72
|
+
function getValue(balance: Amount): BigNumber {
|
73
|
+
if (typeof balance === 'string') {
|
74
|
+
return new BigNumber(balance)
|
75
|
+
}
|
76
|
+
return new BigNumber(balance.value)
|
77
|
+
}
|
78
|
+
|
79
|
+
function computeBalanceChange(node: NormalizedNode): BigNumber | null {
|
80
|
+
let value: BigNumber | null = null
|
81
|
+
if (node.NewFields?.Balance) {
|
82
|
+
value = getValue(node.NewFields.Balance)
|
83
|
+
} else if (node.PreviousFields?.Balance && node.FinalFields?.Balance) {
|
84
|
+
value = getValue(node.FinalFields.Balance).minus(
|
85
|
+
getValue(node.PreviousFields.Balance),
|
86
|
+
)
|
87
|
+
}
|
88
|
+
if (value === null || value.isZero()) {
|
89
|
+
return null
|
90
|
+
}
|
91
|
+
return value
|
92
|
+
}
|
93
|
+
|
94
|
+
function getXRPQuantity(
|
95
|
+
node: NormalizedNode,
|
96
|
+
): { account: string; balance: Balance } | null {
|
97
|
+
const value = computeBalanceChange(node)
|
98
|
+
|
99
|
+
if (value === null) {
|
100
|
+
return null
|
101
|
+
}
|
102
|
+
|
103
|
+
return {
|
104
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- okay here
|
105
|
+
account: (node.FinalFields?.Account ?? node.NewFields?.Account) as string,
|
106
|
+
balance: {
|
107
|
+
currency: 'XRP',
|
108
|
+
value: dropsToXrp(value).toString(),
|
109
|
+
},
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function flipTrustlinePerspective(balanceChange: BalanceChange): BalanceChange {
|
114
|
+
const negatedBalance = new BigNumber(balanceChange.balance.value).negated()
|
115
|
+
return {
|
116
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know this is true
|
117
|
+
account: balanceChange.balance.issuer as string,
|
118
|
+
balance: {
|
119
|
+
issuer: balanceChange.account,
|
120
|
+
currency: balanceChange.balance.currency,
|
121
|
+
value: negatedBalance.toString(),
|
122
|
+
},
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
function getTrustlineQuantity(node: NormalizedNode): BalanceChange[] | null {
|
127
|
+
const value = computeBalanceChange(node)
|
128
|
+
|
129
|
+
if (value === null) {
|
130
|
+
return null
|
131
|
+
}
|
132
|
+
|
133
|
+
/*
|
134
|
+
* A trustline can be created with a non-zero starting balance.
|
135
|
+
* If an offer is placed to acquire an asset with no existing trustline,
|
136
|
+
* the trustline can be created when the offer is taken.
|
137
|
+
*/
|
138
|
+
const fields = node.NewFields == null ? node.FinalFields : node.NewFields
|
139
|
+
|
140
|
+
// the balance is always from low node's perspective
|
141
|
+
const result = {
|
142
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know that this is true
|
143
|
+
account: fields?.LowLimit?.issuer as string,
|
144
|
+
balance: {
|
145
|
+
issuer: fields?.HighLimit?.issuer,
|
146
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know that this is true
|
147
|
+
currency: (fields?.Balance as IssuedCurrencyAmount).currency,
|
148
|
+
value: value.toString(),
|
149
|
+
},
|
150
|
+
}
|
151
|
+
return [result, flipTrustlinePerspective(result)]
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Computes the complete list of every balance that changed in the ledger
|
156
|
+
* as a result of the given transaction.
|
157
|
+
*
|
158
|
+
* @param metadata - Transaction metadata.
|
159
|
+
* @returns Parsed balance changes.
|
160
|
+
* @category Utilities
|
161
|
+
*/
|
162
|
+
export default function getBalanceChanges(
|
163
|
+
metadata: TransactionMetadata,
|
164
|
+
): Array<{
|
165
|
+
account: string
|
166
|
+
balances: Balance[]
|
167
|
+
}> {
|
168
|
+
const quantities = normalizeNodes(metadata).map((node) => {
|
169
|
+
if (node.LedgerEntryType === 'AccountRoot') {
|
170
|
+
const xrpQuantity = getXRPQuantity(node)
|
171
|
+
if (xrpQuantity == null) {
|
172
|
+
return []
|
173
|
+
}
|
174
|
+
return [xrpQuantity]
|
175
|
+
}
|
176
|
+
if (node.LedgerEntryType === 'RippleState') {
|
177
|
+
const trustlineQuantity = getTrustlineQuantity(node)
|
178
|
+
if (trustlineQuantity == null) {
|
179
|
+
return []
|
180
|
+
}
|
181
|
+
return trustlineQuantity
|
182
|
+
}
|
183
|
+
return []
|
184
|
+
})
|
185
|
+
return groupByAccount(flatten(quantities))
|
186
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import flatMap from 'lodash/flatMap'
|
2
|
+
import { decode } from 'ripple-binary-codec'
|
3
|
+
|
4
|
+
import { NFToken } from '../models/ledger/NFTokenPage'
|
5
|
+
import {
|
6
|
+
CreatedNode,
|
7
|
+
isCreatedNode,
|
8
|
+
isModifiedNode,
|
9
|
+
ModifiedNode,
|
10
|
+
TransactionMetadata,
|
11
|
+
} from '../models/transactions/metadata'
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Ensures that the metadata is in a deserialized format to parse.
|
15
|
+
*
|
16
|
+
* @param meta - the metadata from a `tx` method call. Can be in json format or binary format.
|
17
|
+
* @returns the metadata in a deserialized format.
|
18
|
+
*/
|
19
|
+
function ensureDecodedMeta(
|
20
|
+
meta: TransactionMetadata | string,
|
21
|
+
): TransactionMetadata {
|
22
|
+
if (typeof meta === 'string') {
|
23
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Meta is either metadata or serialized metadata.
|
24
|
+
return decode(meta) as unknown as TransactionMetadata
|
25
|
+
}
|
26
|
+
return meta
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Gets the NFTokenID for an NFT recently minted with NFTokenMint.
|
31
|
+
*
|
32
|
+
* @param meta - Metadata from the response to submitting and waiting for an NFTokenMint transaction or from a `tx` method call.
|
33
|
+
* @returns The NFTokenID for the minted NFT.
|
34
|
+
* @throws if meta is not TransactionMetadata.
|
35
|
+
*/
|
36
|
+
export default function getNFTokenID(
|
37
|
+
meta: TransactionMetadata | string | undefined,
|
38
|
+
): string | undefined {
|
39
|
+
if (typeof meta !== 'string' && meta?.AffectedNodes === undefined) {
|
40
|
+
throw new TypeError(`Unable to parse the parameter given to getNFTokenID.
|
41
|
+
'meta' must be the metadata from an NFTokenMint transaction. Received ${JSON.stringify(
|
42
|
+
meta,
|
43
|
+
)} instead.`)
|
44
|
+
}
|
45
|
+
|
46
|
+
const decodedMeta = ensureDecodedMeta(meta)
|
47
|
+
|
48
|
+
/*
|
49
|
+
* When a mint results in splitting an existing page,
|
50
|
+
* it results in a created page and a modified node. Sometimes,
|
51
|
+
* the created node needs to be linked to a third page, resulting
|
52
|
+
* in modifying that third page's PreviousPageMin or NextPageMin
|
53
|
+
* field changing, but no NFTs within that page changing. In this
|
54
|
+
* case, there will be no previous NFTs and we need to skip.
|
55
|
+
* However, there will always be NFTs listed in the final fields,
|
56
|
+
* as rippled outputs all fields in final fields even if they were
|
57
|
+
* not changed. Thus why we add the additional condition to check
|
58
|
+
* if the PreviousFields contains NFTokens
|
59
|
+
*/
|
60
|
+
|
61
|
+
const affectedNodes = decodedMeta.AffectedNodes.filter((node) => {
|
62
|
+
if (isCreatedNode(node)) {
|
63
|
+
return node.CreatedNode.LedgerEntryType === 'NFTokenPage'
|
64
|
+
}
|
65
|
+
if (isModifiedNode(node)) {
|
66
|
+
return (
|
67
|
+
node.ModifiedNode.LedgerEntryType === 'NFTokenPage' &&
|
68
|
+
Boolean(node.ModifiedNode.PreviousFields?.NFTokens)
|
69
|
+
)
|
70
|
+
}
|
71
|
+
return false
|
72
|
+
})
|
73
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
|
74
|
+
const previousTokenIDSet = new Set(
|
75
|
+
flatMap(affectedNodes, (node) => {
|
76
|
+
const nftokens = isModifiedNode(node)
|
77
|
+
? (node.ModifiedNode.PreviousFields?.NFTokens as NFToken[])
|
78
|
+
: []
|
79
|
+
return nftokens.map((token) => token.NFToken.NFTokenID)
|
80
|
+
}).filter((id) => Boolean(id)),
|
81
|
+
)
|
82
|
+
|
83
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
|
84
|
+
const finalTokenIDs = flatMap(affectedNodes, (node) =>
|
85
|
+
(
|
86
|
+
(((node as ModifiedNode).ModifiedNode?.FinalFields?.NFTokens ??
|
87
|
+
(node as CreatedNode).CreatedNode?.NewFields?.NFTokens) as NFToken[]) ??
|
88
|
+
[]
|
89
|
+
).map((token) => token.NFToken.NFTokenID),
|
90
|
+
).filter((nftokenID) => Boolean(nftokenID))
|
91
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
|
92
|
+
/* eslint-enable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
|
93
|
+
|
94
|
+
const nftokenID = finalTokenIDs.find((id) => !previousTokenIDSet.has(id))
|
95
|
+
|
96
|
+
return nftokenID
|
97
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* Prefix for hashing functions.
|
3
|
+
*
|
4
|
+
* These prefixes are inserted before the source material used to
|
5
|
+
* generate various hashes. This is done to put each hash in its own
|
6
|
+
* "space." This way, two different types of objects with the
|
7
|
+
* same binary data will produce different hashes.
|
8
|
+
*
|
9
|
+
* Each prefix is a 4-byte value with the last byte set to zero
|
10
|
+
* and the first three bytes formed from the ASCII equivalent of
|
11
|
+
* some arbitrary string. For example "TXN".
|
12
|
+
*/
|
13
|
+
|
14
|
+
enum HashPrefix {
|
15
|
+
// transaction plus signature to give transaction ID 'TXN'
|
16
|
+
TRANSACTION_ID = 0x54584e00,
|
17
|
+
|
18
|
+
// transaction plus metadata 'TND'
|
19
|
+
TRANSACTION_NODE = 0x534e4400,
|
20
|
+
|
21
|
+
// inner node in tree 'MIN'
|
22
|
+
INNER_NODE = 0x4d494e00,
|
23
|
+
|
24
|
+
// leaf node in tree 'MLN'
|
25
|
+
LEAF_NODE = 0x4d4c4e00,
|
26
|
+
|
27
|
+
// inner transaction to sign 'STX'
|
28
|
+
TRANSACTION_SIGN = 0x53545800,
|
29
|
+
|
30
|
+
// inner transaction to sign (TESTNET) 'stx'
|
31
|
+
TRANSACTION_SIGN_TESTNET = 0x73747800,
|
32
|
+
|
33
|
+
// inner transaction to multisign 'SMT'
|
34
|
+
TRANSACTION_MULTISIGN = 0x534d5400,
|
35
|
+
|
36
|
+
// ledger 'LWR'
|
37
|
+
LEDGER = 0x4c575200,
|
38
|
+
}
|
39
|
+
|
40
|
+
export default HashPrefix
|