xrpl 2.14.0 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/xrpl-latest-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +15451 -74357
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/authorizeChannel.d.ts +3 -0
- package/dist/npm/Wallet/authorizeChannel.d.ts.map +1 -0
- package/dist/npm/Wallet/authorizeChannel.js +14 -0
- package/dist/npm/Wallet/authorizeChannel.js.map +1 -0
- package/dist/npm/Wallet/defaultFaucets.js +1 -1
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/Wallet/fundWallet.d.ts +17 -3
- package/dist/npm/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/Wallet/fundWallet.js +53 -78
- package/dist/npm/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/Wallet/index.d.ts.map +1 -1
- package/dist/npm/Wallet/index.js +24 -23
- package/dist/npm/Wallet/index.js.map +1 -1
- package/dist/npm/Wallet/rfc1751.d.ts +1 -2
- package/dist/npm/Wallet/rfc1751.d.ts.map +1 -1
- package/dist/npm/Wallet/rfc1751.js +21 -5
- package/dist/npm/Wallet/rfc1751.js.map +1 -1
- package/dist/npm/Wallet/signer.d.ts +2 -4
- package/dist/npm/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/Wallet/signer.js +19 -14
- package/dist/npm/Wallet/signer.js.map +1 -1
- package/dist/npm/Wallet/walletFromSecretNumbers.js +2 -2
- package/dist/npm/Wallet/walletFromSecretNumbers.js.map +1 -1
- package/dist/npm/client/RequestManager.d.ts +3 -2
- package/dist/npm/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/client/RequestManager.js +25 -1
- package/dist/npm/client/RequestManager.js.map +1 -1
- package/dist/npm/client/connection.d.ts +8 -11
- package/dist/npm/client/connection.d.ts.map +1 -1
- package/dist/npm/client/connection.js +11 -57
- package/dist/npm/client/connection.js.map +1 -1
- package/dist/npm/client/index.d.ts +56 -79
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +155 -42
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts +4 -2
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js.map +1 -1
- package/dist/npm/errors.d.ts.map +1 -1
- package/dist/npm/errors.js +1 -2
- package/dist/npm/errors.js.map +1 -1
- package/dist/npm/index.d.ts +1 -1
- package/dist/npm/index.d.ts.map +1 -1
- package/dist/npm/index.js +1 -3
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.js +1 -1
- package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/models/ledger/Ledger.d.ts +2 -2
- package/dist/npm/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/models/ledger/Offer.js +1 -1
- package/dist/npm/models/ledger/Offer.js.map +1 -1
- package/dist/npm/models/ledger/RippleState.js +1 -1
- package/dist/npm/models/ledger/RippleState.js.map +1 -1
- package/dist/npm/models/ledger/SignerList.js +1 -1
- package/dist/npm/models/ledger/SignerList.js.map +1 -1
- package/dist/npm/models/methods/index.d.ts +12 -1
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledger.d.ts +35 -7
- package/dist/npm/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/models/methods/submit.d.ts +2 -2
- package/dist/npm/models/methods/submit.d.ts.map +1 -1
- package/dist/npm/models/methods/subscribe.d.ts +3 -0
- package/dist/npm/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/models/methods/tx.d.ts +2 -3
- package/dist/npm/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.js +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenAcceptOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenAcceptOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenAcceptOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.js +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.js +1 -1
- package/dist/npm/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.js +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -1
- package/dist/npm/models/transactions/accountSet.js +2 -2
- package/dist/npm/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/models/transactions/enableAmendment.js +1 -1
- package/dist/npm/models/transactions/enableAmendment.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +1 -1
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/metadata.d.ts +9 -1
- package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/models/transactions/metadata.js.map +1 -1
- package/dist/npm/models/transactions/offerCreate.js +1 -1
- package/dist/npm/models/transactions/offerCreate.js.map +1 -1
- package/dist/npm/models/transactions/payment.d.ts +5 -0
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/payment.js +1 -1
- package/dist/npm/models/transactions/payment.js.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +6 -4
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/transactions/trustSet.js +1 -1
- package/dist/npm/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/snippets/src/bridgeTransfer.js +2 -2
- package/dist/npm/snippets/src/bridgeTransfer.js.map +1 -1
- package/dist/npm/snippets/src/getTransaction.js +1 -1
- package/dist/npm/snippets/src/getTransaction.js.map +1 -1
- package/dist/npm/snippets/src/paths.js +2 -3
- package/dist/npm/snippets/src/paths.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/authorizeChannel.d.ts +3 -0
- package/dist/npm/src/Wallet/authorizeChannel.d.ts.map +1 -0
- package/dist/npm/src/Wallet/authorizeChannel.js +14 -0
- package/dist/npm/src/Wallet/authorizeChannel.js.map +1 -0
- package/dist/npm/src/Wallet/defaultFaucets.js +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.d.ts +17 -3
- package/dist/npm/src/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.js +53 -78
- package/dist/npm/src/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/src/Wallet/index.d.ts.map +1 -1
- package/dist/npm/src/Wallet/index.js +24 -23
- package/dist/npm/src/Wallet/index.js.map +1 -1
- package/dist/npm/src/Wallet/rfc1751.d.ts +1 -2
- package/dist/npm/src/Wallet/rfc1751.d.ts.map +1 -1
- package/dist/npm/src/Wallet/rfc1751.js +21 -5
- package/dist/npm/src/Wallet/rfc1751.js.map +1 -1
- package/dist/npm/src/Wallet/signer.d.ts +2 -4
- package/dist/npm/src/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/src/Wallet/signer.js +19 -14
- package/dist/npm/src/Wallet/signer.js.map +1 -1
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js +2 -2
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -1
- package/dist/npm/src/client/RequestManager.d.ts +3 -2
- package/dist/npm/src/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/src/client/RequestManager.js +25 -1
- package/dist/npm/src/client/RequestManager.js.map +1 -1
- package/dist/npm/src/client/connection.d.ts +8 -11
- package/dist/npm/src/client/connection.d.ts.map +1 -1
- package/dist/npm/src/client/connection.js +11 -57
- package/dist/npm/src/client/connection.js.map +1 -1
- package/dist/npm/src/client/index.d.ts +56 -79
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +155 -42
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/client/partialPayment.d.ts +4 -2
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js.map +1 -1
- package/dist/npm/src/errors.d.ts.map +1 -1
- package/dist/npm/src/errors.js +1 -2
- package/dist/npm/src/errors.js.map +1 -1
- package/dist/npm/src/index.d.ts +1 -1
- package/dist/npm/src/index.d.ts.map +1 -1
- package/dist/npm/src/index.js +1 -3
- package/dist/npm/src/index.js.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/src/models/ledger/Ledger.d.ts +2 -2
- package/dist/npm/src/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Offer.js +1 -1
- package/dist/npm/src/models/ledger/Offer.js.map +1 -1
- package/dist/npm/src/models/ledger/RippleState.js +1 -1
- package/dist/npm/src/models/ledger/RippleState.js.map +1 -1
- package/dist/npm/src/models/ledger/SignerList.js +1 -1
- package/dist/npm/src/models/ledger/SignerList.js.map +1 -1
- package/dist/npm/src/models/methods/index.d.ts +12 -1
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledger.d.ts +35 -7
- package/dist/npm/src/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/src/models/methods/submit.d.ts +2 -2
- package/dist/npm/src/models/methods/submit.d.ts.map +1 -1
- package/dist/npm/src/models/methods/subscribe.d.ts +3 -0
- package/dist/npm/src/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/src/models/methods/tx.d.ts +2 -3
- package/dist/npm/src/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.js +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/src/models/transactions/XChainModifyBridge.js +1 -1
- package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -1
- package/dist/npm/src/models/transactions/accountSet.js +2 -2
- package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/src/models/transactions/enableAmendment.js +1 -1
- package/dist/npm/src/models/transactions/enableAmendment.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +1 -1
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/metadata.d.ts +9 -1
- package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/metadata.js.map +1 -1
- package/dist/npm/src/models/transactions/offerCreate.js +1 -1
- package/dist/npm/src/models/transactions/offerCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/payment.d.ts +5 -0
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/payment.js +1 -1
- package/dist/npm/src/models/transactions/payment.js.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +6 -4
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/transactions/trustSet.js +1 -1
- package/dist/npm/src/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +6 -2
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +9 -28
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/src/sugar/balances.d.ts +2 -17
- package/dist/npm/src/sugar/balances.d.ts.map +1 -1
- package/dist/npm/src/sugar/balances.js +2 -60
- package/dist/npm/src/sugar/balances.js.map +1 -1
- package/dist/npm/src/sugar/getOrderbook.d.ts +19 -5
- package/dist/npm/src/sugar/getOrderbook.d.ts.map +1 -1
- package/dist/npm/src/sugar/getOrderbook.js +72 -53
- package/dist/npm/src/sugar/getOrderbook.js.map +1 -1
- package/dist/npm/src/sugar/index.d.ts +0 -4
- package/dist/npm/src/sugar/index.d.ts.map +1 -1
- package/dist/npm/src/sugar/index.js +0 -13
- package/dist/npm/src/sugar/index.js.map +1 -1
- package/dist/npm/src/sugar/submit.d.ts +7 -11
- package/dist/npm/src/sugar/submit.d.ts.map +1 -1
- package/dist/npm/src/sugar/submit.js +5 -22
- package/dist/npm/src/sugar/submit.js.map +1 -1
- package/dist/npm/src/utils/collections.d.ts +5 -0
- package/dist/npm/src/utils/collections.d.ts.map +1 -0
- package/dist/npm/src/utils/collections.js +24 -0
- package/dist/npm/src/utils/collections.js.map +1 -0
- package/dist/npm/src/utils/getBalanceChanges.d.ts.map +1 -1
- package/dist/npm/src/utils/getBalanceChanges.js +3 -4
- package/dist/npm/src/utils/getBalanceChanges.js.map +1 -1
- package/dist/npm/src/utils/getNFTokenID.d.ts.map +1 -1
- package/dist/npm/src/utils/getNFTokenID.js +8 -8
- package/dist/npm/src/utils/getNFTokenID.js.map +1 -1
- package/dist/npm/src/utils/hashes/SHAMap/node.js +1 -1
- package/dist/npm/src/utils/hashes/SHAMap/node.js.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.d.ts +1 -2
- package/dist/npm/src/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.js +7 -7
- package/dist/npm/src/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/src/utils/hashes/index.d.ts.map +1 -1
- package/dist/npm/src/utils/hashes/index.js +3 -2
- package/dist/npm/src/utils/hashes/index.js.map +1 -1
- package/dist/npm/src/utils/hashes/sha512Half.d.ts.map +1 -1
- package/dist/npm/src/utils/hashes/sha512Half.js +4 -7
- package/dist/npm/src/utils/hashes/sha512Half.js.map +1 -1
- package/dist/npm/src/utils/index.d.ts.map +1 -1
- package/dist/npm/src/utils/index.js +6 -29
- package/dist/npm/src/utils/index.js.map +1 -1
- package/dist/npm/src/utils/parseNFTokenID.d.ts.map +1 -1
- package/dist/npm/src/utils/parseNFTokenID.js +2 -1
- package/dist/npm/src/utils/parseNFTokenID.js.map +1 -1
- package/dist/npm/src/utils/stringConversion.d.ts +1 -2
- package/dist/npm/src/utils/stringConversion.d.ts.map +1 -1
- package/dist/npm/src/utils/stringConversion.js +3 -2
- package/dist/npm/src/utils/stringConversion.js.map +1 -1
- package/dist/npm/src/utils/xrpConversion.d.ts +1 -1
- package/dist/npm/src/utils/xrpConversion.js +1 -1
- package/dist/npm/src/utils/xrpConversion.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts +6 -2
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +9 -28
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/balances.d.ts +2 -17
- package/dist/npm/sugar/balances.d.ts.map +1 -1
- package/dist/npm/sugar/balances.js +2 -60
- package/dist/npm/sugar/balances.js.map +1 -1
- package/dist/npm/sugar/getOrderbook.d.ts +19 -5
- package/dist/npm/sugar/getOrderbook.d.ts.map +1 -1
- package/dist/npm/sugar/getOrderbook.js +72 -53
- package/dist/npm/sugar/getOrderbook.js.map +1 -1
- package/dist/npm/sugar/index.d.ts +0 -4
- package/dist/npm/sugar/index.d.ts.map +1 -1
- package/dist/npm/sugar/index.js +0 -13
- package/dist/npm/sugar/index.js.map +1 -1
- package/dist/npm/sugar/submit.d.ts +7 -11
- package/dist/npm/sugar/submit.d.ts.map +1 -1
- package/dist/npm/sugar/submit.js +5 -22
- package/dist/npm/sugar/submit.js.map +1 -1
- package/dist/npm/utils/collections.d.ts +5 -0
- package/dist/npm/utils/collections.d.ts.map +1 -0
- package/dist/npm/utils/collections.js +24 -0
- package/dist/npm/utils/collections.js.map +1 -0
- package/dist/npm/utils/getBalanceChanges.d.ts.map +1 -1
- package/dist/npm/utils/getBalanceChanges.js +3 -4
- package/dist/npm/utils/getBalanceChanges.js.map +1 -1
- package/dist/npm/utils/getNFTokenID.d.ts.map +1 -1
- package/dist/npm/utils/getNFTokenID.js +8 -8
- package/dist/npm/utils/getNFTokenID.js.map +1 -1
- package/dist/npm/utils/hashes/SHAMap/node.js +1 -1
- package/dist/npm/utils/hashes/SHAMap/node.js.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.d.ts +1 -2
- package/dist/npm/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.js +7 -7
- package/dist/npm/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/utils/hashes/index.d.ts.map +1 -1
- package/dist/npm/utils/hashes/index.js +3 -2
- package/dist/npm/utils/hashes/index.js.map +1 -1
- package/dist/npm/utils/hashes/sha512Half.d.ts.map +1 -1
- package/dist/npm/utils/hashes/sha512Half.js +4 -7
- package/dist/npm/utils/hashes/sha512Half.js.map +1 -1
- package/dist/npm/utils/index.d.ts.map +1 -1
- package/dist/npm/utils/index.js +6 -29
- package/dist/npm/utils/index.js.map +1 -1
- package/dist/npm/utils/parseNFTokenID.d.ts.map +1 -1
- package/dist/npm/utils/parseNFTokenID.js +2 -1
- package/dist/npm/utils/parseNFTokenID.js.map +1 -1
- package/dist/npm/utils/stringConversion.d.ts +1 -2
- package/dist/npm/utils/stringConversion.d.ts.map +1 -1
- package/dist/npm/utils/stringConversion.js +3 -2
- package/dist/npm/utils/stringConversion.js.map +1 -1
- package/dist/npm/utils/xrpConversion.d.ts +1 -1
- package/dist/npm/utils/xrpConversion.js +1 -1
- package/dist/npm/utils/xrpConversion.js.map +1 -1
- package/package.json +23 -25
- package/src/Wallet/authorizeChannel.ts +26 -0
- package/src/Wallet/fundWallet.ts +153 -214
- package/src/Wallet/index.ts +28 -25
- package/src/Wallet/rfc1751.ts +45 -16
- package/src/Wallet/signer.ts +34 -44
- package/src/Wallet/walletFromSecretNumbers.ts +1 -1
- package/src/client/RequestManager.ts +40 -14
- package/src/client/connection.ts +26 -93
- package/src/client/index.ts +706 -274
- package/src/client/partialPayment.ts +16 -14
- package/src/errors.ts +1 -3
- package/src/index.ts +1 -3
- package/src/models/ledger/Ledger.ts +3 -9
- package/src/models/methods/index.ts +177 -0
- package/src/models/methods/ledger.ts +149 -20
- package/src/models/methods/submit.ts +2 -2
- package/src/models/methods/subscribe.ts +36 -0
- package/src/models/methods/tx.ts +3 -5
- package/src/models/transactions/NFTokenAcceptOffer.ts +6 -0
- package/src/models/transactions/NFTokenCancelOffer.ts +6 -0
- package/src/models/transactions/NFTokenCreateOffer.ts +6 -0
- package/src/models/transactions/NFTokenMint.ts +6 -0
- package/src/models/transactions/index.ts +1 -0
- package/src/models/transactions/metadata.ts +31 -1
- package/src/models/transactions/payment.ts +6 -0
- package/src/models/transactions/transaction.ts +21 -5
- package/src/sugar/autofill.ts +84 -88
- package/src/sugar/balances.ts +8 -116
- package/src/sugar/getOrderbook.ts +138 -61
- package/src/sugar/index.ts +0 -8
- package/src/sugar/submit.ts +128 -140
- package/src/utils/collections.ts +57 -0
- package/src/utils/getBalanceChanges.ts +2 -3
- package/src/utils/getNFTokenID.ts +18 -16
- package/src/utils/hashes/hashLedger.ts +7 -9
- package/src/utils/hashes/index.ts +3 -2
- package/src/utils/hashes/sha512Half.ts +4 -7
- package/src/utils/index.ts +12 -6
- package/src/utils/parseNFTokenID.ts +2 -1
- package/src/utils/stringConversion.ts +11 -6
- package/src/utils/xrpConversion.ts +2 -2
- package/dist/npm/client/BroadcastClient.d.ts +0 -7
- package/dist/npm/client/BroadcastClient.d.ts.map +0 -1
- package/dist/npm/client/BroadcastClient.js +0 -49
- package/dist/npm/client/BroadcastClient.js.map +0 -1
- package/dist/npm/client/WSWrapper.d.ts +0 -25
- package/dist/npm/client/WSWrapper.d.ts.map +0 -1
- package/dist/npm/client/WSWrapper.js +0 -44
- package/dist/npm/client/WSWrapper.js.map +0 -1
- package/dist/npm/src/client/BroadcastClient.d.ts +0 -7
- package/dist/npm/src/client/BroadcastClient.d.ts.map +0 -1
- package/dist/npm/src/client/BroadcastClient.js +0 -49
- package/dist/npm/src/client/BroadcastClient.js.map +0 -1
- package/dist/npm/src/client/WSWrapper.d.ts +0 -25
- package/dist/npm/src/client/WSWrapper.d.ts.map +0 -1
- package/dist/npm/src/client/WSWrapper.js +0 -44
- package/dist/npm/src/client/WSWrapper.js.map +0 -1
- package/dist/npm/src/sugar/getLedgerIndex.d.ts +0 -3
- package/dist/npm/src/sugar/getLedgerIndex.d.ts.map +0 -1
- package/dist/npm/src/sugar/getLedgerIndex.js +0 -22
- package/dist/npm/src/sugar/getLedgerIndex.js.map +0 -1
- package/dist/npm/sugar/getLedgerIndex.d.ts +0 -3
- package/dist/npm/sugar/getLedgerIndex.d.ts.map +0 -1
- package/dist/npm/sugar/getLedgerIndex.js +0 -22
- package/dist/npm/sugar/getLedgerIndex.js.map +0 -1
- package/src/client/BroadcastClient.ts +0 -84
- package/src/client/WSWrapper.ts +0 -106
- package/src/sugar/getLedgerIndex.ts +0 -15
@@ -1,5 +1,22 @@
|
|
1
1
|
import { Amount } from '../common'
|
2
2
|
|
3
|
+
import { BaseTransaction } from './common'
|
4
|
+
import {
|
5
|
+
NFTokenAcceptOffer,
|
6
|
+
NFTokenAcceptOfferMetadata,
|
7
|
+
} from './NFTokenAcceptOffer'
|
8
|
+
import {
|
9
|
+
NFTokenCancelOffer,
|
10
|
+
NFTokenCancelOfferMetadata,
|
11
|
+
} from './NFTokenCancelOffer'
|
12
|
+
import {
|
13
|
+
NFTokenCreateOffer,
|
14
|
+
NFTokenCreateOfferMetadata,
|
15
|
+
} from './NFTokenCreateOffer'
|
16
|
+
import { NFTokenMint, NFTokenMintMetadata } from './NFTokenMint'
|
17
|
+
import { Payment, PaymentMetadata } from './payment'
|
18
|
+
import type { Transaction } from './transaction'
|
19
|
+
|
3
20
|
export interface CreatedNode {
|
4
21
|
CreatedNode: {
|
5
22
|
LedgerEntryType: string
|
@@ -59,7 +76,7 @@ export function isDeletedNode(node: Node): node is DeletedNode {
|
|
59
76
|
return Object.prototype.hasOwnProperty.call(node, `DeletedNode`)
|
60
77
|
}
|
61
78
|
|
62
|
-
export interface
|
79
|
+
export interface TransactionMetadataBase {
|
63
80
|
AffectedNodes: Node[]
|
64
81
|
DeliveredAmount?: Amount
|
65
82
|
// "unavailable" possible for transactions before 2014-01-20
|
@@ -67,3 +84,16 @@ export interface TransactionMetadata {
|
|
67
84
|
TransactionIndex: number
|
68
85
|
TransactionResult: string
|
69
86
|
}
|
87
|
+
|
88
|
+
export type TransactionMetadata<T extends BaseTransaction = Transaction> =
|
89
|
+
T extends Payment
|
90
|
+
? PaymentMetadata
|
91
|
+
: T extends NFTokenMint
|
92
|
+
? NFTokenMintMetadata
|
93
|
+
: T extends NFTokenCreateOffer
|
94
|
+
? NFTokenCreateOfferMetadata
|
95
|
+
: T extends NFTokenAcceptOffer
|
96
|
+
? NFTokenAcceptOfferMetadata
|
97
|
+
: T extends NFTokenCancelOffer
|
98
|
+
? NFTokenCancelOfferMetadata
|
99
|
+
: TransactionMetadataBase
|
@@ -13,6 +13,7 @@ import {
|
|
13
13
|
isNumber,
|
14
14
|
Account,
|
15
15
|
} from './common'
|
16
|
+
import type { TransactionMetadataBase } from './metadata'
|
16
17
|
|
17
18
|
/**
|
18
19
|
* Enum representing values for Payment Transaction Flags.
|
@@ -151,6 +152,11 @@ export interface Payment extends BaseTransaction {
|
|
151
152
|
Flags?: number | PaymentFlagsInterface
|
152
153
|
}
|
153
154
|
|
155
|
+
export interface PaymentMetadata extends TransactionMetadataBase {
|
156
|
+
DeliveredAmount?: Amount
|
157
|
+
delivered_amount?: Amount | 'unavailable'
|
158
|
+
}
|
159
|
+
|
154
160
|
/**
|
155
161
|
* Verify the form and type of a Payment at runtime.
|
156
162
|
*
|
@@ -18,7 +18,7 @@ import { CheckCancel, validateCheckCancel } from './checkCancel'
|
|
18
18
|
import { CheckCash, validateCheckCash } from './checkCash'
|
19
19
|
import { CheckCreate, validateCheckCreate } from './checkCreate'
|
20
20
|
import { Clawback, validateClawback } from './clawback'
|
21
|
-
import { isIssuedCurrency } from './common'
|
21
|
+
import { BaseTransaction, isIssuedCurrency } from './common'
|
22
22
|
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
|
23
23
|
import { DIDDelete, validateDIDDelete } from './DIDDelete'
|
24
24
|
import { DIDSet, validateDIDSet } from './DIDSet'
|
@@ -90,9 +90,11 @@ import {
|
|
90
90
|
} from './XChainModifyBridge'
|
91
91
|
|
92
92
|
/**
|
93
|
+
* Transactions that can be submitted by clients
|
94
|
+
*
|
93
95
|
* @category Transaction Models
|
94
96
|
*/
|
95
|
-
export type
|
97
|
+
export type SubmittableTransaction =
|
96
98
|
| AMMBid
|
97
99
|
| AMMCreate
|
98
100
|
| AMMDelete
|
@@ -135,14 +137,28 @@ export type Transaction =
|
|
135
137
|
| XChainCreateClaimID
|
136
138
|
| XChainModifyBridge
|
137
139
|
|
140
|
+
/**
|
141
|
+
* Transactions that can only be created by validators.
|
142
|
+
*
|
143
|
+
* @category Transaction Models
|
144
|
+
*/
|
138
145
|
export type PseudoTransaction = EnableAmendment | SetFee | UNLModify
|
139
146
|
|
147
|
+
/**
|
148
|
+
* All transactions that can live on the XRPL
|
149
|
+
*
|
150
|
+
* @category Transaction Models
|
151
|
+
*/
|
152
|
+
export type Transaction = SubmittableTransaction | PseudoTransaction
|
153
|
+
|
140
154
|
/**
|
141
155
|
* @category Transaction Models
|
142
156
|
*/
|
143
|
-
export interface TransactionAndMetadata
|
144
|
-
|
145
|
-
|
157
|
+
export interface TransactionAndMetadata<
|
158
|
+
T extends BaseTransaction = Transaction,
|
159
|
+
> {
|
160
|
+
transaction: T
|
161
|
+
metadata: TransactionMetadata<T>
|
146
162
|
}
|
147
163
|
|
148
164
|
/**
|
package/src/sugar/autofill.ts
CHANGED
@@ -5,7 +5,6 @@ import type { Client } from '..'
|
|
5
5
|
import { ValidationError, XrplError } from '../errors'
|
6
6
|
import { AccountInfoRequest, AccountObjectsRequest } from '../models/methods'
|
7
7
|
import { Transaction } from '../models/transactions'
|
8
|
-
import { setTransactionFlagsToNumber } from '../models/utils/flags'
|
9
8
|
import { xrpToDrops } from '../utils'
|
10
9
|
|
11
10
|
import getFeeXrp from './getFeeXrp'
|
@@ -19,83 +18,6 @@ const LEDGER_OFFSET = 20
|
|
19
18
|
const RESTRICTED_NETWORKS = 1024
|
20
19
|
const REQUIRED_NETWORKID_VERSION = '1.11.0'
|
21
20
|
const HOOKS_TESTNET_ID = 21338
|
22
|
-
interface ClassicAccountAndTag {
|
23
|
-
classicAccount: string
|
24
|
-
tag: number | false | undefined
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Autofills fields in a transaction. This will set `Sequence`, `Fee`,
|
29
|
-
* `lastLedgerSequence` according to the current state of the server this Client
|
30
|
-
* is connected to. It also converts all X-Addresses to classic addresses and
|
31
|
-
* flags interfaces into numbers.
|
32
|
-
*
|
33
|
-
* @example
|
34
|
-
*
|
35
|
-
* ```ts
|
36
|
-
* const { Client } = require('xrpl')
|
37
|
-
*
|
38
|
-
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
39
|
-
*
|
40
|
-
* async function createAndAutofillTransaction() {
|
41
|
-
* const transaction = {
|
42
|
-
* TransactionType: 'Payment',
|
43
|
-
* Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
44
|
-
* Destination: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
45
|
-
* Amount: '10000000' // 10 XRP in drops (1/1,000,000th of an XRP)
|
46
|
-
* }
|
47
|
-
*
|
48
|
-
* try {
|
49
|
-
* const autofilledTransaction = await client.autofill(transaction)
|
50
|
-
* console.log(autofilledTransaction)
|
51
|
-
* } catch (error) {
|
52
|
-
* console.error(`Failed to autofill transaction: ${error}`)
|
53
|
-
* }
|
54
|
-
* }
|
55
|
-
*
|
56
|
-
* createAndAutofillTransaction()
|
57
|
-
* ```
|
58
|
-
*
|
59
|
-
* Autofill helps fill in fields which should be included in a transaction, but can be determined automatically
|
60
|
-
* such as `LastLedgerSequence` and `Fee`. If you override one of the fields `autofill` changes, your explicit
|
61
|
-
* values will be used instead. By default, this is done as part of `submit` and `submitAndWait` when you pass
|
62
|
-
* in an unsigned transaction along with your wallet to be submitted.
|
63
|
-
*
|
64
|
-
* @param this - A client.
|
65
|
-
* @param transaction - A {@link Transaction} in JSON format
|
66
|
-
* @param signersCount - The expected number of signers for this transaction.
|
67
|
-
* Only used for multisigned transactions.
|
68
|
-
* @returns The autofilled transaction.
|
69
|
-
*/
|
70
|
-
async function autofill<T extends Transaction>(
|
71
|
-
this: Client,
|
72
|
-
transaction: T,
|
73
|
-
signersCount?: number,
|
74
|
-
): Promise<T> {
|
75
|
-
const tx = { ...transaction }
|
76
|
-
|
77
|
-
setValidAddresses(tx)
|
78
|
-
|
79
|
-
setTransactionFlagsToNumber(tx)
|
80
|
-
const promises: Array<Promise<void>> = []
|
81
|
-
if (tx.NetworkID == null) {
|
82
|
-
tx.NetworkID = txNeedsNetworkID(this) ? this.networkID : undefined
|
83
|
-
}
|
84
|
-
if (tx.Sequence == null) {
|
85
|
-
promises.push(setNextValidSequenceNumber(this, tx))
|
86
|
-
}
|
87
|
-
if (tx.Fee == null) {
|
88
|
-
promises.push(calculateFeePerTransactionType(this, tx, signersCount))
|
89
|
-
}
|
90
|
-
if (tx.LastLedgerSequence == null) {
|
91
|
-
promises.push(setLatestValidatedLedgerSequence(this, tx))
|
92
|
-
}
|
93
|
-
if (tx.TransactionType === 'AccountDelete') {
|
94
|
-
promises.push(checkAccountDeleteBlockers(this, tx))
|
95
|
-
}
|
96
|
-
|
97
|
-
return Promise.all(promises).then(() => tx)
|
98
|
-
}
|
99
21
|
|
100
22
|
/**
|
101
23
|
* Determines whether the source rippled version is not later than the target rippled version.
|
@@ -171,7 +93,7 @@ function isNotLaterRippledVersion(source: string, target: string): boolean {
|
|
171
93
|
* @param client -- The connected client.
|
172
94
|
* @returns True if required networkID, false otherwise.
|
173
95
|
*/
|
174
|
-
function txNeedsNetworkID(client: Client): boolean {
|
96
|
+
export function txNeedsNetworkID(client: Client): boolean {
|
175
97
|
if (
|
176
98
|
client.networkID !== undefined &&
|
177
99
|
client.networkID > RESTRICTED_NETWORKS
|
@@ -190,7 +112,17 @@ function txNeedsNetworkID(client: Client): boolean {
|
|
190
112
|
return false
|
191
113
|
}
|
192
114
|
|
193
|
-
|
115
|
+
interface ClassicAccountAndTag {
|
116
|
+
classicAccount: string
|
117
|
+
tag: number | false | undefined
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Sets valid addresses for the transaction.
|
122
|
+
*
|
123
|
+
* @param tx - The transaction object.
|
124
|
+
*/
|
125
|
+
export function setValidAddresses(tx: Transaction): void {
|
194
126
|
validateAccountAddress(tx, 'Account', 'SourceTag')
|
195
127
|
// eslint-disable-next-line @typescript-eslint/dot-notation -- Destination can exist on Transaction
|
196
128
|
if (tx['Destination'] != null) {
|
@@ -206,6 +138,14 @@ function setValidAddresses(tx: Transaction): void {
|
|
206
138
|
convertToClassicAddress(tx, 'RegularKey')
|
207
139
|
}
|
208
140
|
|
141
|
+
/**
|
142
|
+
* Validates the account address in a transaction object.
|
143
|
+
*
|
144
|
+
* @param tx - The transaction object.
|
145
|
+
* @param accountField - The field name for the account address in the transaction object.
|
146
|
+
* @param tagField - The field name for the tag in the transaction object.
|
147
|
+
* @throws {ValidationError} If the tag field does not match the tag of the account address.
|
148
|
+
*/
|
209
149
|
function validateAccountAddress(
|
210
150
|
tx: Transaction,
|
211
151
|
accountField: string,
|
@@ -227,6 +167,14 @@ function validateAccountAddress(
|
|
227
167
|
}
|
228
168
|
}
|
229
169
|
|
170
|
+
/**
|
171
|
+
* Retrieves the classic account and tag from an account address.
|
172
|
+
*
|
173
|
+
* @param Account - The account address.
|
174
|
+
* @param [expectedTag] - The expected tag for the account address.
|
175
|
+
* @returns The classic account and tag.
|
176
|
+
* @throws {ValidationError} If the address includes a tag that does not match the tag specified in the transaction.
|
177
|
+
*/
|
230
178
|
function getClassicAccountAndTag(
|
231
179
|
Account: string,
|
232
180
|
expectedTag?: number,
|
@@ -249,6 +197,12 @@ function getClassicAccountAndTag(
|
|
249
197
|
}
|
250
198
|
}
|
251
199
|
|
200
|
+
/**
|
201
|
+
* Converts the specified field of a transaction object to a classic address format.
|
202
|
+
*
|
203
|
+
* @param tx - The transaction object.
|
204
|
+
* @param fieldName - The name of the field to convert.export
|
205
|
+
*/
|
252
206
|
function convertToClassicAddress(tx: Transaction, fieldName: string): void {
|
253
207
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- assignment is safe
|
254
208
|
const account = tx[fieldName]
|
@@ -259,7 +213,15 @@ function convertToClassicAddress(tx: Transaction, fieldName: string): void {
|
|
259
213
|
}
|
260
214
|
}
|
261
215
|
|
262
|
-
|
216
|
+
/**
|
217
|
+
* Sets the next valid sequence number for a transaction.
|
218
|
+
*
|
219
|
+
* @param client - The client object used for making requests.
|
220
|
+
* @param tx - The transaction object for which the sequence number needs to be set.
|
221
|
+
* @returns A Promise that resolves when the sequence number is set.
|
222
|
+
* @throws {Error} If there is an error retrieving the account information.
|
223
|
+
*/
|
224
|
+
export async function setNextValidSequenceNumber(
|
263
225
|
client: Client,
|
264
226
|
tx: Transaction,
|
265
227
|
): Promise<void> {
|
@@ -273,7 +235,14 @@ async function setNextValidSequenceNumber(
|
|
273
235
|
tx.Sequence = data.result.account_data.Sequence
|
274
236
|
}
|
275
237
|
|
276
|
-
|
238
|
+
/**
|
239
|
+
* Fetches the account deletion fee from the server state using the provided client.
|
240
|
+
*
|
241
|
+
* @param client - The client object used to make the request.
|
242
|
+
* @returns A Promise that resolves to the account deletion fee as a BigNumber.
|
243
|
+
* @throws {Error} Throws an error if the account deletion fee cannot be fetched.
|
244
|
+
*/
|
245
|
+
async function fetchAccountDeleteFee(client: Client): Promise<BigNumber> {
|
277
246
|
const response = await client.request({ command: 'server_state' })
|
278
247
|
const fee = response.result.state.validated_ledger?.reserve_inc
|
279
248
|
|
@@ -284,7 +253,15 @@ async function fetchOwnerReserveFee(client: Client): Promise<BigNumber> {
|
|
284
253
|
return new BigNumber(fee)
|
285
254
|
}
|
286
255
|
|
287
|
-
|
256
|
+
/**
|
257
|
+
* Calculates the fee per transaction type.
|
258
|
+
*
|
259
|
+
* @param client - The client object.
|
260
|
+
* @param tx - The transaction object.
|
261
|
+
* @param [signersCount=0] - The number of signers (default is 0). Only used for multisigning.
|
262
|
+
* @returns A promise that resolves with void. Modifies the `tx` parameter to give it the calculated fee.
|
263
|
+
*/
|
264
|
+
export async function calculateFeePerTransactionType(
|
288
265
|
client: Client,
|
289
266
|
tx: Transaction,
|
290
267
|
signersCount = 0,
|
@@ -309,7 +286,7 @@ async function calculateFeePerTransactionType(
|
|
309
286
|
tx.TransactionType === 'AccountDelete' ||
|
310
287
|
tx.TransactionType === 'AMMCreate'
|
311
288
|
) {
|
312
|
-
baseFee = await
|
289
|
+
baseFee = await fetchAccountDeleteFee(client)
|
313
290
|
}
|
314
291
|
|
315
292
|
/*
|
@@ -331,11 +308,25 @@ async function calculateFeePerTransactionType(
|
|
331
308
|
tx.Fee = totalFee.dp(0, BigNumber.ROUND_CEIL).toString(10)
|
332
309
|
}
|
333
310
|
|
311
|
+
/**
|
312
|
+
* Scales the given value by multiplying it with the provided multiplier.
|
313
|
+
*
|
314
|
+
* @param value - The value to be scaled.
|
315
|
+
* @param multiplier - The multiplier to scale the value.
|
316
|
+
* @returns The scaled value as a string.
|
317
|
+
*/
|
334
318
|
function scaleValue(value, multiplier): string {
|
335
319
|
return new BigNumber(value).times(multiplier).toString()
|
336
320
|
}
|
337
321
|
|
338
|
-
|
322
|
+
/**
|
323
|
+
* Sets the latest validated ledger sequence for the transaction.
|
324
|
+
*
|
325
|
+
* @param client - The client object.
|
326
|
+
* @param tx - The transaction object.
|
327
|
+
* @returns A promise that resolves with void. Modifies the `tx` parameter setting `LastLedgerSequence`.
|
328
|
+
*/
|
329
|
+
export async function setLatestValidatedLedgerSequence(
|
339
330
|
client: Client,
|
340
331
|
tx: Transaction,
|
341
332
|
): Promise<void> {
|
@@ -344,7 +335,14 @@ async function setLatestValidatedLedgerSequence(
|
|
344
335
|
tx.LastLedgerSequence = ledgerSequence + LEDGER_OFFSET
|
345
336
|
}
|
346
337
|
|
347
|
-
|
338
|
+
/**
|
339
|
+
* Checks for any blockers that prevent the deletion of an account.
|
340
|
+
*
|
341
|
+
* @param client - The client object.
|
342
|
+
* @param tx - The transaction object.
|
343
|
+
* @returns A promise that resolves with void if there are no blockers, or rejects with an XrplError if there are blockers.
|
344
|
+
*/
|
345
|
+
export async function checkAccountDeleteBlockers(
|
348
346
|
client: Client,
|
349
347
|
tx: Transaction,
|
350
348
|
): Promise<void> {
|
@@ -367,5 +365,3 @@ async function checkAccountDeleteBlockers(
|
|
367
365
|
resolve()
|
368
366
|
})
|
369
367
|
}
|
370
|
-
|
371
|
-
export default autofill
|
package/src/sugar/balances.ts
CHANGED
@@ -1,123 +1,15 @@
|
|
1
|
-
import
|
1
|
+
import { AccountLinesTrustline, Balance } from '../models'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
import { dropsToXrp } from '../utils'
|
11
|
-
|
12
|
-
function formatBalances(trustlines: AccountLinesTrustline[]): Balance[] {
|
3
|
+
/**
|
4
|
+
* Formats an array of trustlines into an array of balances.
|
5
|
+
*
|
6
|
+
* @param trustlines - The array of trustlines to format.
|
7
|
+
* @returns An array of balances, each containing the value, currency, and issuer.
|
8
|
+
*/
|
9
|
+
export function formatBalances(trustlines: AccountLinesTrustline[]): Balance[] {
|
13
10
|
return trustlines.map((trustline) => ({
|
14
11
|
value: trustline.balance,
|
15
12
|
currency: trustline.currency,
|
16
13
|
issuer: trustline.account,
|
17
14
|
}))
|
18
15
|
}
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Get the XRP balance for an account.
|
22
|
-
*
|
23
|
-
* @example
|
24
|
-
* ```ts
|
25
|
-
* const client = new Client(wss://s.altnet.rippletest.net:51233)
|
26
|
-
* const balance = await client.getXrpBalance('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn')
|
27
|
-
* console.log(balance)
|
28
|
-
* /// '200'
|
29
|
-
* ```
|
30
|
-
*
|
31
|
-
* @param this - Client.
|
32
|
-
* @param address - Address of the account to retrieve XRP balance.
|
33
|
-
* @param options - Options to include for getting the XRP balance.
|
34
|
-
* @param options.ledger_index - Retrieve the account balances at a given
|
35
|
-
* ledger_index.
|
36
|
-
* @param options.ledger_hash - Retrieve the account balances at the ledger with
|
37
|
-
* a given ledger_hash.
|
38
|
-
* @returns The XRP balance of the account (as a string).
|
39
|
-
*/
|
40
|
-
async function getXrpBalance(
|
41
|
-
this: Client,
|
42
|
-
address: string,
|
43
|
-
options: {
|
44
|
-
ledger_hash?: string
|
45
|
-
ledger_index?: LedgerIndex
|
46
|
-
} = {},
|
47
|
-
): Promise<string> {
|
48
|
-
const xrpRequest: AccountInfoRequest = {
|
49
|
-
command: 'account_info',
|
50
|
-
account: address,
|
51
|
-
ledger_index: options.ledger_index ?? 'validated',
|
52
|
-
ledger_hash: options.ledger_hash,
|
53
|
-
}
|
54
|
-
const response = await this.request(xrpRequest)
|
55
|
-
return dropsToXrp(response.result.account_data.Balance)
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Get XRP/non-XRP balances for an account.
|
60
|
-
*
|
61
|
-
* @param this - Client.
|
62
|
-
* @param address - Address of the account to retrieve balances for.
|
63
|
-
* @param options - Allows the client to specify a ledger_hash, ledger_index,
|
64
|
-
* filter by peer, and/or limit number of balances.
|
65
|
-
* @param options.ledger_index - Retrieve the account balances at a given
|
66
|
-
* ledger_index.
|
67
|
-
* @param options.ledger_hash - Retrieve the account balances at the ledger with
|
68
|
-
* a given ledger_hash.
|
69
|
-
* @param options.peer - Filter balances by peer.
|
70
|
-
* @param options.limit - Limit number of balances to return.
|
71
|
-
* @returns An array of XRP/non-XRP balances for the given account.
|
72
|
-
*/
|
73
|
-
// eslint-disable-next-line max-lines-per-function -- Longer definition is required for end users to see the definition.
|
74
|
-
async function getBalances(
|
75
|
-
this: Client,
|
76
|
-
address: string,
|
77
|
-
options: {
|
78
|
-
ledger_hash?: string
|
79
|
-
ledger_index?: LedgerIndex
|
80
|
-
peer?: string
|
81
|
-
limit?: number
|
82
|
-
} = {},
|
83
|
-
): Promise<
|
84
|
-
Array<{ value: string; currency: string; issuer?: string | undefined }>
|
85
|
-
> {
|
86
|
-
const balances: Balance[] = []
|
87
|
-
|
88
|
-
// get XRP balance
|
89
|
-
let xrpPromise: Promise<string> = Promise.resolve('')
|
90
|
-
if (!options.peer) {
|
91
|
-
xrpPromise = this.getXrpBalance(address, {
|
92
|
-
ledger_hash: options.ledger_hash,
|
93
|
-
ledger_index: options.ledger_index,
|
94
|
-
})
|
95
|
-
}
|
96
|
-
|
97
|
-
// get non-XRP balances
|
98
|
-
const linesRequest: AccountLinesRequest = {
|
99
|
-
command: 'account_lines',
|
100
|
-
account: address,
|
101
|
-
ledger_index: options.ledger_index ?? 'validated',
|
102
|
-
ledger_hash: options.ledger_hash,
|
103
|
-
peer: options.peer,
|
104
|
-
limit: options.limit,
|
105
|
-
}
|
106
|
-
const linesPromise = this.requestAll(linesRequest)
|
107
|
-
|
108
|
-
// combine results
|
109
|
-
await Promise.all([xrpPromise, linesPromise]).then(
|
110
|
-
([xrpBalance, linesResponses]) => {
|
111
|
-
const accountLinesBalance = flatMap(linesResponses, (response) =>
|
112
|
-
formatBalances(response.result.lines),
|
113
|
-
)
|
114
|
-
if (xrpBalance !== '') {
|
115
|
-
balances.push({ currency: 'XRP', value: xrpBalance })
|
116
|
-
}
|
117
|
-
balances.push(...accountLinesBalance)
|
118
|
-
},
|
119
|
-
)
|
120
|
-
return balances.slice(0, options.limit)
|
121
|
-
}
|
122
|
-
|
123
|
-
export { getXrpBalance, getBalances }
|