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,187 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers -- this file mimics
|
2
|
+
behavior in rippled. Magic numbers are used for lengths and conditions */
|
3
|
+
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
|
4
|
+
bitwise operators for and-ing numbers with a mask and bit shifting. */
|
5
|
+
|
6
|
+
import BigNumber from 'bignumber.js'
|
7
|
+
import { decodeAccountID } from 'ripple-address-codec'
|
8
|
+
|
9
|
+
import hashLedger, {
|
10
|
+
hashLedgerHeader,
|
11
|
+
hashSignedTx,
|
12
|
+
hashTxTree,
|
13
|
+
hashStateTree,
|
14
|
+
} from './hashLedger'
|
15
|
+
import HashPrefix from './HashPrefix'
|
16
|
+
import ledgerSpaces from './ledgerSpaces'
|
17
|
+
import sha512Half from './sha512Half'
|
18
|
+
|
19
|
+
const HEX = 16
|
20
|
+
const BYTE_LENGTH = 4
|
21
|
+
|
22
|
+
function addressToHex(address: string): string {
|
23
|
+
return Buffer.from(decodeAccountID(address)).toString('hex')
|
24
|
+
}
|
25
|
+
|
26
|
+
function ledgerSpaceHex(name: keyof typeof ledgerSpaces): string {
|
27
|
+
return ledgerSpaces[name].charCodeAt(0).toString(HEX).padStart(4, '0')
|
28
|
+
}
|
29
|
+
|
30
|
+
const MASK = 0xff
|
31
|
+
function currencyToHex(currency: string): string {
|
32
|
+
if (currency.length !== 3) {
|
33
|
+
return currency
|
34
|
+
}
|
35
|
+
|
36
|
+
const bytes = Array(20).fill(0)
|
37
|
+
bytes[12] = currency.charCodeAt(0) & MASK
|
38
|
+
bytes[13] = currency.charCodeAt(1) & MASK
|
39
|
+
bytes[14] = currency.charCodeAt(2) & MASK
|
40
|
+
return Buffer.from(bytes).toString('hex')
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Hash the given binary transaction data with the single-signing prefix.
|
45
|
+
*
|
46
|
+
* See [Serialization Format](https://xrpl.org/serialization.html).
|
47
|
+
*
|
48
|
+
* @param txBlobHex - The binary transaction blob as a hexadecimal string.
|
49
|
+
* @returns The hash to sign.
|
50
|
+
* @category Utilities
|
51
|
+
*/
|
52
|
+
export function hashTx(txBlobHex: string): string {
|
53
|
+
const prefix = HashPrefix.TRANSACTION_SIGN.toString(HEX).toUpperCase()
|
54
|
+
return sha512Half(prefix + txBlobHex)
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Compute AccountRoot Ledger Object Index.
|
59
|
+
*
|
60
|
+
* All objects in a ledger's state tree have a unique Index.
|
61
|
+
* The AccountRoot Ledger Object Index is derived by hashing the
|
62
|
+
* address with a namespace identifier. This ensures every
|
63
|
+
* Index is unique.
|
64
|
+
*
|
65
|
+
* See [Ledger Object Indexes](https://xrpl.org/ledger-object-ids.html).
|
66
|
+
*
|
67
|
+
* @param address - The classic account address.
|
68
|
+
* @returns The Ledger Object Index for the account.
|
69
|
+
* @category Utilities
|
70
|
+
*/
|
71
|
+
export function hashAccountRoot(address: string): string {
|
72
|
+
return sha512Half(ledgerSpaceHex('account') + addressToHex(address))
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* [SignerList Index Format](https://xrpl.org/signerlist.html#signerlist-id-format).
|
77
|
+
*
|
78
|
+
* The Index of a SignerList object is the SHA-512Half of the following values, concatenated in order:
|
79
|
+
* * The RippleState space key (0x0053)
|
80
|
+
* * The AccountID of the owner of the SignerList
|
81
|
+
* * The SignerListID (currently always 0).
|
82
|
+
*
|
83
|
+
* This method computes a SignerList Ledger Object Index.
|
84
|
+
*
|
85
|
+
* @param address - The classic account address of the SignerList owner (starting with r).
|
86
|
+
* @returns The Index of the account's SignerList object.
|
87
|
+
* @category Utilities
|
88
|
+
*/
|
89
|
+
export function hashSignerListId(address: string): string {
|
90
|
+
return sha512Half(
|
91
|
+
`${ledgerSpaceHex('signerList') + addressToHex(address)}00000000`,
|
92
|
+
)
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* [Offer Index Format](https://xrpl.org/offer.html#offer-id-format).
|
97
|
+
*
|
98
|
+
* The Index of a Offer object is the SHA-512Half of the following values, concatenated in order:
|
99
|
+
* * The Offer space key (0x006F)
|
100
|
+
* * The AccountID of the account placing the offer
|
101
|
+
* * The Sequence number of the OfferCreate transaction that created the offer.
|
102
|
+
*
|
103
|
+
* This method computes an Offer Index.
|
104
|
+
*
|
105
|
+
* @param address - The classic account address of the SignerList owner (starting with r).
|
106
|
+
* @param sequence - Sequence of the Offer.
|
107
|
+
* @returns The Index of the account's Offer object.
|
108
|
+
* @category Utilities
|
109
|
+
*/
|
110
|
+
export function hashOfferId(address: string, sequence: number): string {
|
111
|
+
const hexPrefix = ledgerSpaces.offer
|
112
|
+
.charCodeAt(0)
|
113
|
+
.toString(HEX)
|
114
|
+
.padStart(2, '0')
|
115
|
+
const hexSequence = sequence.toString(HEX).padStart(8, '0')
|
116
|
+
const prefix = `00${hexPrefix}`
|
117
|
+
return sha512Half(prefix + addressToHex(address) + hexSequence)
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Compute the hash of a Trustline.
|
122
|
+
*
|
123
|
+
* @param address1 - One of the addresses in the Trustline.
|
124
|
+
* @param address2 - The other address in the Trustline.
|
125
|
+
* @param currency - Currency in the Trustline.
|
126
|
+
* @returns The hash of the Trustline.
|
127
|
+
* @category Utilities
|
128
|
+
*/
|
129
|
+
export function hashTrustline(
|
130
|
+
address1: string,
|
131
|
+
address2: string,
|
132
|
+
currency: string,
|
133
|
+
): string {
|
134
|
+
const address1Hex = addressToHex(address1)
|
135
|
+
const address2Hex = addressToHex(address2)
|
136
|
+
|
137
|
+
const swap = new BigNumber(address1Hex, 16).isGreaterThan(
|
138
|
+
new BigNumber(address2Hex, 16),
|
139
|
+
)
|
140
|
+
const lowAddressHex = swap ? address2Hex : address1Hex
|
141
|
+
const highAddressHex = swap ? address1Hex : address2Hex
|
142
|
+
|
143
|
+
const prefix = ledgerSpaceHex('rippleState')
|
144
|
+
return sha512Half(
|
145
|
+
prefix + lowAddressHex + highAddressHex + currencyToHex(currency),
|
146
|
+
)
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Compute the Hash of an Escrow LedgerEntry.
|
151
|
+
*
|
152
|
+
* @param address - Address of the Escrow.
|
153
|
+
* @param sequence - OfferSequence of the Escrow.
|
154
|
+
* @returns The hash of the Escrow LedgerEntry.
|
155
|
+
* @category Utilities
|
156
|
+
*/
|
157
|
+
export function hashEscrow(address: string, sequence: number): string {
|
158
|
+
return sha512Half(
|
159
|
+
ledgerSpaceHex('escrow') +
|
160
|
+
addressToHex(address) +
|
161
|
+
sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'),
|
162
|
+
)
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Compute the hash of a Payment Channel.
|
167
|
+
*
|
168
|
+
* @param address - Account of the Payment Channel.
|
169
|
+
* @param dstAddress - Destination Account of the Payment Channel.
|
170
|
+
* @param sequence - Sequence number of the Transaction that created the Payment Channel.
|
171
|
+
* @returns Hash of the Payment Channel.
|
172
|
+
* @category Utilities
|
173
|
+
*/
|
174
|
+
export function hashPaymentChannel(
|
175
|
+
address: string,
|
176
|
+
dstAddress: string,
|
177
|
+
sequence: number,
|
178
|
+
): string {
|
179
|
+
return sha512Half(
|
180
|
+
ledgerSpaceHex('paychan') +
|
181
|
+
addressToHex(address) +
|
182
|
+
addressToHex(dstAddress) +
|
183
|
+
sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'),
|
184
|
+
)
|
185
|
+
}
|
186
|
+
|
187
|
+
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* XRP Ledger namespace prefixes.
|
3
|
+
*
|
4
|
+
* The XRP Ledger is a key-value store. In order to avoid name collisions,
|
5
|
+
* names are partitioned into namespaces.
|
6
|
+
*
|
7
|
+
* Each namespace is just a single character prefix.
|
8
|
+
*
|
9
|
+
* See [LedgerNameSpace enum](https://github.com/ripple/rippled/blob/master/src/ripple/protocol/LedgerFormats.h#L100).
|
10
|
+
*/
|
11
|
+
const ledgerSpaces = {
|
12
|
+
account: 'a',
|
13
|
+
dirNode: 'd',
|
14
|
+
generatorMap: 'g',
|
15
|
+
rippleState: 'r',
|
16
|
+
// Entry for an offer.
|
17
|
+
offer: 'o',
|
18
|
+
// Directory of things owned by an account.
|
19
|
+
ownerDir: 'O',
|
20
|
+
// Directory of order books.
|
21
|
+
bookDir: 'B',
|
22
|
+
contract: 'c',
|
23
|
+
skipList: 's',
|
24
|
+
escrow: 'u',
|
25
|
+
amendment: 'f',
|
26
|
+
feeSettings: 'e',
|
27
|
+
ticket: 'T',
|
28
|
+
signerList: 'S',
|
29
|
+
paychan: 'x',
|
30
|
+
check: 'C',
|
31
|
+
depositPreauth: 'p',
|
32
|
+
}
|
33
|
+
|
34
|
+
export default ledgerSpaces
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { createHash } from 'crypto'
|
2
|
+
|
3
|
+
const HASH_SIZE = 64
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Compute a sha512Half Hash of a hex string.
|
7
|
+
*
|
8
|
+
* @param hex - Hex string to hash.
|
9
|
+
* @returns Hash of hex.
|
10
|
+
*/
|
11
|
+
function sha512Half(hex: string): string {
|
12
|
+
return createHash('sha512')
|
13
|
+
.update(Buffer.from(hex, 'hex'))
|
14
|
+
.digest('hex')
|
15
|
+
.toUpperCase()
|
16
|
+
.slice(0, HASH_SIZE)
|
17
|
+
}
|
18
|
+
|
19
|
+
export default sha512Half
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import {
|
2
|
+
classicAddressToXAddress,
|
3
|
+
decodeAccountID,
|
4
|
+
decodeAccountPublic,
|
5
|
+
decodeNodePublic,
|
6
|
+
decodeSeed,
|
7
|
+
decodeXAddress,
|
8
|
+
encodeAccountID,
|
9
|
+
encodeAccountPublic,
|
10
|
+
encodeNodePublic,
|
11
|
+
encodeSeed,
|
12
|
+
encodeXAddress,
|
13
|
+
isValidClassicAddress,
|
14
|
+
isValidXAddress,
|
15
|
+
xAddressToClassicAddress,
|
16
|
+
} from 'ripple-address-codec'
|
17
|
+
import * as rbc from 'ripple-binary-codec'
|
18
|
+
import { verify as verifyKeypairSignature } from 'ripple-keypairs'
|
19
|
+
|
20
|
+
import { LedgerEntry } from '../models/ledger'
|
21
|
+
import { Response } from '../models/methods'
|
22
|
+
import { PaymentChannelClaim } from '../models/transactions/paymentChannelClaim'
|
23
|
+
import { Transaction } from '../models/transactions/transaction'
|
24
|
+
|
25
|
+
import { deriveKeypair, deriveAddress, deriveXAddress } from './derive'
|
26
|
+
import getBalanceChanges from './getBalanceChanges'
|
27
|
+
import getNFTokenID from './getNFTokenID'
|
28
|
+
import {
|
29
|
+
hashSignedTx,
|
30
|
+
hashTx,
|
31
|
+
hashAccountRoot,
|
32
|
+
hashSignerListId,
|
33
|
+
hashOfferId,
|
34
|
+
hashTrustline,
|
35
|
+
hashTxTree,
|
36
|
+
hashStateTree,
|
37
|
+
hashLedger,
|
38
|
+
hashLedgerHeader,
|
39
|
+
hashEscrow,
|
40
|
+
hashPaymentChannel,
|
41
|
+
} from './hashes'
|
42
|
+
import parseNFTokenID from './parseNFTokenID'
|
43
|
+
import {
|
44
|
+
percentToTransferRate,
|
45
|
+
decimalToTransferRate,
|
46
|
+
transferRateToDecimal,
|
47
|
+
percentToQuality,
|
48
|
+
decimalToQuality,
|
49
|
+
qualityToDecimal,
|
50
|
+
} from './quality'
|
51
|
+
import signPaymentChannelClaim from './signPaymentChannelClaim'
|
52
|
+
import { convertHexToString, convertStringToHex } from './stringConversion'
|
53
|
+
import {
|
54
|
+
rippleTimeToISOTime,
|
55
|
+
isoTimeToRippleTime,
|
56
|
+
rippleTimeToUnixTime,
|
57
|
+
unixTimeToRippleTime,
|
58
|
+
} from './timeConversion'
|
59
|
+
import verifyPaymentChannelClaim from './verifyPaymentChannelClaim'
|
60
|
+
import { xrpToDrops, dropsToXrp } from './xrpConversion'
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Check if a secret is valid.
|
64
|
+
*
|
65
|
+
* @param secret - Secret to test for validity.
|
66
|
+
* @returns True if secret can be derived into a keypair.
|
67
|
+
* @category Utilities
|
68
|
+
*/
|
69
|
+
function isValidSecret(secret: string): boolean {
|
70
|
+
try {
|
71
|
+
deriveKeypair(secret)
|
72
|
+
return true
|
73
|
+
} catch (_err) {
|
74
|
+
return false
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Encodes a LedgerEntry or Transaction into a hex string
|
80
|
+
*
|
81
|
+
* @param object - LedgerEntry or Transaction in JSON format.
|
82
|
+
* @returns A hex string representing the encoded object.
|
83
|
+
*/
|
84
|
+
function encode(object: Transaction | LedgerEntry): string {
|
85
|
+
return rbc.encode(object)
|
86
|
+
}
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Encodes a Transaction for signing
|
90
|
+
*
|
91
|
+
* @param object - LedgerEntry in JSON or Transaction format.
|
92
|
+
* @returns A hex string representing the encoded object.
|
93
|
+
*/
|
94
|
+
function encodeForSigning(object: Transaction): string {
|
95
|
+
return rbc.encodeForSigning(object)
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Encodes a PaymentChannelClaim for signing
|
100
|
+
*
|
101
|
+
* @param object - PaymentChannelClaim in JSON format.
|
102
|
+
* @returns A hex string representing the encoded object.
|
103
|
+
*/
|
104
|
+
function encodeForSigningClaim(object: PaymentChannelClaim): string {
|
105
|
+
return rbc.encodeForSigningClaim(object)
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Encodes a Transaction for multi-signing
|
110
|
+
*
|
111
|
+
* @param object - Transaction in JSON format.
|
112
|
+
* @param signer - The address of the account signing this transaction
|
113
|
+
* @returns A hex string representing the encoded object.
|
114
|
+
*/
|
115
|
+
function encodeForMultiSigning(object: Transaction, signer: string): string {
|
116
|
+
return rbc.encodeForMultisigning(object, signer)
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Decodes a hex string into a transaction | ledger entry
|
121
|
+
*
|
122
|
+
* @param hex - hex string in the XRPL serialization format.
|
123
|
+
* @returns The hex string decoded according to XRPL serialization format.
|
124
|
+
*/
|
125
|
+
function decode(hex: string): Record<string, unknown> {
|
126
|
+
return rbc.decode(hex)
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Validates that a given address is a valid X-Address or a valid classic
|
131
|
+
* address.
|
132
|
+
*
|
133
|
+
* @param address - Address to validate.
|
134
|
+
* @returns True if address is a valid X-Address or classic address.
|
135
|
+
* @category Utilities
|
136
|
+
*/
|
137
|
+
function isValidAddress(address: string): boolean {
|
138
|
+
return isValidXAddress(address) || isValidClassicAddress(address)
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Returns true if there are more pages of data.
|
143
|
+
*
|
144
|
+
* When there are more results than contained in the response, the response
|
145
|
+
* includes a `marker` field.
|
146
|
+
*
|
147
|
+
* See https://ripple.com/build/rippled-apis/#markers-and-pagination.
|
148
|
+
*
|
149
|
+
* @param response - Response to check for more pages on.
|
150
|
+
* @returns Whether the response has more pages of data.
|
151
|
+
* @category Utilities
|
152
|
+
*/
|
153
|
+
function hasNextPage(response: Response): boolean {
|
154
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation -- only checking if it exists
|
155
|
+
return Boolean(response.result['marker'])
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* @category Utilities
|
160
|
+
*/
|
161
|
+
const hashes = {
|
162
|
+
hashSignedTx,
|
163
|
+
hashTx,
|
164
|
+
hashAccountRoot,
|
165
|
+
hashSignerListId,
|
166
|
+
hashOfferId,
|
167
|
+
hashTrustline,
|
168
|
+
hashTxTree,
|
169
|
+
hashStateTree,
|
170
|
+
hashLedger,
|
171
|
+
hashLedgerHeader,
|
172
|
+
hashEscrow,
|
173
|
+
hashPaymentChannel,
|
174
|
+
}
|
175
|
+
|
176
|
+
export {
|
177
|
+
getBalanceChanges,
|
178
|
+
dropsToXrp,
|
179
|
+
xrpToDrops,
|
180
|
+
hasNextPage,
|
181
|
+
rippleTimeToISOTime,
|
182
|
+
isoTimeToRippleTime,
|
183
|
+
rippleTimeToUnixTime,
|
184
|
+
unixTimeToRippleTime,
|
185
|
+
percentToQuality,
|
186
|
+
decimalToQuality,
|
187
|
+
percentToTransferRate,
|
188
|
+
decimalToTransferRate,
|
189
|
+
transferRateToDecimal,
|
190
|
+
qualityToDecimal,
|
191
|
+
isValidSecret,
|
192
|
+
isValidAddress,
|
193
|
+
hashes,
|
194
|
+
deriveKeypair,
|
195
|
+
deriveAddress,
|
196
|
+
deriveXAddress,
|
197
|
+
signPaymentChannelClaim,
|
198
|
+
verifyKeypairSignature,
|
199
|
+
verifyPaymentChannelClaim,
|
200
|
+
convertStringToHex,
|
201
|
+
convertHexToString,
|
202
|
+
classicAddressToXAddress,
|
203
|
+
xAddressToClassicAddress,
|
204
|
+
isValidXAddress,
|
205
|
+
isValidClassicAddress,
|
206
|
+
encodeSeed,
|
207
|
+
decodeSeed,
|
208
|
+
encodeAccountID,
|
209
|
+
decodeAccountID,
|
210
|
+
encodeNodePublic,
|
211
|
+
decodeNodePublic,
|
212
|
+
encodeAccountPublic,
|
213
|
+
decodeAccountPublic,
|
214
|
+
encodeXAddress,
|
215
|
+
decodeXAddress,
|
216
|
+
encode,
|
217
|
+
decode,
|
218
|
+
encodeForMultiSigning,
|
219
|
+
encodeForSigning,
|
220
|
+
encodeForSigningClaim,
|
221
|
+
getNFTokenID,
|
222
|
+
parseNFTokenID,
|
223
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers -- Doing hex string parsing. */
|
2
|
+
import BigNumber from 'bignumber.js'
|
3
|
+
import { encodeAccountID } from 'ripple-address-codec'
|
4
|
+
|
5
|
+
import { XrplError } from '../errors'
|
6
|
+
|
7
|
+
/**
|
8
|
+
* An issuer may issue several NFTs with the same taxon; to ensure that NFTs are
|
9
|
+
* spread across multiple pages we lightly mix the taxon up by using the sequence
|
10
|
+
* (which is not under the issuer's direct control) as the seed for a simple linear
|
11
|
+
* congruential generator.
|
12
|
+
*
|
13
|
+
* From the Hull-Dobell theorem we know that f(x)=(m*x+c) mod n will yield a
|
14
|
+
* permutation of [0, n) when n is a power of 2 if m is congruent to 1 mod 4 and
|
15
|
+
* c is odd. By doing a bitwise XOR with this permutation we can scramble/unscramble
|
16
|
+
* the taxon.
|
17
|
+
*
|
18
|
+
* The XLS-20d proposal fixes m = 384160001 and c = 2459.
|
19
|
+
* We then take the modulus of 2^32 which is 4294967296.
|
20
|
+
*
|
21
|
+
* @param taxon - The scrambled or unscrambled taxon (The XOR is both the encoding and decoding)
|
22
|
+
* @param tokenSeq - The account sequence when the token was minted. Used as a psuedorandom seed.
|
23
|
+
* @returns the opposite taxon. If the taxon was scrambled it becomes unscrambled, and vice versa.
|
24
|
+
*/
|
25
|
+
function unscrambleTaxon(taxon: number, tokenSeq: number): number {
|
26
|
+
/* eslint-disable no-bitwise -- XOR is part of the encode/decode scheme. */
|
27
|
+
return (taxon ^ (384160001 * tokenSeq + 2459)) % 4294967296
|
28
|
+
/* eslint-enable no-bitwise */
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Parses an NFTokenID into the information it is encoding.
|
33
|
+
*
|
34
|
+
* Example decoding:
|
35
|
+
*
|
36
|
+
* 000B 0539 C35B55AA096BA6D87A6E6C965A6534150DC56E5E 12C5D09E 0000000C
|
37
|
+
* +--- +--- +--------------------------------------- +------- +-------
|
38
|
+
* | | | | |
|
39
|
+
* | | | | `---> Sequence: 12
|
40
|
+
* | | | |
|
41
|
+
* | | | `---> Scrambled Taxon: 314,953,886
|
42
|
+
* | | | Unscrambled Taxon: 1337
|
43
|
+
* | | |
|
44
|
+
* | | `---> Issuer: rJoxBSzpXhPtAuqFmqxQtGKjA13jUJWthE
|
45
|
+
* | |
|
46
|
+
* | `---> TransferFee: 1337.0 bps or 13.37%
|
47
|
+
* |
|
48
|
+
* `---> Flags: 11 -> lsfBurnable, lsfOnlyXRP and lsfTransferable
|
49
|
+
*
|
50
|
+
* @param nftokenID - A hex string which identifies an NFToken on the ledger.
|
51
|
+
* @throws XrplError when given an invalid nftokenID.
|
52
|
+
* @returns a decoded nftokenID with all fields encoded within.
|
53
|
+
*/
|
54
|
+
export default function parseNFTokenID(nftokenID: string): {
|
55
|
+
NFTokenID: string
|
56
|
+
Flags: number
|
57
|
+
TransferFee: number
|
58
|
+
Issuer: string
|
59
|
+
Taxon: number
|
60
|
+
Sequence: number
|
61
|
+
} {
|
62
|
+
const expectedLength = 64
|
63
|
+
if (nftokenID.length !== expectedLength) {
|
64
|
+
throw new XrplError(`Attempting to parse a nftokenID with length ${nftokenID.length}
|
65
|
+
, but expected a token with length ${expectedLength}`)
|
66
|
+
}
|
67
|
+
|
68
|
+
const scrambledTaxon = new BigNumber(
|
69
|
+
nftokenID.substring(48, 56),
|
70
|
+
16,
|
71
|
+
).toNumber()
|
72
|
+
const sequence = new BigNumber(nftokenID.substring(56, 64), 16).toNumber()
|
73
|
+
|
74
|
+
const NFTokenIDData = {
|
75
|
+
NFTokenID: nftokenID,
|
76
|
+
Flags: new BigNumber(nftokenID.substring(0, 4), 16).toNumber(),
|
77
|
+
TransferFee: new BigNumber(nftokenID.substring(4, 8), 16).toNumber(),
|
78
|
+
Issuer: encodeAccountID(Buffer.from(nftokenID.substring(8, 48), 'hex')),
|
79
|
+
Taxon: unscrambleTaxon(scrambledTaxon, sequence),
|
80
|
+
Sequence: sequence,
|
81
|
+
}
|
82
|
+
|
83
|
+
return NFTokenIDData
|
84
|
+
}
|