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,6 +1,4 @@
|
|
1
|
-
/* eslint-disable max-lines-per-function -- Needs to process orderbooks. */
|
2
1
|
import BigNumber from 'bignumber.js'
|
3
|
-
import flatMap from 'lodash/flatMap'
|
4
2
|
|
5
3
|
import type { Client } from '../client'
|
6
4
|
import { ValidationError } from '../errors'
|
@@ -31,43 +29,40 @@ const getOrderbookOptionsSet = new Set([
|
|
31
29
|
])
|
32
30
|
|
33
31
|
/**
|
34
|
-
*
|
35
|
-
|
36
|
-
|
32
|
+
* Represents the options for retrieving the order book.
|
33
|
+
*/
|
34
|
+
export interface GetOrderBookOptions {
|
35
|
+
/**
|
36
|
+
* The limit on the number of offers to return.
|
37
|
+
*/
|
38
|
+
limit?: number
|
39
|
+
/**
|
40
|
+
* The ledger index of the ledger to use.
|
41
|
+
*/
|
42
|
+
ledger_index?: LedgerIndex
|
43
|
+
/**
|
44
|
+
* The ledger hash of the ledger to use.
|
45
|
+
*/
|
46
|
+
ledger_hash?: string | null
|
47
|
+
/**
|
48
|
+
* The account that takes the offers.
|
49
|
+
*/
|
50
|
+
taker?: string | null
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Validates the options for retrieving the order book.
|
37
55
|
*
|
38
|
-
* @param
|
39
|
-
* @
|
40
|
-
* @param currency2 - Specification of a second currency involved. (With a currency code and optionally an issuer)
|
41
|
-
* @param options - Options allowing the client to specify ledger_index,
|
42
|
-
* ledger_hash, filter by taker, and/or limit number of orders.
|
43
|
-
* @param options.ledger_index - Retrieve the orderbook at a given ledger_index.
|
44
|
-
* @param options.ledger_hash - Retrieve the orderbook at the ledger with a
|
45
|
-
* given ledger_hash.
|
46
|
-
* @param options.taker - Filter orders by taker.
|
47
|
-
* @param options.limit - The limit passed into each book_offers request.
|
48
|
-
* Can return more than this due to two calls being made. Defaults to 20.
|
49
|
-
* @returns An object containing buy and sell objects.
|
56
|
+
* @param options - The options to validate.
|
57
|
+
* @throws {ValidationError} If any validation errors occur.
|
50
58
|
*/
|
51
|
-
// eslint-disable-next-line
|
52
|
-
|
53
|
-
|
54
|
-
currency1: BookOfferCurrency,
|
55
|
-
currency2: BookOfferCurrency,
|
56
|
-
options: {
|
57
|
-
limit?: number
|
58
|
-
ledger_index?: LedgerIndex
|
59
|
-
ledger_hash?: string | null
|
60
|
-
taker?: string | null
|
61
|
-
} = {},
|
62
|
-
): Promise<{
|
63
|
-
buy: BookOffer[]
|
64
|
-
sell: BookOffer[]
|
65
|
-
}> {
|
66
|
-
Object.keys(options).forEach((key) => {
|
59
|
+
// eslint-disable-next-line complexity -- Necessary for validation.
|
60
|
+
export function validateOrderbookOptions(options: GetOrderBookOptions): void {
|
61
|
+
for (const key of Object.keys(options)) {
|
67
62
|
if (!getOrderbookOptionsSet.has(key)) {
|
68
63
|
throw new ValidationError(`Unexpected option: ${key}`, options)
|
69
64
|
}
|
70
|
-
}
|
65
|
+
}
|
71
66
|
|
72
67
|
if (options.limit && typeof options.limit !== 'number') {
|
73
68
|
throw new ValidationError('limit must be a number', options.limit)
|
@@ -101,7 +96,30 @@ async function getOrderbook(
|
|
101
96
|
if (options.taker !== undefined && typeof options.taker !== 'string') {
|
102
97
|
throw new ValidationError('taker must be a string', options.taker)
|
103
98
|
}
|
99
|
+
}
|
104
100
|
|
101
|
+
/**
|
102
|
+
* Creates a request object for retrieving book offers.
|
103
|
+
*
|
104
|
+
* @param currency1 - The first currency in the pair.
|
105
|
+
* @param currency2 - The second currency in the pair.
|
106
|
+
* @param options - Additional options for the request.
|
107
|
+
* @param [options.limit] - The maximum number of offers to retrieve.
|
108
|
+
* @param [options.ledger_index] - The ledger index to use for retrieval.
|
109
|
+
* @param [options.ledger_hash] - The ledger hash to use for retrieval.
|
110
|
+
* @param [options.taker] - The taker address for retrieval.
|
111
|
+
* @returns The created request object.
|
112
|
+
*/
|
113
|
+
export function createBookOffersRequest(
|
114
|
+
currency1: BookOfferCurrency,
|
115
|
+
currency2: BookOfferCurrency,
|
116
|
+
options: {
|
117
|
+
limit?: number
|
118
|
+
ledger_index?: LedgerIndex
|
119
|
+
ledger_hash?: string | null
|
120
|
+
taker?: string | null
|
121
|
+
},
|
122
|
+
): BookOffersRequest {
|
105
123
|
const request: BookOffersRequest = {
|
106
124
|
command: 'book_offers',
|
107
125
|
taker_pays: currency1,
|
@@ -111,25 +129,78 @@ async function getOrderbook(
|
|
111
129
|
limit: options.limit ?? DEFAULT_LIMIT,
|
112
130
|
taker: options.taker ? options.taker : undefined,
|
113
131
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
132
|
+
|
133
|
+
return request
|
134
|
+
}
|
135
|
+
|
136
|
+
type BookOfferResult = BookOffer[]
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Retrieves all book offer results using the given request.
|
140
|
+
*
|
141
|
+
* @param client - The Ripple client.
|
142
|
+
* @param request - The request object.
|
143
|
+
* @returns The array of book offer results.
|
144
|
+
*/
|
145
|
+
export async function requestAllOffers(
|
146
|
+
client: Client,
|
147
|
+
request: BookOffersRequest,
|
148
|
+
): Promise<BookOfferResult[]> {
|
149
|
+
const results = await client.requestAll(request)
|
150
|
+
return results.map((result) => result.result.offers)
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Creates a reverse request object by swapping the taker pays and taker gets amounts.
|
155
|
+
*
|
156
|
+
* @param request - The original request object.
|
157
|
+
* @returns The reverse request object.
|
158
|
+
*/
|
159
|
+
export function reverseRequest(request: BookOffersRequest): BookOffersRequest {
|
160
|
+
return {
|
161
|
+
...request,
|
162
|
+
taker_pays: request.taker_gets,
|
163
|
+
taker_gets: request.taker_pays,
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Extracts the offers from the book offer results.
|
169
|
+
*
|
170
|
+
* @param offerResults - The array of book offer results.
|
171
|
+
* @returns The extracted offers.
|
172
|
+
*/
|
173
|
+
export function extractOffers(offerResults: BookOfferResult[]): BookOffer[] {
|
174
|
+
return offerResults.flatMap((offerResult) => offerResult)
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Combines the direct and reverse offers into a single array.
|
179
|
+
*
|
180
|
+
* @param directOffers - The direct offers.
|
181
|
+
* @param reverseOffers - The reverse offers.
|
182
|
+
* @returns The combined array of offers.
|
183
|
+
*/
|
184
|
+
export function combineOrders(
|
185
|
+
directOffers: BookOffer[],
|
186
|
+
reverseOffers: BookOffer[],
|
187
|
+
): BookOffer[] {
|
188
|
+
return [...directOffers, ...reverseOffers]
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Separates the buy and sell orders from the given array of orders.
|
193
|
+
*
|
194
|
+
* @param orders - The array of orders.
|
195
|
+
* @returns The separated buy and sell orders.
|
196
|
+
*/
|
197
|
+
export function separateBuySellOrders(orders: BookOffer[]): {
|
198
|
+
buy: BookOffer[]
|
199
|
+
sell: BookOffer[]
|
200
|
+
} {
|
131
201
|
const buy: BookOffer[] = []
|
132
202
|
const sell: BookOffer[] = []
|
203
|
+
|
133
204
|
orders.forEach((order) => {
|
134
205
|
// eslint-disable-next-line no-bitwise -- necessary for flags check
|
135
206
|
if ((order.Flags & OfferFlags.lsfSell) === 0) {
|
@@ -138,15 +209,21 @@ async function getOrderbook(
|
|
138
209
|
sell.push(order)
|
139
210
|
}
|
140
211
|
})
|
141
|
-
|
142
|
-
|
143
|
-
* for both buys and sells, lowest quality is closest to mid-market
|
144
|
-
* we sort the orders so that earlier orders are closer to mid-market
|
145
|
-
*/
|
146
|
-
return {
|
147
|
-
buy: sortOffers(buy).slice(0, options.limit),
|
148
|
-
sell: sortOffers(sell).slice(0, options.limit),
|
149
|
-
}
|
212
|
+
|
213
|
+
return { buy, sell }
|
150
214
|
}
|
151
215
|
|
152
|
-
|
216
|
+
/**
|
217
|
+
* Sorts and limits the given array of offers.
|
218
|
+
*
|
219
|
+
* @param offers - The array of offers to sort and limit.
|
220
|
+
* @param [limit] - The maximum number of offers to include.
|
221
|
+
* @returns The sorted and limited array of offers.
|
222
|
+
*/
|
223
|
+
export function sortAndLimitOffers(
|
224
|
+
offers: BookOffer[],
|
225
|
+
limit?: number,
|
226
|
+
): BookOffer[] {
|
227
|
+
const sortedOffers = sortOffers(offers)
|
228
|
+
return sortedOffers.slice(0, limit)
|
229
|
+
}
|
package/src/sugar/index.ts
CHANGED
@@ -1,11 +1,3 @@
|
|
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
1
|
export * from './submit'
|
10
2
|
|
11
3
|
export * from './utils'
|
package/src/sugar/submit.ts
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
import { decode, encode } from 'ripple-binary-codec'
|
2
2
|
|
3
|
-
import type {
|
3
|
+
import type {
|
4
|
+
Client,
|
5
|
+
SubmitRequest,
|
6
|
+
SubmitResponse,
|
7
|
+
SubmittableTransaction,
|
8
|
+
Transaction,
|
9
|
+
Wallet,
|
10
|
+
} from '..'
|
4
11
|
import { ValidationError, XrplError } from '../errors'
|
5
12
|
import { Signer } from '../models/common'
|
6
13
|
import { TxRequest, TxResponse } from '../models/methods'
|
7
|
-
import { Transaction } from '../models/transactions'
|
8
14
|
import { BaseTransaction } from '../models/transactions/common'
|
9
|
-
import { hashes } from '../utils'
|
10
15
|
|
11
16
|
/** Approximate time for a ledger to close, in milliseconds */
|
12
17
|
const LEDGER_CLOSE_TIME = 1000
|
@@ -17,132 +22,33 @@ async function sleep(ms: number): Promise<void> {
|
|
17
22
|
})
|
18
23
|
}
|
19
24
|
|
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
|
-
}
|
25
|
+
// Helper functions
|
51
26
|
|
52
27
|
/**
|
53
|
-
*
|
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
|
-
* ```
|
28
|
+
* Submits a request to the client with a signed transaction.
|
84
29
|
*
|
85
|
-
*
|
30
|
+
* @param client - The client to submit the request to.
|
31
|
+
* @param signedTransaction - The signed transaction to submit. It can be either a Transaction object or a
|
32
|
+
* string (encode from ripple-binary-codec) representation of the transaction.
|
33
|
+
* @param [failHard=false] - Optional. Determines whether the submission should fail hard (true) or not (false). Default is false.
|
34
|
+
* @returns A promise that resolves with the response from the client.
|
35
|
+
* @throws {ValidationError} If the signed transaction is not valid (not signed).
|
86
36
|
*
|
87
|
-
*
|
88
|
-
*
|
37
|
+
* @example
|
38
|
+
* import { Client } from "xrpl"
|
39
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233");
|
40
|
+
* await client.connect();
|
41
|
+
* const signedTransaction = createSignedTransaction();
|
42
|
+
* // Example 1: Submitting a Transaction object
|
43
|
+
* const response1 = await submitRequest(client, signedTransaction);
|
89
44
|
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
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.
|
45
|
+
* // Example 2: Submitting a string representation of the transaction
|
46
|
+
* const signedTransactionString = encode(signedTransaction);
|
47
|
+
* const response2 = await submitRequest(client, signedTransactionString, true);
|
107
48
|
*/
|
108
|
-
async function
|
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(
|
49
|
+
export async function submitRequest(
|
144
50
|
client: Client,
|
145
|
-
signedTransaction:
|
51
|
+
signedTransaction: SubmittableTransaction | string,
|
146
52
|
failHard = false,
|
147
53
|
): Promise<SubmitResponse> {
|
148
54
|
if (!isSigned(signedTransaction)) {
|
@@ -161,15 +67,50 @@ async function submitRequest(
|
|
161
67
|
return client.request(request)
|
162
68
|
}
|
163
69
|
|
164
|
-
|
165
|
-
*
|
166
|
-
*
|
167
|
-
*
|
168
|
-
*
|
70
|
+
/**
|
71
|
+
* Waits for the final outcome of a transaction by polling the ledger until the result can be considered final,
|
72
|
+
* meaning it has either been included in a validated ledger, or the transaction's lastLedgerSequence has been
|
73
|
+
* surpassed by the latest ledger sequence (meaning it will never be included in a validated ledger).
|
74
|
+
*
|
75
|
+
* @template T - The type of the transaction. Defaults to `Transaction`.
|
76
|
+
* @param client - The client to use for requesting transaction information.
|
77
|
+
* @param txHash - The hash of the transaction to wait for.
|
78
|
+
* @param lastLedger - The last ledger sequence of the transaction.
|
79
|
+
* @param submissionResult - The preliminary result of the transaction.
|
80
|
+
* @returns A promise that resolves with the final transaction response.
|
81
|
+
*
|
82
|
+
* @throws {XrplError} If the latest ledger sequence surpasses the transaction's lastLedgerSequence.
|
83
|
+
*
|
84
|
+
* @example
|
85
|
+
* import { hashes, Client } from "xrpl"
|
86
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233")
|
87
|
+
* await client.connect()
|
88
|
+
*
|
89
|
+
* const transaction = createTransaction() // your transaction function
|
90
|
+
*
|
91
|
+
* const signedTx = await getSignedTx(this, transaction)
|
92
|
+
*
|
93
|
+
* const lastLedger = getLastLedgerSequence(signedTx)
|
94
|
+
*
|
95
|
+
* if (lastLedger == null) {
|
96
|
+
* throw new ValidationError(
|
97
|
+
* 'Transaction must contain a LastLedgerSequence value for reliable submission.',
|
98
|
+
* )
|
99
|
+
* }
|
100
|
+
*
|
101
|
+
* const response = await submitRequest(this, signedTx, opts?.failHard)
|
102
|
+
*
|
103
|
+
* const txHash = hashes.hashSignedTx(signedTx)
|
104
|
+
* return waitForFinalTransactionOutcome(
|
105
|
+
* this,
|
106
|
+
* txHash,
|
107
|
+
* lastLedger,
|
108
|
+
* response.result.engine_result,
|
109
|
+
* )
|
169
110
|
*/
|
170
111
|
// 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 =
|
112
|
+
export async function waitForFinalTransactionOutcome<
|
113
|
+
T extends BaseTransaction = SubmittableTransaction,
|
173
114
|
>(
|
174
115
|
client: Client,
|
175
116
|
txHash: string,
|
@@ -224,7 +165,7 @@ async function waitForFinalTransactionOutcome<
|
|
224
165
|
}
|
225
166
|
|
226
167
|
// checks if the transaction has been signed
|
227
|
-
function isSigned(transaction:
|
168
|
+
function isSigned(transaction: SubmittableTransaction | string): boolean {
|
228
169
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
229
170
|
if (typeof tx === 'string') {
|
230
171
|
return false
|
@@ -248,22 +189,52 @@ function isSigned(transaction: Transaction | string): boolean {
|
|
248
189
|
return tx.SigningPubKey != null && tx.TxnSignature != null
|
249
190
|
}
|
250
191
|
|
251
|
-
|
252
|
-
|
192
|
+
/**
|
193
|
+
* Updates a transaction with `autofill` then signs it if it is unsigned.
|
194
|
+
*
|
195
|
+
* @param client - The client from which to retrieve the signed transaction.
|
196
|
+
* @param transaction - The transaction to retrieve. It can be either a Transaction object or
|
197
|
+
* a string (encode from ripple-binary-codec) representation of the transaction.
|
198
|
+
* @param [options={}] - Optional. Additional options for retrieving the signed transaction.
|
199
|
+
* @param [options.autofill=true] - Optional. Determines whether the transaction should be autofilled (true)
|
200
|
+
* or not (false). Default is true.
|
201
|
+
* @param [options.wallet] - Optional. A wallet to sign the transaction. It must be provided when submitting
|
202
|
+
* an unsigned transaction. Default is undefined.
|
203
|
+
* @returns A promise that resolves with the signed transaction.
|
204
|
+
*
|
205
|
+
* @throws {ValidationError} If the transaction is not signed and no wallet is provided.
|
206
|
+
*
|
207
|
+
* @example
|
208
|
+
* import { Client } from "xrpl"
|
209
|
+
* import { encode } from "ripple-binary-codec"
|
210
|
+
*
|
211
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233");
|
212
|
+
* await client.connect():
|
213
|
+
* const transaction = createTransaction(); // createTransaction is your function to create a transaction
|
214
|
+
* const options = {
|
215
|
+
* autofill: true,
|
216
|
+
* wallet: myWallet,
|
217
|
+
* };
|
218
|
+
*
|
219
|
+
* // Example 1: Retrieving a signed Transaction object
|
220
|
+
* const signedTx1 = await getSignedTx(client, transaction, options);
|
221
|
+
*
|
222
|
+
* // Example 2: Retrieving a string representation of the signed transaction
|
223
|
+
* const signedTxString = await getSignedTx(client, encode(transaction), options);
|
224
|
+
*/
|
225
|
+
export async function getSignedTx(
|
253
226
|
client: Client,
|
254
|
-
transaction:
|
227
|
+
transaction: SubmittableTransaction | string,
|
255
228
|
{
|
256
229
|
autofill = true,
|
257
230
|
wallet,
|
258
231
|
}: {
|
259
232
|
// If true, autofill a transaction.
|
260
233
|
autofill?: boolean
|
261
|
-
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
262
|
-
failHard?: boolean
|
263
234
|
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
264
235
|
wallet?: Wallet
|
265
236
|
} = {},
|
266
|
-
): Promise<
|
237
|
+
): Promise<SubmittableTransaction | string> {
|
267
238
|
if (isSigned(transaction)) {
|
268
239
|
return transaction
|
269
240
|
}
|
@@ -277,7 +248,7 @@ async function getSignedTx(
|
|
277
248
|
let tx =
|
278
249
|
typeof transaction === 'string'
|
279
250
|
? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- converts JsonObject to correct Transaction type
|
280
|
-
(decode(transaction) as unknown as
|
251
|
+
(decode(transaction) as unknown as SubmittableTransaction)
|
281
252
|
: transaction
|
282
253
|
|
283
254
|
if (autofill) {
|
@@ -288,7 +259,26 @@ async function getSignedTx(
|
|
288
259
|
}
|
289
260
|
|
290
261
|
// checks if there is a LastLedgerSequence as a part of the transaction
|
291
|
-
|
262
|
+
/**
|
263
|
+
* Retrieves the last ledger sequence from a transaction.
|
264
|
+
*
|
265
|
+
* @param transaction - The transaction to retrieve the last ledger sequence from. It can be either a Transaction object or
|
266
|
+
* a string (encode from ripple-binary-codec) representation of the transaction.
|
267
|
+
* @returns The last ledger sequence of the transaction, or null if not available.
|
268
|
+
*
|
269
|
+
* @example
|
270
|
+
* const transaction = createTransaction(); // your function to create a transaction
|
271
|
+
*
|
272
|
+
* // Example 1: Retrieving the last ledger sequence from a Transaction object
|
273
|
+
* const lastLedgerSequence1 = getLastLedgerSequence(transaction);
|
274
|
+
* console.log(lastLedgerSequence1); // Output: 12345
|
275
|
+
*
|
276
|
+
* // Example 2: Retrieving the last ledger sequence from a string representation of the transaction
|
277
|
+
* const transactionString = encode(transaction);
|
278
|
+
* const lastLedgerSequence2 = getLastLedgerSequence(transactionString);
|
279
|
+
* console.log(lastLedgerSequence2); // Output: 67890
|
280
|
+
*/
|
281
|
+
export function getLastLedgerSequence(
|
292
282
|
transaction: Transaction | string,
|
293
283
|
): number | null {
|
294
284
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
@@ -301,5 +291,3 @@ function isAccountDelete(transaction: Transaction | string): boolean {
|
|
301
291
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
302
292
|
return tx.TransactionType === 'AccountDelete'
|
303
293
|
}
|
304
|
-
|
305
|
-
export { submit, submitAndWait }
|
@@ -0,0 +1,57 @@
|
|
1
|
+
type ValueOf<T> = T[keyof T]
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Creates an object composed of keys generated from the results of running each element of collection thru iteratee.
|
5
|
+
* The order of grouped values is determined by the order they occur in collection.
|
6
|
+
* The corresponding value of each key is an array of elements responsible for generating the key.
|
7
|
+
*
|
8
|
+
* Similar to lodash's groupBy
|
9
|
+
*
|
10
|
+
* @param array - array to iterate over
|
11
|
+
* @param iteratee - function that returns key of the group to place the item
|
12
|
+
*
|
13
|
+
* @returns a map of arrays
|
14
|
+
*/
|
15
|
+
export function groupBy<T>(
|
16
|
+
array: T[],
|
17
|
+
iteratee: (value: T, index: number, array: T[]) => string | number,
|
18
|
+
): Record<string | number, T[]> {
|
19
|
+
// eslint-disable-next-line max-params -- need all the params for the fallback
|
20
|
+
function predicate(
|
21
|
+
acc: Record<string | number, T[]>,
|
22
|
+
value: T,
|
23
|
+
index: number,
|
24
|
+
arrayReference: T[],
|
25
|
+
): Record<string | number, T[]> {
|
26
|
+
const key = iteratee(value, index, arrayReference) || 0
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Find existing group or create a new one
|
28
|
+
const group = acc[key] || []
|
29
|
+
group.push(value)
|
30
|
+
acc[key] = group
|
31
|
+
return acc
|
32
|
+
}
|
33
|
+
|
34
|
+
return array.reduce(predicate, {})
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Creates an object composed of the own and inherited enumerable string keyed properties of object that
|
39
|
+
* predicate doesn't return truthy for.
|
40
|
+
*
|
41
|
+
* @param obj - Object to have properties removed.
|
42
|
+
* @param predicate - function that returns whether the property should be removed from the obj.
|
43
|
+
*
|
44
|
+
* @returns object
|
45
|
+
*/
|
46
|
+
export function omitBy<T extends object>(
|
47
|
+
obj: T,
|
48
|
+
predicate: (objElement: ValueOf<T>, k: string | number | symbol) => boolean,
|
49
|
+
): Partial<T> {
|
50
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- We know the keys are properties of T
|
51
|
+
const keys: Array<keyof T> = Object.keys(obj) as Array<keyof T>
|
52
|
+
const keysToKeep = keys.filter((kb) => !predicate(obj[kb], kb))
|
53
|
+
return keysToKeep.reduce((acc: Partial<T>, key: keyof T) => {
|
54
|
+
acc[key] = obj[key]
|
55
|
+
return acc
|
56
|
+
}, {})
|
57
|
+
}
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import BigNumber from 'bignumber.js'
|
2
|
-
import flatten from 'lodash/flatten'
|
3
|
-
import groupBy from 'lodash/groupBy'
|
4
2
|
|
5
3
|
import {
|
6
4
|
Amount,
|
@@ -10,6 +8,7 @@ import {
|
|
10
8
|
Node,
|
11
9
|
} from '../models'
|
12
10
|
|
11
|
+
import { groupBy } from './collections'
|
13
12
|
import { dropsToXrp } from './xrpConversion'
|
14
13
|
|
15
14
|
interface BalanceChange {
|
@@ -182,5 +181,5 @@ export default function getBalanceChanges(
|
|
182
181
|
}
|
183
182
|
return []
|
184
183
|
})
|
185
|
-
return groupByAccount(
|
184
|
+
return groupByAccount(quantities.flat())
|
186
185
|
}
|