xrpl 2.14.1 → 2.14.2
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.
Potentially problematic release.
This version of xrpl might be problematic. Click here for more details.
- package/README.md +3 -3
- package/build/xrpl-latest-min.js +24471 -3
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +17934 -75049
- 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.d.ts +1 -2
- package/dist/npm/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.js +1 -6
- 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 +49 -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 +32 -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 +6 -4
- 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 +61 -79
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +180 -50
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts +6 -3
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js +21 -6
- 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 +2 -1
- package/dist/npm/index.d.ts.map +1 -1
- package/dist/npm/index.js +9 -3
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +23 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/common/index.js +4 -0
- package/dist/npm/models/common/index.js.map +1 -1
- package/dist/npm/models/index.d.ts +1 -1
- package/dist/npm/models/index.d.ts.map +1 -1
- package/dist/npm/models/index.js +4 -2
- package/dist/npm/models/index.js.map +1 -1
- package/dist/npm/models/ledger/AMM.d.ts +2 -2
- package/dist/npm/models/ledger/AMM.d.ts.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/Amendments.d.ts +2 -2
- package/dist/npm/models/ledger/Amendments.d.ts.map +1 -1
- package/dist/npm/models/ledger/BaseLedgerEntry.d.ts +3 -3
- package/dist/npm/models/ledger/BaseLedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/Credential.d.ts +17 -0
- package/dist/npm/models/ledger/Credential.d.ts.map +1 -0
- package/dist/npm/models/ledger/Credential.js +3 -0
- package/dist/npm/models/ledger/Credential.js.map +1 -0
- package/dist/npm/models/ledger/DepositPreauth.d.ts +3 -1
- package/dist/npm/models/ledger/DepositPreauth.d.ts.map +1 -1
- package/dist/npm/models/ledger/DirectoryNode.d.ts +2 -2
- package/dist/npm/models/ledger/DirectoryNode.d.ts.map +1 -1
- package/dist/npm/models/ledger/FeeSettings.d.ts +2 -2
- package/dist/npm/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/models/ledger/Ledger.d.ts +14 -4
- package/dist/npm/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts +5 -2
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/LedgerHashes.d.ts +2 -2
- package/dist/npm/models/ledger/LedgerHashes.d.ts.map +1 -1
- package/dist/npm/models/ledger/MPToken.d.ts +10 -0
- package/dist/npm/models/ledger/MPToken.d.ts.map +1 -0
- package/dist/npm/models/ledger/MPToken.js +3 -0
- package/dist/npm/models/ledger/MPToken.js.map +1 -0
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts +13 -0
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts.map +1 -0
- package/dist/npm/models/ledger/MPTokenIssuance.js +3 -0
- package/dist/npm/models/ledger/MPTokenIssuance.js.map +1 -0
- package/dist/npm/models/ledger/NegativeUNL.d.ts +2 -2
- package/dist/npm/models/ledger/NegativeUNL.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/Oracle.d.ts +12 -0
- package/dist/npm/models/ledger/Oracle.d.ts.map +1 -0
- package/dist/npm/models/ledger/Oracle.js +3 -0
- package/dist/npm/models/ledger/Oracle.js.map +1 -0
- package/dist/npm/models/ledger/PermissionedDomain.d.ts +11 -0
- package/dist/npm/models/ledger/PermissionedDomain.d.ts.map +1 -0
- package/dist/npm/models/ledger/PermissionedDomain.js +3 -0
- package/dist/npm/models/ledger/PermissionedDomain.js.map +1 -0
- package/dist/npm/models/ledger/RippleState.d.ts +4 -1
- package/dist/npm/models/ledger/RippleState.d.ts.map +1 -1
- package/dist/npm/models/ledger/RippleState.js +4 -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/ledger/index.d.ts +6 -2
- package/dist/npm/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.js.map +1 -1
- package/dist/npm/models/methods/accountChannels.d.ts +1 -1
- package/dist/npm/models/methods/accountChannels.d.ts.map +1 -1
- package/dist/npm/models/methods/accountInfo.d.ts +17 -4
- package/dist/npm/models/methods/accountInfo.d.ts.map +1 -1
- package/dist/npm/models/methods/accountTx.d.ts +11 -5
- package/dist/npm/models/methods/accountTx.d.ts.map +1 -1
- package/dist/npm/models/methods/depositAuthorized.d.ts +2 -0
- package/dist/npm/models/methods/depositAuthorized.d.ts.map +1 -1
- package/dist/npm/models/methods/feature.d.ts +28 -0
- package/dist/npm/models/methods/feature.d.ts.map +1 -0
- package/dist/npm/models/methods/feature.js +3 -0
- package/dist/npm/models/methods/feature.js.map +1 -0
- package/dist/npm/models/methods/getAggregatePrice.d.ts +31 -0
- package/dist/npm/models/methods/getAggregatePrice.d.ts.map +1 -0
- package/dist/npm/models/methods/getAggregatePrice.js +3 -0
- package/dist/npm/models/methods/getAggregatePrice.js.map +1 -0
- package/dist/npm/models/methods/index.d.ts +25 -9
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledger.d.ts +49 -9
- package/dist/npm/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/models/methods/ledgerEntry.d.ts +12 -0
- package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/models/methods/nftsByIssuer.d.ts +19 -0
- package/dist/npm/models/methods/nftsByIssuer.d.ts.map +1 -0
- package/dist/npm/models/methods/nftsByIssuer.js +3 -0
- package/dist/npm/models/methods/nftsByIssuer.js.map +1 -0
- package/dist/npm/models/methods/serverState.d.ts +1 -0
- package/dist/npm/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/models/methods/simulate.d.ts +42 -0
- package/dist/npm/models/methods/simulate.d.ts.map +1 -0
- package/dist/npm/models/methods/simulate.js +3 -0
- package/dist/npm/models/methods/simulate.js.map +1 -0
- 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/submitMultisigned.d.ts +16 -5
- package/dist/npm/models/methods/submitMultisigned.d.ts.map +1 -1
- package/dist/npm/models/methods/subscribe.d.ts +10 -3
- package/dist/npm/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/models/methods/tx.d.ts +21 -10
- package/dist/npm/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMClawback.d.ts +17 -0
- package/dist/npm/models/transactions/AMMClawback.d.ts.map +1 -0
- package/dist/npm/models/transactions/AMMClawback.js +34 -0
- package/dist/npm/models/transactions/AMMClawback.js.map +1 -0
- package/dist/npm/models/transactions/AMMDeposit.d.ts +3 -1
- package/dist/npm/models/transactions/AMMDeposit.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js +2 -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/CredentialAccept.d.ts +9 -0
- package/dist/npm/models/transactions/CredentialAccept.d.ts.map +1 -0
- package/dist/npm/models/transactions/CredentialAccept.js +12 -0
- package/dist/npm/models/transactions/CredentialAccept.js.map +1 -0
- package/dist/npm/models/transactions/CredentialCreate.d.ts +11 -0
- package/dist/npm/models/transactions/CredentialCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/CredentialCreate.js +34 -0
- package/dist/npm/models/transactions/CredentialCreate.js.map +1 -0
- package/dist/npm/models/transactions/CredentialDelete.d.ts +10 -0
- package/dist/npm/models/transactions/CredentialDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/CredentialDelete.js +17 -0
- package/dist/npm/models/transactions/CredentialDelete.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts +15 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.js +15 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +54 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js +10 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js +29 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js.map +1 -0
- 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 +7 -1
- package/dist/npm/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.js +2 -1
- package/dist/npm/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenModify.d.ts +9 -0
- package/dist/npm/models/transactions/NFTokenModify.d.ts.map +1 -0
- package/dist/npm/models/transactions/NFTokenModify.js +22 -0
- package/dist/npm/models/transactions/NFTokenModify.js.map +1 -0
- package/dist/npm/models/transactions/XChainModifyBridge.js +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -1
- package/dist/npm/models/transactions/accountDelete.d.ts +1 -0
- package/dist/npm/models/transactions/accountDelete.d.ts.map +1 -1
- package/dist/npm/models/transactions/accountDelete.js +1 -0
- package/dist/npm/models/transactions/accountDelete.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/clawback.d.ts +3 -2
- package/dist/npm/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/models/transactions/clawback.js +11 -1
- package/dist/npm/models/transactions/clawback.js.map +1 -1
- package/dist/npm/models/transactions/common.d.ts +7 -1
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +97 -4
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/depositPreauth.d.ts +3 -0
- package/dist/npm/models/transactions/depositPreauth.d.ts.map +1 -1
- package/dist/npm/models/transactions/depositPreauth.js +20 -7
- package/dist/npm/models/transactions/depositPreauth.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/escrowFinish.d.ts +1 -0
- package/dist/npm/models/transactions/escrowFinish.d.ts.map +1 -1
- package/dist/npm/models/transactions/escrowFinish.js +1 -0
- package/dist/npm/models/transactions/escrowFinish.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +16 -3
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +13 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/metadata.d.ts +16 -4
- 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/oracleDelete.d.ts +7 -0
- package/dist/npm/models/transactions/oracleDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/oracleDelete.js +10 -0
- package/dist/npm/models/transactions/oracleDelete.js.map +1 -0
- package/dist/npm/models/transactions/oracleSet.d.ts +13 -0
- package/dist/npm/models/transactions/oracleSet.d.ts.map +1 -0
- package/dist/npm/models/transactions/oracleSet.js +59 -0
- package/dist/npm/models/transactions/oracleSet.js.map +1 -0
- package/dist/npm/models/transactions/payment.d.ts +12 -6
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/payment.js +3 -2
- package/dist/npm/models/transactions/payment.js.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.d.ts +1 -0
- package/dist/npm/models/transactions/paymentChannelClaim.d.ts.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js +2 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/models/transactions/permissionedDomainDelete.d.ts +7 -0
- package/dist/npm/models/transactions/permissionedDomainDelete.d.ts.map +1 -0
- package/dist/npm/models/transactions/permissionedDomainDelete.js +10 -0
- package/dist/npm/models/transactions/permissionedDomainDelete.js.map +1 -0
- package/dist/npm/models/transactions/permissionedDomainSet.d.ts +9 -0
- package/dist/npm/models/transactions/permissionedDomainSet.d.ts.map +1 -0
- package/dist/npm/models/transactions/permissionedDomainSet.js +13 -0
- package/dist/npm/models/transactions/permissionedDomainSet.js.map +1 -0
- package/dist/npm/models/transactions/transaction.d.ts +19 -4
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +53 -1
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/transactions/trustSet.d.ts +5 -1
- package/dist/npm/models/transactions/trustSet.d.ts.map +1 -1
- package/dist/npm/models/transactions/trustSet.js +3 -1
- package/dist/npm/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/models/utils/flags.d.ts +2 -0
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +51 -16
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/models/utils/index.d.ts +1 -0
- package/dist/npm/models/utils/index.d.ts.map +1 -1
- package/dist/npm/models/utils/index.js +2 -1
- package/dist/npm/models/utils/index.js.map +1 -1
- package/dist/npm/snippets/src/claimPayChannel.js +1 -1
- package/dist/npm/snippets/src/claimPayChannel.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 +7 -12
- package/dist/npm/snippets/src/paths.js.map +1 -1
- package/dist/npm/snippets/src/sendEscrow.js +1 -1
- package/dist/npm/snippets/src/sendEscrow.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.d.ts +1 -2
- package/dist/npm/src/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js +1 -6
- 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 +49 -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 +32 -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 +6 -4
- 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 +61 -79
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +180 -50
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/client/partialPayment.d.ts +6 -3
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js +21 -6
- 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 +2 -1
- package/dist/npm/src/index.d.ts.map +1 -1
- package/dist/npm/src/index.js +9 -3
- package/dist/npm/src/index.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +23 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/common/index.js +4 -0
- package/dist/npm/src/models/common/index.js.map +1 -1
- package/dist/npm/src/models/index.d.ts +1 -1
- package/dist/npm/src/models/index.d.ts.map +1 -1
- package/dist/npm/src/models/index.js +4 -2
- package/dist/npm/src/models/index.js.map +1 -1
- package/dist/npm/src/models/ledger/AMM.d.ts +2 -2
- package/dist/npm/src/models/ledger/AMM.d.ts.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/Amendments.d.ts +2 -2
- package/dist/npm/src/models/ledger/Amendments.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/BaseLedgerEntry.d.ts +3 -3
- package/dist/npm/src/models/ledger/BaseLedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Credential.d.ts +17 -0
- package/dist/npm/src/models/ledger/Credential.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/Credential.js +3 -0
- package/dist/npm/src/models/ledger/Credential.js.map +1 -0
- package/dist/npm/src/models/ledger/DepositPreauth.d.ts +3 -1
- package/dist/npm/src/models/ledger/DepositPreauth.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/DirectoryNode.d.ts +2 -2
- package/dist/npm/src/models/ledger/DirectoryNode.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/FeeSettings.d.ts +2 -2
- package/dist/npm/src/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Ledger.d.ts +14 -4
- package/dist/npm/src/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts +5 -2
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/LedgerHashes.d.ts +2 -2
- package/dist/npm/src/models/ledger/LedgerHashes.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/MPToken.d.ts +10 -0
- package/dist/npm/src/models/ledger/MPToken.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/MPToken.js +3 -0
- package/dist/npm/src/models/ledger/MPToken.js.map +1 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts +13 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.js +3 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.js.map +1 -0
- package/dist/npm/src/models/ledger/NegativeUNL.d.ts +2 -2
- package/dist/npm/src/models/ledger/NegativeUNL.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/Oracle.d.ts +12 -0
- package/dist/npm/src/models/ledger/Oracle.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/Oracle.js +3 -0
- package/dist/npm/src/models/ledger/Oracle.js.map +1 -0
- package/dist/npm/src/models/ledger/PermissionedDomain.d.ts +11 -0
- package/dist/npm/src/models/ledger/PermissionedDomain.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/PermissionedDomain.js +3 -0
- package/dist/npm/src/models/ledger/PermissionedDomain.js.map +1 -0
- package/dist/npm/src/models/ledger/RippleState.d.ts +4 -1
- package/dist/npm/src/models/ledger/RippleState.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/RippleState.js +4 -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/ledger/index.d.ts +6 -2
- package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.js.map +1 -1
- package/dist/npm/src/models/methods/accountChannels.d.ts +1 -1
- package/dist/npm/src/models/methods/accountChannels.d.ts.map +1 -1
- package/dist/npm/src/models/methods/accountInfo.d.ts +17 -4
- package/dist/npm/src/models/methods/accountInfo.d.ts.map +1 -1
- package/dist/npm/src/models/methods/accountTx.d.ts +11 -5
- package/dist/npm/src/models/methods/accountTx.d.ts.map +1 -1
- package/dist/npm/src/models/methods/depositAuthorized.d.ts +2 -0
- package/dist/npm/src/models/methods/depositAuthorized.d.ts.map +1 -1
- package/dist/npm/src/models/methods/feature.d.ts +28 -0
- package/dist/npm/src/models/methods/feature.d.ts.map +1 -0
- package/dist/npm/src/models/methods/feature.js +3 -0
- package/dist/npm/src/models/methods/feature.js.map +1 -0
- package/dist/npm/src/models/methods/getAggregatePrice.d.ts +31 -0
- package/dist/npm/src/models/methods/getAggregatePrice.d.ts.map +1 -0
- package/dist/npm/src/models/methods/getAggregatePrice.js +3 -0
- package/dist/npm/src/models/methods/getAggregatePrice.js.map +1 -0
- package/dist/npm/src/models/methods/index.d.ts +25 -9
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledger.d.ts +49 -9
- package/dist/npm/src/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledgerEntry.d.ts +12 -0
- package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/methods/nftsByIssuer.d.ts +19 -0
- package/dist/npm/src/models/methods/nftsByIssuer.d.ts.map +1 -0
- package/dist/npm/src/models/methods/nftsByIssuer.js +3 -0
- package/dist/npm/src/models/methods/nftsByIssuer.js.map +1 -0
- package/dist/npm/src/models/methods/serverState.d.ts +1 -0
- package/dist/npm/src/models/methods/serverState.d.ts.map +1 -1
- package/dist/npm/src/models/methods/simulate.d.ts +42 -0
- package/dist/npm/src/models/methods/simulate.d.ts.map +1 -0
- package/dist/npm/src/models/methods/simulate.js +3 -0
- package/dist/npm/src/models/methods/simulate.js.map +1 -0
- 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/submitMultisigned.d.ts +16 -5
- package/dist/npm/src/models/methods/submitMultisigned.d.ts.map +1 -1
- package/dist/npm/src/models/methods/subscribe.d.ts +10 -3
- package/dist/npm/src/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/src/models/methods/tx.d.ts +21 -10
- package/dist/npm/src/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMClawback.d.ts +17 -0
- package/dist/npm/src/models/transactions/AMMClawback.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/AMMClawback.js +34 -0
- package/dist/npm/src/models/transactions/AMMClawback.js.map +1 -0
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts +3 -1
- package/dist/npm/src/models/transactions/AMMDeposit.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js +2 -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/CredentialAccept.d.ts +9 -0
- package/dist/npm/src/models/transactions/CredentialAccept.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/CredentialAccept.js +12 -0
- package/dist/npm/src/models/transactions/CredentialAccept.js.map +1 -0
- package/dist/npm/src/models/transactions/CredentialCreate.d.ts +11 -0
- package/dist/npm/src/models/transactions/CredentialCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/CredentialCreate.js +34 -0
- package/dist/npm/src/models/transactions/CredentialCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/CredentialDelete.d.ts +10 -0
- package/dist/npm/src/models/transactions/CredentialDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/CredentialDelete.js +17 -0
- package/dist/npm/src/models/transactions/CredentialDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts +15 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.js +15 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +54 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js +10 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js +29 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js.map +1 -0
- 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 +7 -1
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js +2 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenModify.d.ts +9 -0
- package/dist/npm/src/models/transactions/NFTokenModify.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/NFTokenModify.js +22 -0
- package/dist/npm/src/models/transactions/NFTokenModify.js.map +1 -0
- 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/accountDelete.d.ts +1 -0
- package/dist/npm/src/models/transactions/accountDelete.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/accountDelete.js +1 -0
- package/dist/npm/src/models/transactions/accountDelete.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/clawback.d.ts +3 -2
- package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/clawback.js +11 -1
- package/dist/npm/src/models/transactions/clawback.js.map +1 -1
- package/dist/npm/src/models/transactions/common.d.ts +7 -1
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +97 -4
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/depositPreauth.d.ts +3 -0
- package/dist/npm/src/models/transactions/depositPreauth.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/depositPreauth.js +20 -7
- package/dist/npm/src/models/transactions/depositPreauth.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/escrowFinish.d.ts +1 -0
- package/dist/npm/src/models/transactions/escrowFinish.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/escrowFinish.js +1 -0
- package/dist/npm/src/models/transactions/escrowFinish.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +16 -3
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +13 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/metadata.d.ts +16 -4
- 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/oracleDelete.d.ts +7 -0
- package/dist/npm/src/models/transactions/oracleDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/oracleDelete.js +10 -0
- package/dist/npm/src/models/transactions/oracleDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/oracleSet.d.ts +13 -0
- package/dist/npm/src/models/transactions/oracleSet.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/oracleSet.js +59 -0
- package/dist/npm/src/models/transactions/oracleSet.js.map +1 -0
- package/dist/npm/src/models/transactions/payment.d.ts +12 -6
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/payment.js +3 -2
- package/dist/npm/src/models/transactions/payment.js.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts +1 -0
- package/dist/npm/src/models/transactions/paymentChannelClaim.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js +2 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/src/models/transactions/permissionedDomainDelete.d.ts +7 -0
- package/dist/npm/src/models/transactions/permissionedDomainDelete.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/permissionedDomainDelete.js +10 -0
- package/dist/npm/src/models/transactions/permissionedDomainDelete.js.map +1 -0
- package/dist/npm/src/models/transactions/permissionedDomainSet.d.ts +9 -0
- package/dist/npm/src/models/transactions/permissionedDomainSet.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/permissionedDomainSet.js +13 -0
- package/dist/npm/src/models/transactions/permissionedDomainSet.js.map +1 -0
- package/dist/npm/src/models/transactions/transaction.d.ts +19 -4
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +53 -1
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/transactions/trustSet.d.ts +5 -1
- package/dist/npm/src/models/transactions/trustSet.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/trustSet.js +3 -1
- package/dist/npm/src/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts +2 -0
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +51 -16
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/models/utils/index.d.ts +1 -0
- package/dist/npm/src/models/utils/index.d.ts.map +1 -1
- package/dist/npm/src/models/utils/index.js +2 -1
- package/dist/npm/src/models/utils/index.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +7 -3
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +11 -32
- 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/getFeeXrp.d.ts +1 -1
- package/dist/npm/src/sugar/getFeeXrp.d.ts.map +1 -1
- package/dist/npm/src/sugar/getFeeXrp.js +3 -2
- package/dist/npm/src/sugar/getFeeXrp.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 +11 -28
- 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 +5 -5
- 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 +2 -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 +7 -3
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +11 -32
- 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/getFeeXrp.d.ts +1 -1
- package/dist/npm/sugar/getFeeXrp.d.ts.map +1 -1
- package/dist/npm/sugar/getFeeXrp.js +3 -2
- package/dist/npm/sugar/getFeeXrp.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 +11 -28
- 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 +5 -5
- 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 +2 -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 +20 -47
- package/src/Wallet/authorizeChannel.ts +26 -0
- package/src/Wallet/defaultFaucets.ts +0 -6
- package/src/Wallet/fundWallet.ts +152 -214
- package/src/Wallet/index.ts +38 -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 +50 -19
- package/src/client/connection.ts +29 -94
- package/src/client/index.ts +816 -286
- package/src/client/partialPayment.ts +79 -26
- package/src/errors.ts +1 -3
- package/src/index.ts +8 -3
- package/src/models/common/index.ts +56 -0
- package/src/models/index.ts +3 -1
- package/src/models/ledger/AMM.ts +2 -2
- package/src/models/ledger/Amendments.ts +2 -2
- package/src/models/ledger/BaseLedgerEntry.ts +9 -5
- package/src/models/ledger/Credential.ts +47 -0
- package/src/models/ledger/DepositPreauth.ts +6 -2
- package/src/models/ledger/DirectoryNode.ts +2 -2
- package/src/models/ledger/FeeSettings.ts +4 -2
- package/src/models/ledger/Ledger.ts +51 -15
- package/src/models/ledger/LedgerEntry.ts +11 -0
- package/src/models/ledger/LedgerHashes.ts +2 -4
- package/src/models/ledger/MPToken.ts +11 -0
- package/src/models/ledger/MPTokenIssuance.ts +13 -0
- package/src/models/ledger/NegativeUNL.ts +2 -2
- package/src/models/ledger/Oracle.ts +43 -0
- package/src/models/ledger/PermissionedDomain.ts +29 -0
- package/src/models/ledger/RippleState.ts +6 -0
- package/src/models/ledger/index.ts +10 -1
- package/src/models/methods/accountChannels.ts +64 -1
- package/src/models/methods/accountInfo.ts +58 -12
- package/src/models/methods/accountTx.ts +49 -8
- package/src/models/methods/depositAuthorized.ts +10 -0
- package/src/models/methods/feature.ts +68 -0
- package/src/models/methods/getAggregatePrice.ts +119 -0
- package/src/models/methods/index.ts +259 -6
- package/src/models/methods/ledger.ts +187 -22
- package/src/models/methods/ledgerEntry.ts +45 -1
- package/src/models/methods/nftsByIssuer.ts +68 -0
- package/src/models/methods/serverState.ts +1 -0
- package/src/models/methods/simulate.ts +88 -0
- package/src/models/methods/submit.ts +2 -2
- package/src/models/methods/submitMultisigned.ts +48 -16
- package/src/models/methods/subscribe.ts +70 -3
- package/src/models/methods/tx.ts +76 -26
- package/src/models/transactions/AMMClawback.ts +120 -0
- package/src/models/transactions/AMMDeposit.ts +2 -0
- package/src/models/transactions/CredentialAccept.ts +44 -0
- package/src/models/transactions/CredentialCreate.ts +81 -0
- package/src/models/transactions/CredentialDelete.ts +55 -0
- package/src/models/transactions/MPTokenAuthorize.ts +67 -0
- package/src/models/transactions/MPTokenIssuanceCreate.ts +179 -0
- package/src/models/transactions/MPTokenIssuanceDestroy.ts +34 -0
- package/src/models/transactions/MPTokenIssuanceSet.ts +86 -0
- 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 +11 -0
- package/src/models/transactions/NFTokenModify.ts +67 -0
- package/src/models/transactions/accountDelete.ts +16 -0
- package/src/models/transactions/clawback.ts +27 -6
- package/src/models/transactions/common.ts +179 -1
- package/src/models/transactions/depositPreauth.ts +54 -15
- package/src/models/transactions/escrowFinish.ts +14 -0
- package/src/models/transactions/index.ts +33 -2
- package/src/models/transactions/metadata.ts +41 -4
- package/src/models/transactions/oracleDelete.ts +32 -0
- package/src/models/transactions/oracleSet.ts +176 -0
- package/src/models/transactions/payment.ts +27 -6
- package/src/models/transactions/paymentChannelClaim.ts +20 -1
- package/src/models/transactions/permissionedDomainDelete.ts +28 -0
- package/src/models/transactions/permissionedDomainSet.ts +54 -0
- package/src/models/transactions/transaction.ts +116 -7
- package/src/models/transactions/trustSet.ts +10 -0
- package/src/models/utils/flags.ts +80 -22
- package/src/models/utils/index.ts +1 -0
- package/src/sugar/autofill.ts +88 -98
- package/src/sugar/balances.ts +8 -116
- package/src/sugar/getFeeXrp.ts +6 -3
- package/src/sugar/getOrderbook.ts +138 -61
- package/src/sugar/index.ts +0 -8
- package/src/sugar/submit.ts +135 -146
- 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 +15 -14
- package/src/utils/hashes/index.ts +3 -2
- package/src/utils/hashes/sha512Half.ts +4 -7
- package/src/utils/index.ts +14 -7
- 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/snippets/src/bridgeTransfer.d.ts +0 -2
- package/dist/npm/snippets/src/bridgeTransfer.d.ts.map +0 -1
- package/dist/npm/snippets/src/bridgeTransfer.js +0 -126
- package/dist/npm/snippets/src/bridgeTransfer.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
package/src/client/index.ts
CHANGED
@@ -1,118 +1,91 @@
|
|
1
1
|
/* eslint-disable jsdoc/require-jsdoc -- Request has many aliases, but they don't need unique docs */
|
2
|
-
|
2
|
+
|
3
3
|
/* eslint-disable max-lines -- Client is a large file w/ lots of imports/exports */
|
4
|
-
import
|
5
|
-
import { EventEmitter } from 'events'
|
4
|
+
import { EventEmitter } from 'eventemitter3'
|
6
5
|
|
7
|
-
import {
|
6
|
+
import {
|
7
|
+
RippledError,
|
8
|
+
NotFoundError,
|
9
|
+
ValidationError,
|
10
|
+
XrplError,
|
11
|
+
} from '../errors'
|
12
|
+
import {
|
13
|
+
APIVersion,
|
14
|
+
LedgerIndex,
|
15
|
+
Balance,
|
16
|
+
DEFAULT_API_VERSION,
|
17
|
+
} from '../models/common'
|
8
18
|
import {
|
9
19
|
Request,
|
10
|
-
Response,
|
11
20
|
// account methods
|
12
21
|
AccountChannelsRequest,
|
13
22
|
AccountChannelsResponse,
|
14
|
-
AccountCurrenciesRequest,
|
15
|
-
AccountCurrenciesResponse,
|
16
23
|
AccountInfoRequest,
|
17
|
-
AccountInfoResponse,
|
18
24
|
AccountLinesRequest,
|
19
25
|
AccountLinesResponse,
|
20
|
-
AccountNFTsRequest,
|
21
|
-
AccountNFTsResponse,
|
22
26
|
AccountObjectsRequest,
|
23
27
|
AccountObjectsResponse,
|
24
28
|
AccountOffersRequest,
|
25
29
|
AccountOffersResponse,
|
26
30
|
AccountTxRequest,
|
27
31
|
AccountTxResponse,
|
28
|
-
GatewayBalancesRequest,
|
29
|
-
GatewayBalancesResponse,
|
30
|
-
NoRippleCheckRequest,
|
31
|
-
NoRippleCheckResponse,
|
32
32
|
// ledger methods
|
33
|
-
LedgerRequest,
|
34
|
-
LedgerResponse,
|
35
|
-
LedgerClosedRequest,
|
36
|
-
LedgerClosedResponse,
|
37
|
-
LedgerCurrentRequest,
|
38
|
-
LedgerCurrentResponse,
|
39
33
|
LedgerDataRequest,
|
40
34
|
LedgerDataResponse,
|
41
|
-
LedgerEntryRequest,
|
42
|
-
LedgerEntryResponse,
|
43
|
-
// transaction methods
|
44
|
-
SubmitRequest,
|
45
|
-
SubmitResponse,
|
46
|
-
SubmitMultisignedRequest,
|
47
|
-
SubmitMultisignedResponse,
|
48
|
-
TransactionEntryRequest,
|
49
|
-
TransactionEntryResponse,
|
50
|
-
TxRequest,
|
51
35
|
TxResponse,
|
52
|
-
// path and order book methods
|
53
|
-
BookOffersRequest,
|
54
|
-
BookOffersResponse,
|
55
|
-
DepositAuthorizedRequest,
|
56
|
-
DepositAuthorizedResponse,
|
57
|
-
PathFindRequest,
|
58
|
-
PathFindResponse,
|
59
|
-
RipplePathFindRequest,
|
60
|
-
RipplePathFindResponse,
|
61
|
-
// payment channel methods
|
62
|
-
ChannelVerifyRequest,
|
63
|
-
ChannelVerifyResponse,
|
64
|
-
// server info methods
|
65
|
-
FeeRequest,
|
66
|
-
FeeResponse,
|
67
|
-
ManifestRequest,
|
68
|
-
ManifestResponse,
|
69
|
-
ServerInfoRequest,
|
70
|
-
ServerInfoResponse,
|
71
|
-
ServerStateRequest,
|
72
|
-
ServerStateResponse,
|
73
|
-
// utility methods
|
74
|
-
PingRequest,
|
75
|
-
PingResponse,
|
76
|
-
RandomRequest,
|
77
|
-
RandomResponse,
|
78
|
-
LedgerStream,
|
79
|
-
ValidationStream,
|
80
|
-
TransactionStream,
|
81
|
-
PathFindStream,
|
82
|
-
PeerStatusStream,
|
83
|
-
ConsensusStream,
|
84
|
-
SubscribeRequest,
|
85
|
-
SubscribeResponse,
|
86
|
-
UnsubscribeRequest,
|
87
|
-
UnsubscribeResponse,
|
88
|
-
// NFT methods
|
89
|
-
NFTBuyOffersRequest,
|
90
|
-
NFTBuyOffersResponse,
|
91
|
-
NFTSellOffersRequest,
|
92
|
-
NFTSellOffersResponse,
|
93
|
-
// clio only methods
|
94
|
-
NFTInfoRequest,
|
95
|
-
NFTInfoResponse,
|
96
|
-
NFTHistoryRequest,
|
97
|
-
NFTHistoryResponse,
|
98
|
-
// AMM methods
|
99
|
-
AMMInfoRequest,
|
100
|
-
AMMInfoResponse,
|
101
|
-
ServerDefinitionsRequest,
|
102
|
-
ServerDefinitionsResponse,
|
103
36
|
} from '../models/methods'
|
104
|
-
import {
|
37
|
+
import type {
|
38
|
+
RequestResponseMap,
|
39
|
+
RequestAllResponseMap,
|
40
|
+
MarkerRequest,
|
41
|
+
MarkerResponse,
|
42
|
+
SubmitResponse,
|
43
|
+
SimulateRequest,
|
44
|
+
} from '../models/methods'
|
45
|
+
import type { BookOffer, BookOfferCurrency } from '../models/methods/bookOffers'
|
46
|
+
import {
|
47
|
+
SimulateBinaryResponse,
|
48
|
+
SimulateJsonResponse,
|
49
|
+
} from '../models/methods/simulate'
|
50
|
+
import type {
|
51
|
+
EventTypes,
|
52
|
+
OnEventToListenerMap,
|
53
|
+
} from '../models/methods/subscribe'
|
54
|
+
import type { SubmittableTransaction } from '../models/transactions'
|
55
|
+
import { convertTxFlagsToNumber } from '../models/utils/flags'
|
105
56
|
import {
|
106
|
-
autofill,
|
107
57
|
ensureClassicAddress,
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
submit,
|
113
|
-
submitAndWait,
|
58
|
+
submitRequest,
|
59
|
+
getSignedTx,
|
60
|
+
getLastLedgerSequence,
|
61
|
+
waitForFinalTransactionOutcome,
|
114
62
|
} from '../sugar'
|
115
|
-
import
|
63
|
+
import {
|
64
|
+
setValidAddresses,
|
65
|
+
setNextValidSequenceNumber,
|
66
|
+
calculateFeePerTransactionType,
|
67
|
+
setLatestValidatedLedgerSequence,
|
68
|
+
checkAccountDeleteBlockers,
|
69
|
+
txNeedsNetworkID,
|
70
|
+
} from '../sugar/autofill'
|
71
|
+
import { formatBalances } from '../sugar/balances'
|
72
|
+
import {
|
73
|
+
validateOrderbookOptions,
|
74
|
+
createBookOffersRequest,
|
75
|
+
requestAllOffers,
|
76
|
+
reverseRequest,
|
77
|
+
extractOffers,
|
78
|
+
combineOrders,
|
79
|
+
separateBuySellOrders,
|
80
|
+
sortAndLimitOffers,
|
81
|
+
} from '../sugar/getOrderbook'
|
82
|
+
import { dropsToXrp, hashes, isValidClassicAddress } from '../utils'
|
83
|
+
import { Wallet } from '../Wallet'
|
84
|
+
import {
|
85
|
+
type FaucetRequestBody,
|
86
|
+
FundingOptions,
|
87
|
+
requestFunding,
|
88
|
+
} from '../Wallet/fundWallet'
|
116
89
|
|
117
90
|
import {
|
118
91
|
Connection,
|
@@ -125,12 +98,49 @@ import {
|
|
125
98
|
} from './partialPayment'
|
126
99
|
|
127
100
|
export interface ClientOptions extends ConnectionUserOptions {
|
101
|
+
/**
|
102
|
+
* Multiplication factor to multiply estimated fee by to provide a cushion in case the
|
103
|
+
* required fee rises during submission of a transaction. Defaults to 1.2.
|
104
|
+
*
|
105
|
+
* @category Fee
|
106
|
+
*/
|
128
107
|
feeCushion?: number
|
108
|
+
/**
|
109
|
+
* Maximum transaction cost to allow, in decimal XRP. Must be a string-encoded
|
110
|
+
* number. Defaults to '2'.
|
111
|
+
*
|
112
|
+
* @category Fee
|
113
|
+
*/
|
129
114
|
maxFeeXRP?: string
|
130
|
-
|
115
|
+
/**
|
116
|
+
* Duration to wait for a request to timeout.
|
117
|
+
*/
|
131
118
|
timeout?: number
|
132
119
|
}
|
133
120
|
|
121
|
+
// Make sure to update both this and `RequestNextPageReturnMap` at the same time
|
122
|
+
type RequestNextPageType =
|
123
|
+
| AccountChannelsRequest
|
124
|
+
| AccountLinesRequest
|
125
|
+
| AccountObjectsRequest
|
126
|
+
| AccountOffersRequest
|
127
|
+
| AccountTxRequest
|
128
|
+
| LedgerDataRequest
|
129
|
+
|
130
|
+
type RequestNextPageReturnMap<T> = T extends AccountChannelsRequest
|
131
|
+
? AccountChannelsResponse
|
132
|
+
: T extends AccountLinesRequest
|
133
|
+
? AccountLinesResponse
|
134
|
+
: T extends AccountObjectsRequest
|
135
|
+
? AccountObjectsResponse
|
136
|
+
: T extends AccountOffersRequest
|
137
|
+
? AccountOffersResponse
|
138
|
+
: T extends AccountTxRequest
|
139
|
+
? AccountTxResponse
|
140
|
+
: T extends LedgerDataRequest
|
141
|
+
? LedgerDataResponse
|
142
|
+
: never
|
143
|
+
|
134
144
|
/**
|
135
145
|
* Get the response key / property name that contains the listed data for a
|
136
146
|
* command. This varies from command to command, but we need to know it to
|
@@ -160,19 +170,10 @@ function getCollectKeyFromCommand(command: string): string | null {
|
|
160
170
|
}
|
161
171
|
|
162
172
|
function clamp(value: number, min: number, max: number): number {
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
interface MarkerRequest extends BaseRequest {
|
168
|
-
limit?: number
|
169
|
-
marker?: unknown
|
170
|
-
}
|
171
|
-
|
172
|
-
interface MarkerResponse extends BaseResponse {
|
173
|
-
result: {
|
174
|
-
marker?: unknown
|
173
|
+
if (min > max) {
|
174
|
+
throw new Error('Illegal clamp bounds')
|
175
175
|
}
|
176
|
+
return Math.min(Math.max(value, min), max)
|
176
177
|
}
|
177
178
|
|
178
179
|
const DEFAULT_FEE_CUSHION = 1.2
|
@@ -188,7 +189,7 @@ const NORMAL_DISCONNECT_CODE = 1000
|
|
188
189
|
*
|
189
190
|
* @category Clients
|
190
191
|
*/
|
191
|
-
class Client extends EventEmitter {
|
192
|
+
class Client extends EventEmitter<EventTypes> {
|
192
193
|
/*
|
193
194
|
* Underlying connection to rippled.
|
194
195
|
*/
|
@@ -222,14 +223,26 @@ class Client extends EventEmitter {
|
|
222
223
|
*/
|
223
224
|
public buildVersion: string | undefined
|
224
225
|
|
226
|
+
/**
|
227
|
+
* API Version used by the server this client is connected to
|
228
|
+
*
|
229
|
+
*/
|
230
|
+
public apiVersion: APIVersion = DEFAULT_API_VERSION
|
231
|
+
|
225
232
|
/**
|
226
233
|
* Creates a new Client with a websocket connection to a rippled server.
|
227
234
|
*
|
228
235
|
* @param server - URL of the server to connect to.
|
229
236
|
* @param options - Options for client settings.
|
230
237
|
* @category Constructor
|
238
|
+
*
|
239
|
+
* @example
|
240
|
+
* ```ts
|
241
|
+
* import { Client } from "xrpl"
|
242
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
243
|
+
* ```
|
231
244
|
*/
|
232
|
-
|
245
|
+
/* eslint-disable max-lines-per-function -- the constructor requires more lines to implement the logic */
|
233
246
|
public constructor(server: string, options: ClientOptions = {}) {
|
234
247
|
super()
|
235
248
|
if (typeof server !== 'string' || !/wss?(?:\+unix)?:\/\//u.exec(server)) {
|
@@ -293,6 +306,7 @@ class Client extends EventEmitter {
|
|
293
306
|
this.emit('path_find', path)
|
294
307
|
})
|
295
308
|
}
|
309
|
+
/* eslint-enable max-lines-per-function */
|
296
310
|
|
297
311
|
/**
|
298
312
|
* Get the url that the client is connected to.
|
@@ -304,87 +318,37 @@ class Client extends EventEmitter {
|
|
304
318
|
return this.connection.getUrl()
|
305
319
|
}
|
306
320
|
|
307
|
-
/**
|
308
|
-
* @category Network
|
309
|
-
*/
|
310
|
-
public async request(
|
311
|
-
r: AccountChannelsRequest,
|
312
|
-
): Promise<AccountChannelsResponse>
|
313
|
-
public async request(
|
314
|
-
r: AccountCurrenciesRequest,
|
315
|
-
): Promise<AccountCurrenciesResponse>
|
316
|
-
public async request(r: AccountInfoRequest): Promise<AccountInfoResponse>
|
317
|
-
public async request(r: AccountLinesRequest): Promise<AccountLinesResponse>
|
318
|
-
public async request(r: AccountNFTsRequest): Promise<AccountNFTsResponse>
|
319
|
-
public async request(
|
320
|
-
r: AccountObjectsRequest,
|
321
|
-
): Promise<AccountObjectsResponse>
|
322
|
-
public async request(r: AccountOffersRequest): Promise<AccountOffersResponse>
|
323
|
-
public async request(r: AccountTxRequest): Promise<AccountTxResponse>
|
324
|
-
public async request(r: AMMInfoRequest): Promise<AMMInfoResponse>
|
325
|
-
public async request(r: BookOffersRequest): Promise<BookOffersResponse>
|
326
|
-
public async request(r: ChannelVerifyRequest): Promise<ChannelVerifyResponse>
|
327
|
-
public async request(
|
328
|
-
r: DepositAuthorizedRequest,
|
329
|
-
): Promise<DepositAuthorizedResponse>
|
330
|
-
public async request(r: FeeRequest): Promise<FeeResponse>
|
331
|
-
public async request(
|
332
|
-
r: GatewayBalancesRequest,
|
333
|
-
): Promise<GatewayBalancesResponse>
|
334
|
-
public async request(r: LedgerRequest): Promise<LedgerResponse>
|
335
|
-
public async request(r: LedgerClosedRequest): Promise<LedgerClosedResponse>
|
336
|
-
public async request(r: LedgerCurrentRequest): Promise<LedgerCurrentResponse>
|
337
|
-
public async request(r: LedgerDataRequest): Promise<LedgerDataResponse>
|
338
|
-
public async request(r: LedgerEntryRequest): Promise<LedgerEntryResponse>
|
339
|
-
public async request(r: ManifestRequest): Promise<ManifestResponse>
|
340
|
-
public async request(r: NFTBuyOffersRequest): Promise<NFTBuyOffersResponse>
|
341
|
-
public async request(r: NFTSellOffersRequest): Promise<NFTSellOffersResponse>
|
342
|
-
public async request(r: NFTInfoRequest): Promise<NFTInfoResponse>
|
343
|
-
public async request(r: NFTHistoryRequest): Promise<NFTHistoryResponse>
|
344
|
-
public async request(r: NoRippleCheckRequest): Promise<NoRippleCheckResponse>
|
345
|
-
public async request(r: PathFindRequest): Promise<PathFindResponse>
|
346
|
-
public async request(r: PingRequest): Promise<PingResponse>
|
347
|
-
public async request(r: RandomRequest): Promise<RandomResponse>
|
348
|
-
public async request(
|
349
|
-
r: RipplePathFindRequest,
|
350
|
-
): Promise<RipplePathFindResponse>
|
351
|
-
public async request(
|
352
|
-
r: ServerDefinitionsRequest,
|
353
|
-
): Promise<ServerDefinitionsResponse>
|
354
|
-
public async request(r: ServerInfoRequest): Promise<ServerInfoResponse>
|
355
|
-
public async request(r: ServerStateRequest): Promise<ServerStateResponse>
|
356
|
-
public async request(r: SubmitRequest): Promise<SubmitResponse>
|
357
|
-
public async request(
|
358
|
-
r: SubmitMultisignedRequest,
|
359
|
-
): Promise<SubmitMultisignedResponse>
|
360
|
-
public request(r: SubscribeRequest): Promise<SubscribeResponse>
|
361
|
-
public request(r: UnsubscribeRequest): Promise<UnsubscribeResponse>
|
362
|
-
public async request(
|
363
|
-
r: TransactionEntryRequest,
|
364
|
-
): Promise<TransactionEntryResponse>
|
365
|
-
public async request(r: TxRequest): Promise<TxResponse>
|
366
|
-
public async request<R extends BaseRequest, T extends BaseResponse>(
|
367
|
-
r: R,
|
368
|
-
): Promise<T>
|
369
321
|
/**
|
370
322
|
* Makes a request to the client with the given command and
|
371
323
|
* additional request body parameters.
|
372
324
|
*
|
325
|
+
* @category Network
|
373
326
|
* @param req - Request to send to the server.
|
374
327
|
* @returns The response from the server.
|
375
|
-
*
|
328
|
+
*
|
329
|
+
* @example
|
330
|
+
* ```ts
|
331
|
+
* const response = await client.request({
|
332
|
+
* command: 'account_info',
|
333
|
+
* account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
334
|
+
* })
|
335
|
+
* console.log(response)
|
336
|
+
* ```
|
376
337
|
*/
|
377
|
-
public async request<
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
338
|
+
public async request<
|
339
|
+
R extends Request,
|
340
|
+
V extends APIVersion = typeof DEFAULT_API_VERSION,
|
341
|
+
T = RequestResponseMap<R, V>,
|
342
|
+
>(req: R): Promise<T> {
|
343
|
+
const request = {
|
382
344
|
...req,
|
383
|
-
account:
|
384
|
-
|
385
|
-
ensureClassicAddress(req.account
|
386
|
-
|
387
|
-
|
345
|
+
account:
|
346
|
+
typeof req.account === 'string'
|
347
|
+
? ensureClassicAddress(req.account)
|
348
|
+
: undefined,
|
349
|
+
api_version: req.api_version ?? this.apiVersion,
|
350
|
+
}
|
351
|
+
const response = await this.connection.request<R, T>(request)
|
388
352
|
|
389
353
|
// mutates `response` to add warnings
|
390
354
|
handlePartialPayment(req.command, response)
|
@@ -392,44 +356,34 @@ class Client extends EventEmitter {
|
|
392
356
|
return response
|
393
357
|
}
|
394
358
|
|
395
|
-
/**
|
396
|
-
* @category Network
|
397
|
-
*/
|
398
|
-
public async requestNextPage(
|
399
|
-
req: AccountChannelsRequest,
|
400
|
-
resp: AccountChannelsResponse,
|
401
|
-
): Promise<AccountChannelsResponse>
|
402
|
-
public async requestNextPage(
|
403
|
-
req: AccountLinesRequest,
|
404
|
-
resp: AccountLinesResponse,
|
405
|
-
): Promise<AccountLinesResponse>
|
406
|
-
public async requestNextPage(
|
407
|
-
req: AccountObjectsRequest,
|
408
|
-
resp: AccountObjectsResponse,
|
409
|
-
): Promise<AccountObjectsResponse>
|
410
|
-
public async requestNextPage(
|
411
|
-
req: AccountOffersRequest,
|
412
|
-
resp: AccountOffersResponse,
|
413
|
-
): Promise<AccountOffersResponse>
|
414
|
-
public async requestNextPage(
|
415
|
-
req: AccountTxRequest,
|
416
|
-
resp: AccountTxResponse,
|
417
|
-
): Promise<AccountTxResponse>
|
418
|
-
public async requestNextPage(
|
419
|
-
req: LedgerDataRequest,
|
420
|
-
resp: LedgerDataResponse,
|
421
|
-
): Promise<LedgerDataResponse>
|
422
359
|
/**
|
423
360
|
* Requests the next page of data.
|
424
361
|
*
|
362
|
+
* @category Network
|
363
|
+
*
|
425
364
|
* @param req - Request to send.
|
426
365
|
* @param resp - Response with the marker to use in the request.
|
427
366
|
* @returns The response with the next page of data.
|
367
|
+
*
|
368
|
+
* @example
|
369
|
+
* ```ts
|
370
|
+
* const response = await client.request({
|
371
|
+
* command: 'account_tx',
|
372
|
+
* account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
373
|
+
* })
|
374
|
+
* console.log(response)
|
375
|
+
* const nextResponse = await client.requestNextPage({
|
376
|
+
* command: 'account_tx',
|
377
|
+
* account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
378
|
+
* },
|
379
|
+
* response)
|
380
|
+
* console.log(nextResponse)
|
381
|
+
* ```
|
428
382
|
*/
|
429
383
|
public async requestNextPage<
|
430
|
-
T extends
|
431
|
-
U extends
|
432
|
-
>(req: T, resp: U): Promise<
|
384
|
+
T extends RequestNextPageType,
|
385
|
+
U extends RequestNextPageReturnMap<T>,
|
386
|
+
>(req: T, resp: U): Promise<RequestNextPageReturnMap<T>> {
|
433
387
|
if (!resp.result.marker) {
|
434
388
|
return Promise.reject(
|
435
389
|
new NotFoundError('response does not have a next page'),
|
@@ -443,7 +397,13 @@ class Client extends EventEmitter {
|
|
443
397
|
/**
|
444
398
|
* Event handler for subscription streams.
|
445
399
|
*
|
446
|
-
* @
|
400
|
+
* @category Network
|
401
|
+
*
|
402
|
+
* @param eventName - Name of the event. Only forwards streams.
|
403
|
+
* @param listener - Function to run on event.
|
404
|
+
* @returns This, because it inherits from EventEmitter.
|
405
|
+
*
|
406
|
+
* * @example
|
447
407
|
* ```ts
|
448
408
|
* const api = new Client('wss://s.altnet.rippletest.net:51233')
|
449
409
|
*
|
@@ -458,68 +418,15 @@ class Client extends EventEmitter {
|
|
458
418
|
* streams: ['transactions_proposed']
|
459
419
|
* })
|
460
420
|
* ```
|
461
|
-
*
|
462
|
-
* @category Network
|
463
421
|
*/
|
464
|
-
public on
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
): this
|
470
|
-
public on(
|
471
|
-
event: 'validationReceived',
|
472
|
-
listener: (validation: ValidationStream) => void,
|
473
|
-
): this
|
474
|
-
public on(
|
475
|
-
event: 'transaction',
|
476
|
-
listener: (tx: TransactionStream) => void,
|
477
|
-
): this
|
478
|
-
public on(
|
479
|
-
event: 'peerStatusChange',
|
480
|
-
listener: (status: PeerStatusStream) => void,
|
481
|
-
): this
|
482
|
-
public on(
|
483
|
-
event: 'consensusPhase',
|
484
|
-
listener: (phase: ConsensusStream) => void,
|
485
|
-
): this
|
486
|
-
public on(
|
487
|
-
event: 'manifestReceived',
|
488
|
-
listener: (manifest: ManifestResponse) => void,
|
489
|
-
): this
|
490
|
-
public on(event: 'path_find', listener: (path: PathFindStream) => void): this
|
491
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- needs to be any for overload
|
492
|
-
public on(event: 'error', listener: (...err: any[]) => void): this
|
493
|
-
/**
|
494
|
-
* Event handler for subscription streams.
|
495
|
-
*
|
496
|
-
* @param eventName - Name of the event. Only forwards streams.
|
497
|
-
* @param listener - Function to run on event.
|
498
|
-
* @returns This, because it inherits from EventEmitter.
|
499
|
-
*/
|
500
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- needs to be any for overload
|
501
|
-
public on(eventName: string, listener: (...args: any[]) => void): this {
|
422
|
+
public on<
|
423
|
+
T extends EventTypes,
|
424
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- needs to be any for overload
|
425
|
+
U extends (...args: any[]) => void = OnEventToListenerMap<T>,
|
426
|
+
>(eventName: T, listener: U): this {
|
502
427
|
return super.on(eventName, listener)
|
503
428
|
}
|
504
429
|
|
505
|
-
/**
|
506
|
-
* @category Network
|
507
|
-
*/
|
508
|
-
public async requestAll(
|
509
|
-
req: AccountChannelsRequest,
|
510
|
-
): Promise<AccountChannelsResponse[]>
|
511
|
-
public async requestAll(
|
512
|
-
req: AccountLinesRequest,
|
513
|
-
): Promise<AccountLinesResponse[]>
|
514
|
-
public async requestAll(
|
515
|
-
req: AccountObjectsRequest,
|
516
|
-
): Promise<AccountObjectsResponse[]>
|
517
|
-
public async requestAll(
|
518
|
-
req: AccountOffersRequest,
|
519
|
-
): Promise<AccountOffersResponse[]>
|
520
|
-
public async requestAll(req: AccountTxRequest): Promise<AccountTxResponse[]>
|
521
|
-
public async requestAll(req: BookOffersRequest): Promise<BookOffersResponse[]>
|
522
|
-
public async requestAll(req: LedgerDataRequest): Promise<LedgerDataResponse[]>
|
523
430
|
/**
|
524
431
|
* Makes multiple paged requests to the client to return a given number of
|
525
432
|
* resources. Multiple paged requests will be made until the `limit`
|
@@ -533,15 +440,28 @@ class Client extends EventEmitter {
|
|
533
440
|
* general use. Instead, use rippled's built-in pagination and make multiple
|
534
441
|
* requests as needed.
|
535
442
|
*
|
443
|
+
* @category Network
|
444
|
+
*
|
536
445
|
* @param request - The initial request to send to the server.
|
537
446
|
* @param collect - (Optional) the param to use to collect the array of resources (only needed if command is unknown).
|
538
447
|
* @returns The array of all responses.
|
539
448
|
* @throws ValidationError if there is no collection key (either from a known command or for the unknown command).
|
449
|
+
*
|
450
|
+
* @example
|
451
|
+
* // Request all ledger data pages
|
452
|
+
* const allResponses = await client.requestAll({ command: 'ledger_data' });
|
453
|
+
* console.log(allResponses);
|
454
|
+
*
|
455
|
+
* @example
|
456
|
+
* // Request all transaction data pages
|
457
|
+
* const allResponses = await client.requestAll({ command: 'transaction_data' });
|
458
|
+
* console.log(allResponses);
|
540
459
|
*/
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
460
|
+
|
461
|
+
public async requestAll<
|
462
|
+
T extends MarkerRequest,
|
463
|
+
U = RequestAllResponseMap<T, APIVersion>,
|
464
|
+
>(request: T, collect?: string): Promise<U[]> {
|
545
465
|
/*
|
546
466
|
* The data under collection is keyed based on the command. Fail if command
|
547
467
|
* not recognized and collection key not provided.
|
@@ -557,7 +477,6 @@ class Client extends EventEmitter {
|
|
557
477
|
const countTo: number = request.limit == null ? Infinity : request.limit
|
558
478
|
let count = 0
|
559
479
|
let marker: unknown = request.marker
|
560
|
-
let lastBatchLength: number
|
561
480
|
const results: U[] = []
|
562
481
|
do {
|
563
482
|
const countRemaining = clamp(countTo - count, MIN_LIMIT, MAX_LIMIT)
|
@@ -569,7 +488,7 @@ class Client extends EventEmitter {
|
|
569
488
|
// eslint-disable-next-line no-await-in-loop -- Necessary for this, it really has to wait
|
570
489
|
const singleResponse = await this.connection.request(repeatProps)
|
571
490
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Should be true
|
572
|
-
const singleResult = (singleResponse as
|
491
|
+
const singleResult = (singleResponse as MarkerResponse<APIVersion>).result
|
573
492
|
if (!(collectKey in singleResult)) {
|
574
493
|
throw new XrplError(`${collectKey} not in result`)
|
575
494
|
}
|
@@ -581,16 +500,23 @@ class Client extends EventEmitter {
|
|
581
500
|
// Make sure we handle when no data (not even an empty array) is returned.
|
582
501
|
if (Array.isArray(collectedData)) {
|
583
502
|
count += collectedData.length
|
584
|
-
lastBatchLength = collectedData.length
|
585
|
-
} else {
|
586
|
-
lastBatchLength = 0
|
587
503
|
}
|
588
|
-
} while (Boolean(marker) && count < countTo
|
504
|
+
} while (Boolean(marker) && count < countTo)
|
589
505
|
return results
|
590
506
|
}
|
591
507
|
|
592
508
|
/**
|
593
509
|
* Get networkID and buildVersion from server_info
|
510
|
+
*
|
511
|
+
* @returns void
|
512
|
+
* @example
|
513
|
+
* ```ts
|
514
|
+
* const { Client } = require('xrpl')
|
515
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
516
|
+
* await client.getServerInfo()
|
517
|
+
* console.log(client.networkID)
|
518
|
+
* console.log(client.buildVersion)
|
519
|
+
* ```
|
594
520
|
*/
|
595
521
|
public async getServerInfo(): Promise<void> {
|
596
522
|
try {
|
@@ -623,6 +549,15 @@ class Client extends EventEmitter {
|
|
623
549
|
* before exiting your application.
|
624
550
|
* @returns A promise that resolves with a void value when a connection is established.
|
625
551
|
* @category Network
|
552
|
+
*
|
553
|
+
* @example
|
554
|
+
* ```ts
|
555
|
+
* const { Client } = require('xrpl')
|
556
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
557
|
+
* await client.connect()
|
558
|
+
* // do something with the client
|
559
|
+
* await client.disconnect()
|
560
|
+
* ```
|
626
561
|
*/
|
627
562
|
public async connect(): Promise<void> {
|
628
563
|
return this.connection.connect().then(async () => {
|
@@ -664,54 +599,649 @@ class Client extends EventEmitter {
|
|
664
599
|
*
|
665
600
|
* @returns Whether the client instance is connected.
|
666
601
|
* @category Network
|
602
|
+
* @example
|
603
|
+
* ```ts
|
604
|
+
* const { Client } = require('xrpl')
|
605
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
606
|
+
* await client.connect()
|
607
|
+
* console.log(client.isConnected())
|
608
|
+
* // true
|
609
|
+
* await client.disconnect()
|
610
|
+
* console.log(client.isConnected())
|
611
|
+
* // false
|
612
|
+
* ```
|
667
613
|
*/
|
668
614
|
public isConnected(): boolean {
|
669
615
|
return this.connection.isConnected()
|
670
616
|
}
|
671
617
|
|
672
618
|
/**
|
619
|
+
* Autofills fields in a transaction. This will set `Sequence`, `Fee`,
|
620
|
+
* `lastLedgerSequence` according to the current state of the server this Client
|
621
|
+
* is connected to. It also converts all X-Addresses to classic addresses and
|
622
|
+
* flags interfaces into numbers.
|
623
|
+
*
|
673
624
|
* @category Core
|
625
|
+
*
|
626
|
+
* @example
|
627
|
+
*
|
628
|
+
* ```ts
|
629
|
+
* const { Client } = require('xrpl')
|
630
|
+
*
|
631
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
632
|
+
*
|
633
|
+
* async function createAndAutofillTransaction() {
|
634
|
+
* const transaction = {
|
635
|
+
* TransactionType: 'Payment',
|
636
|
+
* Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
637
|
+
* Destination: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
638
|
+
* Amount: '10000000' // 10 XRP in drops (1/1,000,000th of an XRP)
|
639
|
+
* }
|
640
|
+
*
|
641
|
+
* try {
|
642
|
+
* const autofilledTransaction = await client.autofill(transaction)
|
643
|
+
* console.log(autofilledTransaction)
|
644
|
+
* } catch (error) {
|
645
|
+
* console.error(`Failed to autofill transaction: ${error}`)
|
646
|
+
* }
|
647
|
+
* }
|
648
|
+
*
|
649
|
+
* createAndAutofillTransaction()
|
650
|
+
* ```
|
651
|
+
*
|
652
|
+
* Autofill helps fill in fields which should be included in a transaction, but can be determined automatically
|
653
|
+
* such as `LastLedgerSequence` and `Fee`. If you override one of the fields `autofill` changes, your explicit
|
654
|
+
* values will be used instead. By default, this is done as part of `submit` and `submitAndWait` when you pass
|
655
|
+
* in an unsigned transaction along with your wallet to be submitted.
|
656
|
+
*
|
657
|
+
* @template T
|
658
|
+
* @param transaction - A {@link SubmittableTransaction} in JSON format
|
659
|
+
* @param signersCount - The expected number of signers for this transaction.
|
660
|
+
* Only used for multisigned transactions.
|
661
|
+
* @returns The autofilled transaction.
|
662
|
+
* @throws ValidationError If Amount and DeliverMax fields are not identical in a Payment Transaction
|
674
663
|
*/
|
675
|
-
|
664
|
+
|
665
|
+
// eslint-disable-next-line complexity -- handling Payment transaction API v2 requires more logic
|
666
|
+
public async autofill<T extends SubmittableTransaction>(
|
667
|
+
transaction: T,
|
668
|
+
signersCount?: number,
|
669
|
+
): Promise<T> {
|
670
|
+
const tx = { ...transaction }
|
671
|
+
|
672
|
+
setValidAddresses(tx)
|
673
|
+
tx.Flags = convertTxFlagsToNumber(tx)
|
674
|
+
|
675
|
+
const promises: Array<Promise<void>> = []
|
676
|
+
if (tx.NetworkID == null) {
|
677
|
+
tx.NetworkID = txNeedsNetworkID(this) ? this.networkID : undefined
|
678
|
+
}
|
679
|
+
if (tx.Sequence == null) {
|
680
|
+
promises.push(setNextValidSequenceNumber(this, tx))
|
681
|
+
}
|
682
|
+
if (tx.Fee == null) {
|
683
|
+
promises.push(calculateFeePerTransactionType(this, tx, signersCount))
|
684
|
+
}
|
685
|
+
if (tx.LastLedgerSequence == null) {
|
686
|
+
promises.push(setLatestValidatedLedgerSequence(this, tx))
|
687
|
+
}
|
688
|
+
if (tx.TransactionType === 'AccountDelete') {
|
689
|
+
promises.push(checkAccountDeleteBlockers(this, tx))
|
690
|
+
}
|
691
|
+
|
692
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
693
|
+
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
694
|
+
if (tx.TransactionType === 'Payment' && tx.DeliverMax != null) {
|
695
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
|
696
|
+
if (tx.Amount == null) {
|
697
|
+
// If only DeliverMax is provided, use it to populate the Amount field
|
698
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
699
|
+
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
700
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- DeliverMax is a known RPC-level property
|
701
|
+
tx.Amount = tx.DeliverMax
|
702
|
+
}
|
703
|
+
|
704
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
705
|
+
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
706
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
|
707
|
+
if (tx.Amount != null && tx.Amount !== tx.DeliverMax) {
|
708
|
+
return Promise.reject(
|
709
|
+
new ValidationError(
|
710
|
+
'PaymentTransaction: Amount and DeliverMax fields must be identical when both are provided',
|
711
|
+
),
|
712
|
+
)
|
713
|
+
}
|
714
|
+
|
715
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
|
716
|
+
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
|
717
|
+
delete tx.DeliverMax
|
718
|
+
}
|
719
|
+
|
720
|
+
return Promise.all(promises).then(() => tx)
|
721
|
+
}
|
676
722
|
|
677
723
|
/**
|
724
|
+
* Submits a signed/unsigned transaction.
|
725
|
+
* Steps performed on a transaction:
|
726
|
+
* 1. Autofill.
|
727
|
+
* 2. Sign & Encode.
|
728
|
+
* 3. Submit.
|
729
|
+
*
|
678
730
|
* @category Core
|
731
|
+
*
|
732
|
+
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
733
|
+
* @param opts - (Optional) Options used to sign and submit a transaction.
|
734
|
+
* @param opts.autofill - If true, autofill a transaction.
|
735
|
+
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
736
|
+
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
737
|
+
*
|
738
|
+
* @returns A promise that contains SubmitResponse.
|
739
|
+
* @throws RippledError if submit request fails.
|
740
|
+
*
|
741
|
+
* @example
|
742
|
+
* ```ts
|
743
|
+
* const { Client, Wallet } = require('xrpl')
|
744
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
745
|
+
* await client.connect()
|
746
|
+
* const wallet = Wallet.generate()
|
747
|
+
* const transaction = {
|
748
|
+
* TransactionType: 'Payment',
|
749
|
+
* Account: wallet.classicAddress,
|
750
|
+
* Destination: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
|
751
|
+
* Amount: '10000000' // 10 XRP in drops (1/1,000,000th of an XRP)
|
752
|
+
* }
|
753
|
+
* const submitResponse = await client.submit(transaction, { wallet })
|
754
|
+
* console.log(submitResponse)
|
755
|
+
* ```
|
679
756
|
*/
|
680
|
-
public
|
757
|
+
public async submit(
|
758
|
+
transaction: SubmittableTransaction | string,
|
759
|
+
opts?: {
|
760
|
+
// If true, autofill a transaction.
|
761
|
+
autofill?: boolean
|
762
|
+
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
763
|
+
failHard?: boolean
|
764
|
+
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
765
|
+
wallet?: Wallet
|
766
|
+
},
|
767
|
+
): Promise<SubmitResponse> {
|
768
|
+
const signedTx = await getSignedTx(this, transaction, opts)
|
769
|
+
return submitRequest(this, signedTx, opts?.failHard)
|
770
|
+
}
|
771
|
+
|
681
772
|
/**
|
773
|
+
* Simulates an unsigned transaction.
|
774
|
+
* Steps performed on a transaction:
|
775
|
+
* 1. Autofill.
|
776
|
+
* 2. Sign & Encode.
|
777
|
+
* 3. Submit.
|
778
|
+
*
|
682
779
|
* @category Core
|
780
|
+
*
|
781
|
+
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
782
|
+
* @param opts - (Optional) Options used to sign and submit a transaction.
|
783
|
+
* @param opts.binary - If true, return the metadata in a binary encoding.
|
784
|
+
*
|
785
|
+
* @returns A promise that contains SimulateResponse.
|
786
|
+
* @throws RippledError if the simulate request fails.
|
683
787
|
*/
|
684
|
-
|
788
|
+
|
789
|
+
public async simulate<Binary extends boolean = false>(
|
790
|
+
transaction: SubmittableTransaction | string,
|
791
|
+
opts?: {
|
792
|
+
// If true, return the binary-encoded representation of the results.
|
793
|
+
binary?: Binary
|
794
|
+
},
|
795
|
+
): Promise<
|
796
|
+
Binary extends true ? SimulateBinaryResponse : SimulateJsonResponse
|
797
|
+
> {
|
798
|
+
// send request
|
799
|
+
const binary = opts?.binary ?? false
|
800
|
+
const request: SimulateRequest =
|
801
|
+
typeof transaction === 'string'
|
802
|
+
? { command: 'simulate', tx_blob: transaction, binary }
|
803
|
+
: { command: 'simulate', tx_json: transaction, binary }
|
804
|
+
return this.request(request)
|
805
|
+
}
|
685
806
|
|
686
807
|
/**
|
808
|
+
* Asynchronously submits a transaction and verifies that it has been included in a
|
809
|
+
* validated ledger (or has errored/will not be included for some reason).
|
810
|
+
* See [Reliable Transaction Submission](https://xrpl.org/reliable-transaction-submission.html).
|
811
|
+
*
|
812
|
+
* @category Core
|
813
|
+
*
|
814
|
+
* @example
|
815
|
+
*
|
816
|
+
* ```ts
|
817
|
+
* const { Client, Wallet } = require('xrpl')
|
818
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
819
|
+
*
|
820
|
+
* async function submitTransaction() {
|
821
|
+
* const senderWallet = client.fundWallet()
|
822
|
+
* const recipientWallet = client.fundWallet()
|
823
|
+
*
|
824
|
+
* const transaction = {
|
825
|
+
* TransactionType: 'Payment',
|
826
|
+
* Account: senderWallet.address,
|
827
|
+
* Destination: recipientWallet.address,
|
828
|
+
* Amount: '10'
|
829
|
+
* }
|
830
|
+
*
|
831
|
+
* try {
|
832
|
+
* await client.submit(signedTransaction, { wallet: senderWallet })
|
833
|
+
* console.log(result)
|
834
|
+
* } catch (error) {
|
835
|
+
* console.error(`Failed to submit transaction: ${error}`)
|
836
|
+
* }
|
837
|
+
* }
|
838
|
+
*
|
839
|
+
* submitTransaction()
|
840
|
+
* ```
|
841
|
+
*
|
842
|
+
* In this example we submit a payment transaction between two newly created testnet accounts.
|
843
|
+
*
|
844
|
+
* Under the hood, `submit` will call `client.autofill` by default, and because we've passed in a `Wallet` it
|
845
|
+
* Will also sign the transaction for us before submitting the signed transaction binary blob to the ledger.
|
846
|
+
*
|
847
|
+
* This is similar to `submitAndWait` which does all of the above, but also waits to see if the transaction has been validated.
|
848
|
+
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
849
|
+
* @param opts - (Optional) Options used to sign and submit a transaction.
|
850
|
+
* @param opts.autofill - If true, autofill a transaction.
|
851
|
+
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
852
|
+
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
853
|
+
* @throws Connection errors: If the `Client` object is unable to establish a connection to the specified WebSocket endpoint,
|
854
|
+
* an error will be thrown.
|
855
|
+
* @throws Transaction errors: If the submitted transaction is invalid or cannot be included in a validated ledger for any
|
856
|
+
* reason, the promise returned by `submitAndWait()` will be rejected with an error. This could include issues with insufficient
|
857
|
+
* balance, invalid transaction fields, or other issues specific to the transaction being submitted.
|
858
|
+
* @throws Ledger errors: If the ledger being used to submit the transaction is undergoing maintenance or otherwise unavailable,
|
859
|
+
* an error will be thrown.
|
860
|
+
* @throws Timeout errors: If the transaction takes longer than the specified timeout period to be included in a validated
|
861
|
+
* ledger, the promise returned by `submitAndWait()` will be rejected with an error.
|
862
|
+
* @returns A promise that contains TxResponse, that will return when the transaction has been validated.
|
863
|
+
*/
|
864
|
+
public async submitAndWait<
|
865
|
+
T extends SubmittableTransaction = SubmittableTransaction,
|
866
|
+
>(
|
867
|
+
transaction: T | string,
|
868
|
+
opts?: {
|
869
|
+
// If true, autofill a transaction.
|
870
|
+
autofill?: boolean
|
871
|
+
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
872
|
+
failHard?: boolean
|
873
|
+
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
874
|
+
wallet?: Wallet
|
875
|
+
},
|
876
|
+
): Promise<TxResponse<T>> {
|
877
|
+
const signedTx = await getSignedTx(this, transaction, opts)
|
878
|
+
|
879
|
+
const lastLedger = getLastLedgerSequence(signedTx)
|
880
|
+
if (lastLedger == null) {
|
881
|
+
throw new ValidationError(
|
882
|
+
'Transaction must contain a LastLedgerSequence value for reliable submission.',
|
883
|
+
)
|
884
|
+
}
|
885
|
+
|
886
|
+
const response = await submitRequest(this, signedTx, opts?.failHard)
|
887
|
+
|
888
|
+
const txHash = hashes.hashSignedTx(signedTx)
|
889
|
+
return waitForFinalTransactionOutcome(
|
890
|
+
this,
|
891
|
+
txHash,
|
892
|
+
lastLedger,
|
893
|
+
response.result.engine_result,
|
894
|
+
)
|
895
|
+
}
|
896
|
+
|
897
|
+
/**
|
898
|
+
* Deprecated: Use autofill instead, provided for users familiar with v1
|
899
|
+
*
|
900
|
+
* @param transaction - A {@link Transaction} in JSON format
|
901
|
+
* @param signersCount - The expected number of signers for this transaction.
|
902
|
+
* Only used for multisigned transactions.
|
687
903
|
* @deprecated Use autofill instead, provided for users familiar with v1
|
688
904
|
*/
|
689
|
-
public prepareTransaction
|
905
|
+
public async prepareTransaction(
|
906
|
+
transaction: SubmittableTransaction,
|
907
|
+
signersCount?: number,
|
908
|
+
): ReturnType<Client['autofill']> {
|
909
|
+
return this.autofill(transaction, signersCount)
|
910
|
+
}
|
690
911
|
|
691
912
|
/**
|
913
|
+
* Retrieves the XRP balance of a given account address.
|
914
|
+
*
|
692
915
|
* @category Abstraction
|
916
|
+
*
|
917
|
+
* @example
|
918
|
+
* ```ts
|
919
|
+
* const client = new Client(wss://s.altnet.rippletest.net:51233)
|
920
|
+
* await client.connect()
|
921
|
+
* const balance = await client.getXrpBalance('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn')
|
922
|
+
* console.log(balance)
|
923
|
+
* await client.disconnect()
|
924
|
+
* /// '200'
|
925
|
+
* ```
|
926
|
+
*
|
927
|
+
* @param address - The XRP address to retrieve the balance for.
|
928
|
+
* @param [options] - Additional options for fetching the balance (optional).
|
929
|
+
* @param [options.ledger_hash] - The hash of the ledger to retrieve the balance from (optional).
|
930
|
+
* @param [options.ledger_index] - The index of the ledger to retrieve the balance from (optional).
|
931
|
+
* @returns A promise that resolves with the XRP balance as a number.
|
693
932
|
*/
|
694
|
-
public
|
933
|
+
public async getXrpBalance(
|
934
|
+
address: string,
|
935
|
+
options: {
|
936
|
+
ledger_hash?: string
|
937
|
+
ledger_index?: LedgerIndex
|
938
|
+
} = {},
|
939
|
+
): Promise<number> {
|
940
|
+
const xrpRequest: AccountInfoRequest = {
|
941
|
+
command: 'account_info',
|
942
|
+
account: address,
|
943
|
+
ledger_index: options.ledger_index ?? 'validated',
|
944
|
+
ledger_hash: options.ledger_hash,
|
945
|
+
}
|
946
|
+
const response = await this.request(xrpRequest)
|
947
|
+
return dropsToXrp(response.result.account_data.Balance)
|
948
|
+
}
|
695
949
|
|
696
950
|
/**
|
951
|
+
* Get XRP/non-XRP balances for an account.
|
952
|
+
*
|
697
953
|
* @category Abstraction
|
954
|
+
*
|
955
|
+
* @example
|
956
|
+
* ```ts
|
957
|
+
* const { Client } = require('xrpl')
|
958
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
959
|
+
* await client.connect()
|
960
|
+
*
|
961
|
+
* async function getAccountBalances(address) {
|
962
|
+
* try {
|
963
|
+
* const options = {
|
964
|
+
* ledger_index: 'validated',
|
965
|
+
* limit: 10
|
966
|
+
* };
|
967
|
+
*
|
968
|
+
* const balances = await xrplClient.getBalances(address, options);
|
969
|
+
*
|
970
|
+
* console.log('Account Balances:');
|
971
|
+
* balances.forEach((balance) => {
|
972
|
+
* console.log(`Currency: ${balance.currency}`);
|
973
|
+
* console.log(`Value: ${balance.value}`);
|
974
|
+
* console.log(`Issuer: ${balance.issuer}`);
|
975
|
+
* console.log('---');
|
976
|
+
* });
|
977
|
+
* } catch (error) {
|
978
|
+
* console.error('Error retrieving account balances:', error);
|
979
|
+
* }
|
980
|
+
* }
|
981
|
+
*
|
982
|
+
* const address = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh';
|
983
|
+
* await getAccountBalances(address);
|
984
|
+
* await client.disconnect();
|
985
|
+
* ```
|
986
|
+
*
|
987
|
+
* @param address - Address of the account to retrieve balances for.
|
988
|
+
* @param options - Allows the client to specify a ledger_hash, ledger_index,
|
989
|
+
* filter by peer, and/or limit number of balances.
|
990
|
+
* @param options.ledger_index - Retrieve the account balances at a given
|
991
|
+
* ledger_index.
|
992
|
+
* @param options.ledger_hash - Retrieve the account balances at the ledger with
|
993
|
+
* a given ledger_hash.
|
994
|
+
* @param options.peer - Filter balances by peer.
|
995
|
+
* @param options.limit - Limit number of balances to return.
|
996
|
+
* @returns An array of XRP/non-XRP balances for the given account.
|
698
997
|
*/
|
699
|
-
|
998
|
+
/* eslint-disable max-lines-per-function -- getBalances requires more lines to implement logic */
|
999
|
+
public async getBalances(
|
1000
|
+
address: string,
|
1001
|
+
options: {
|
1002
|
+
ledger_hash?: string
|
1003
|
+
ledger_index?: LedgerIndex
|
1004
|
+
peer?: string
|
1005
|
+
limit?: number
|
1006
|
+
} = {},
|
1007
|
+
): Promise<
|
1008
|
+
Array<{ value: string; currency: string; issuer?: string | undefined }>
|
1009
|
+
> {
|
1010
|
+
const balances: Balance[] = []
|
1011
|
+
|
1012
|
+
// get XRP balance
|
1013
|
+
let xrpPromise: Promise<number> = Promise.resolve(0)
|
1014
|
+
if (!options.peer) {
|
1015
|
+
xrpPromise = this.getXrpBalance(address, {
|
1016
|
+
ledger_hash: options.ledger_hash,
|
1017
|
+
ledger_index: options.ledger_index,
|
1018
|
+
})
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
// get non-XRP balances
|
1022
|
+
const linesRequest: AccountLinesRequest = {
|
1023
|
+
command: 'account_lines',
|
1024
|
+
account: address,
|
1025
|
+
ledger_index: options.ledger_index ?? 'validated',
|
1026
|
+
ledger_hash: options.ledger_hash,
|
1027
|
+
peer: options.peer,
|
1028
|
+
limit: options.limit,
|
1029
|
+
}
|
1030
|
+
const linesPromise = this.requestAll(linesRequest)
|
1031
|
+
|
1032
|
+
// combine results
|
1033
|
+
await Promise.all([xrpPromise, linesPromise]).then(
|
1034
|
+
([xrpBalance, linesResponses]) => {
|
1035
|
+
const accountLinesBalance = linesResponses.flatMap((response) =>
|
1036
|
+
formatBalances(response.result.lines),
|
1037
|
+
)
|
1038
|
+
if (xrpBalance !== 0) {
|
1039
|
+
balances.push({ currency: 'XRP', value: xrpBalance.toString() })
|
1040
|
+
}
|
1041
|
+
balances.push(...accountLinesBalance)
|
1042
|
+
},
|
1043
|
+
)
|
1044
|
+
return balances.slice(0, options.limit)
|
1045
|
+
}
|
1046
|
+
/* eslint-enable max-lines-per-function */
|
700
1047
|
|
701
1048
|
/**
|
1049
|
+
* Fetch orderbook (buy/sell orders) between two currency pairs. This checks both sides of the orderbook
|
1050
|
+
* by making two `order_book` requests (with the second reversing takerPays and takerGets). Returned offers are
|
1051
|
+
* not normalized in this function, so either currency could be takerGets or takerPays.
|
1052
|
+
*
|
702
1053
|
* @category Abstraction
|
1054
|
+
*
|
1055
|
+
* @param currency1 - Specification of one currency involved. (With a currency code and optionally an issuer)
|
1056
|
+
* @param currency2 - Specification of a second currency involved. (With a currency code and optionally an issuer)
|
1057
|
+
* @param options - Options allowing the client to specify ledger_index,
|
1058
|
+
* ledger_hash, filter by taker, and/or limit number of orders.
|
1059
|
+
* @param options.ledger_index - Retrieve the orderbook at a given ledger_index.
|
1060
|
+
* @param options.ledger_hash - Retrieve the orderbook at the ledger with a
|
1061
|
+
* given ledger_hash.
|
1062
|
+
* @param options.taker - Filter orders by taker.
|
1063
|
+
* @param options.limit - The limit passed into each book_offers request.
|
1064
|
+
* Can return more than this due to two calls being made. Defaults to 20.
|
1065
|
+
* @returns An object containing buy and sell objects.
|
703
1066
|
*/
|
704
|
-
|
1067
|
+
|
1068
|
+
public async getOrderbook(
|
1069
|
+
currency1: BookOfferCurrency,
|
1070
|
+
currency2: BookOfferCurrency,
|
1071
|
+
options: {
|
1072
|
+
limit?: number
|
1073
|
+
ledger_index?: LedgerIndex
|
1074
|
+
ledger_hash?: string | null
|
1075
|
+
taker?: string | null
|
1076
|
+
} = {},
|
1077
|
+
): Promise<{
|
1078
|
+
buy: BookOffer[]
|
1079
|
+
sell: BookOffer[]
|
1080
|
+
}> {
|
1081
|
+
validateOrderbookOptions(options)
|
1082
|
+
|
1083
|
+
const request = createBookOffersRequest(currency1, currency2, options)
|
1084
|
+
|
1085
|
+
const directOfferResults = await requestAllOffers(this, request)
|
1086
|
+
const reverseOfferResults = await requestAllOffers(
|
1087
|
+
this,
|
1088
|
+
reverseRequest(request),
|
1089
|
+
)
|
1090
|
+
|
1091
|
+
const directOffers = extractOffers(directOfferResults)
|
1092
|
+
const reverseOffers = extractOffers(reverseOfferResults)
|
1093
|
+
|
1094
|
+
const orders = combineOrders(directOffers, reverseOffers)
|
1095
|
+
|
1096
|
+
const { buy, sell } = separateBuySellOrders(orders)
|
1097
|
+
|
1098
|
+
/*
|
1099
|
+
* Sort the orders
|
1100
|
+
* for both buys and sells, lowest quality is closest to mid-market
|
1101
|
+
* we sort the orders so that earlier orders are closer to mid-market
|
1102
|
+
*/
|
1103
|
+
return {
|
1104
|
+
buy: sortAndLimitOffers(buy, options.limit),
|
1105
|
+
sell: sortAndLimitOffers(sell, options.limit),
|
1106
|
+
}
|
1107
|
+
}
|
705
1108
|
|
706
1109
|
/**
|
1110
|
+
* Returns the index of the most recently validated ledger.
|
1111
|
+
*
|
707
1112
|
* @category Abstraction
|
1113
|
+
*
|
1114
|
+
* @returns The most recently validated ledger index.
|
1115
|
+
*
|
1116
|
+
* @example
|
1117
|
+
* ```ts
|
1118
|
+
* const { Client } = require('xrpl')
|
1119
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
1120
|
+
* await client.connect()
|
1121
|
+
* const ledgerIndex = await client.getLedgerIndex()
|
1122
|
+
* console.log(ledgerIndex)
|
1123
|
+
* // 884039
|
1124
|
+
* ```
|
708
1125
|
*/
|
709
|
-
public getLedgerIndex
|
1126
|
+
public async getLedgerIndex(): Promise<number> {
|
1127
|
+
const ledgerResponse = await this.request({
|
1128
|
+
command: 'ledger',
|
1129
|
+
ledger_index: 'validated',
|
1130
|
+
})
|
1131
|
+
return ledgerResponse.result.ledger_index
|
1132
|
+
}
|
710
1133
|
|
711
1134
|
/**
|
1135
|
+
* The fundWallet() method is used to send an amount of XRP (usually 1000) to a new (randomly generated)
|
1136
|
+
* or existing XRP Ledger wallet.
|
1137
|
+
*
|
712
1138
|
* @category Faucet
|
1139
|
+
*
|
1140
|
+
* @example
|
1141
|
+
*
|
1142
|
+
* Example 1: Fund a randomly generated wallet
|
1143
|
+
* const { Client, Wallet } = require('xrpl')
|
1144
|
+
*
|
1145
|
+
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
1146
|
+
* await client.connect()
|
1147
|
+
* const { balance, wallet } = await client.fundWallet()
|
1148
|
+
*
|
1149
|
+
* Under the hood, this will use `Wallet.generate()` to create a new random wallet, then ask a testnet faucet
|
1150
|
+
* To send it XRP on ledger to make it a real account. If successful, this will return the new account balance in XRP
|
1151
|
+
* Along with the Wallet object to track the keys for that account. If you'd like, you can also re-fill an existing
|
1152
|
+
* Account by passing in a Wallet you already have.
|
1153
|
+
* ```ts
|
1154
|
+
* const api = new xrpl.Client("wss://s.altnet.rippletest.net:51233")
|
1155
|
+
* await api.connect()
|
1156
|
+
* const { wallet, balance } = await api.fundWallet()
|
1157
|
+
* ```
|
1158
|
+
*
|
1159
|
+
* Example 2: Fund wallet using a custom faucet host and known wallet address
|
1160
|
+
*
|
1161
|
+
* `fundWallet` will try to infer the url of a faucet API from the network your client is connected to.
|
1162
|
+
* There are hardcoded default faucets for popular test networks like testnet and devnet.
|
1163
|
+
* However, if you're working with a newer or more obscure network, you may have to specify the faucetHost
|
1164
|
+
* And faucetPath so `fundWallet` can ask that faucet to fund your wallet.
|
1165
|
+
*
|
1166
|
+
* ```ts
|
1167
|
+
* const newWallet = Wallet.generate()
|
1168
|
+
* const { balance, wallet } = await client.fundWallet(newWallet, {
|
1169
|
+
* amount: '10',
|
1170
|
+
* faucetHost: 'https://custom-faucet.example.com',
|
1171
|
+
* faucetPath: '/accounts'
|
1172
|
+
* })
|
1173
|
+
* console.log(`Sent 10 XRP to wallet: ${address} from the given faucet. Resulting balance: ${balance} XRP`)
|
1174
|
+
* } catch (error) {
|
1175
|
+
* console.error(`Failed to fund wallet: ${error}`)
|
1176
|
+
* }
|
1177
|
+
* }
|
1178
|
+
* ```
|
1179
|
+
*
|
1180
|
+
* @param wallet - An existing XRPL Wallet to fund. If undefined or null, a new Wallet will be created.
|
1181
|
+
* @param options - See below.
|
1182
|
+
* @param options.faucetHost - A custom host for a faucet server. On devnet,
|
1183
|
+
* testnet, AMM devnet, and HooksV3 testnet, `fundWallet` will
|
1184
|
+
* attempt to determine the correct server automatically. In other environments,
|
1185
|
+
* or if you would like to customize the faucet host in devnet or testnet,
|
1186
|
+
* you should provide the host using this option.
|
1187
|
+
* @param options.faucetPath - A custom path for a faucet server. On devnet,
|
1188
|
+
* testnet, AMM devnet, and HooksV3 testnet, `fundWallet` will
|
1189
|
+
* attempt to determine the correct path automatically. In other environments,
|
1190
|
+
* or if you would like to customize the faucet path in devnet or testnet,
|
1191
|
+
* you should provide the path using this option.
|
1192
|
+
* Ex: client.fundWallet(null,{'faucet.altnet.rippletest.net', '/accounts'})
|
1193
|
+
* specifies a request to 'faucet.altnet.rippletest.net/accounts' to fund a new wallet.
|
1194
|
+
* @param options.amount - A custom amount to fund, if undefined or null, the default amount will be 1000.
|
1195
|
+
* @returns A Wallet on the Testnet or Devnet that contains some amount of XRP,
|
1196
|
+
* and that wallet's balance in XRP.
|
1197
|
+
* @throws When either Client isn't connected or unable to fund wallet address.
|
713
1198
|
*/
|
714
|
-
public
|
1199
|
+
public async fundWallet(
|
1200
|
+
this: Client,
|
1201
|
+
wallet?: Wallet | null,
|
1202
|
+
options: FundingOptions = {},
|
1203
|
+
): Promise<{
|
1204
|
+
wallet: Wallet
|
1205
|
+
balance: number
|
1206
|
+
}> {
|
1207
|
+
if (!this.isConnected()) {
|
1208
|
+
throw new RippledError('Client not connected, cannot call faucet')
|
1209
|
+
}
|
1210
|
+
const existingWallet = Boolean(wallet)
|
1211
|
+
|
1212
|
+
// Generate a new Wallet if no existing Wallet is provided or its address is invalid to fund
|
1213
|
+
const walletToFund =
|
1214
|
+
wallet && isValidClassicAddress(wallet.classicAddress)
|
1215
|
+
? wallet
|
1216
|
+
: Wallet.generate()
|
1217
|
+
|
1218
|
+
// Create the POST request body
|
1219
|
+
const postBody: FaucetRequestBody = {
|
1220
|
+
destination: walletToFund.classicAddress,
|
1221
|
+
xrpAmount: options.amount,
|
1222
|
+
usageContext: options.usageContext,
|
1223
|
+
userAgent: 'xrpl.js',
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
let startingBalance = 0
|
1227
|
+
if (existingWallet) {
|
1228
|
+
try {
|
1229
|
+
startingBalance = Number(
|
1230
|
+
await this.getXrpBalance(walletToFund.classicAddress),
|
1231
|
+
)
|
1232
|
+
} catch {
|
1233
|
+
/* startingBalance remains what it was previously */
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
return requestFunding(
|
1238
|
+
options,
|
1239
|
+
this,
|
1240
|
+
startingBalance,
|
1241
|
+
walletToFund,
|
1242
|
+
postBody,
|
1243
|
+
)
|
1244
|
+
}
|
715
1245
|
}
|
716
1246
|
|
717
1247
|
export { Client }
|