xrpl 2.13.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/xrpl-latest-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +18279 -74867
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/authorizeChannel.d.ts +3 -0
- package/dist/npm/Wallet/authorizeChannel.d.ts.map +1 -0
- package/dist/npm/Wallet/authorizeChannel.js +14 -0
- package/dist/npm/Wallet/authorizeChannel.js.map +1 -0
- package/dist/npm/Wallet/defaultFaucets.js +1 -1
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/Wallet/fundWallet.d.ts +17 -3
- package/dist/npm/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/Wallet/fundWallet.js +53 -78
- package/dist/npm/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/Wallet/index.d.ts.map +1 -1
- package/dist/npm/Wallet/index.js +24 -23
- package/dist/npm/Wallet/index.js.map +1 -1
- package/dist/npm/Wallet/signer.d.ts +2 -4
- package/dist/npm/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/Wallet/signer.js +17 -13
- package/dist/npm/Wallet/signer.js.map +1 -1
- package/dist/npm/Wallet/walletFromSecretNumbers.js +2 -2
- package/dist/npm/Wallet/walletFromSecretNumbers.js.map +1 -1
- package/dist/npm/client/RequestManager.d.ts +3 -2
- package/dist/npm/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/client/RequestManager.js +25 -1
- package/dist/npm/client/RequestManager.js.map +1 -1
- package/dist/npm/client/connection.d.ts +8 -11
- package/dist/npm/client/connection.d.ts.map +1 -1
- package/dist/npm/client/connection.js +8 -54
- package/dist/npm/client/connection.js.map +1 -1
- package/dist/npm/client/index.d.ts +56 -78
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +155 -42
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts +4 -2
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js.map +1 -1
- package/dist/npm/errors.d.ts.map +1 -1
- package/dist/npm/errors.js +1 -2
- package/dist/npm/errors.js.map +1 -1
- package/dist/npm/index.d.ts +1 -1
- package/dist/npm/index.d.ts.map +1 -1
- package/dist/npm/index.js +1 -3
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/models/ledger/AccountRoot.js +1 -1
- package/dist/npm/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/models/ledger/Offer.js +1 -1
- package/dist/npm/models/ledger/Offer.js.map +1 -1
- package/dist/npm/models/ledger/RippleState.js +1 -1
- package/dist/npm/models/ledger/RippleState.js.map +1 -1
- package/dist/npm/models/ledger/SignerList.js +1 -1
- package/dist/npm/models/ledger/SignerList.js.map +1 -1
- package/dist/npm/models/methods/index.d.ts +12 -1
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledger.d.ts +35 -7
- package/dist/npm/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/models/methods/subscribe.d.ts +3 -0
- package/dist/npm/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/models/methods/tx.d.ts +1 -1
- package/dist/npm/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js +1 -1
- package/dist/npm/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.js +1 -1
- package/dist/npm/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenAcceptOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenAcceptOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenAcceptOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.js +1 -1
- package/dist/npm/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.d.ts +4 -0
- package/dist/npm/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/models/transactions/NFTokenMint.js +1 -1
- package/dist/npm/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.js +1 -1
- package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -1
- package/dist/npm/models/transactions/accountSet.js +2 -2
- package/dist/npm/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/models/transactions/enableAmendment.js +1 -1
- package/dist/npm/models/transactions/enableAmendment.js.map +1 -1
- package/dist/npm/models/transactions/metadata.d.ts +9 -1
- package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/models/transactions/metadata.js.map +1 -1
- package/dist/npm/models/transactions/offerCreate.js +1 -1
- package/dist/npm/models/transactions/offerCreate.js.map +1 -1
- package/dist/npm/models/transactions/payment.d.ts +5 -0
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/payment.js +1 -1
- package/dist/npm/models/transactions/payment.js.map +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js +1 -1
- package/dist/npm/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +4 -3
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/transactions/trustSet.js +1 -1
- package/dist/npm/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/snippets/src/getTransaction.js +1 -1
- package/dist/npm/snippets/src/getTransaction.js.map +1 -1
- package/dist/npm/snippets/src/paths.js +2 -3
- package/dist/npm/snippets/src/paths.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/authorizeChannel.d.ts +3 -0
- package/dist/npm/src/Wallet/authorizeChannel.d.ts.map +1 -0
- package/dist/npm/src/Wallet/authorizeChannel.js +14 -0
- package/dist/npm/src/Wallet/authorizeChannel.js.map +1 -0
- package/dist/npm/src/Wallet/defaultFaucets.js +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.d.ts +17 -3
- package/dist/npm/src/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.js +53 -78
- package/dist/npm/src/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/src/Wallet/index.d.ts.map +1 -1
- package/dist/npm/src/Wallet/index.js +24 -23
- package/dist/npm/src/Wallet/index.js.map +1 -1
- package/dist/npm/src/Wallet/signer.d.ts +2 -4
- package/dist/npm/src/Wallet/signer.d.ts.map +1 -1
- package/dist/npm/src/Wallet/signer.js +17 -13
- package/dist/npm/src/Wallet/signer.js.map +1 -1
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js +2 -2
- package/dist/npm/src/Wallet/walletFromSecretNumbers.js.map +1 -1
- package/dist/npm/src/client/RequestManager.d.ts +3 -2
- package/dist/npm/src/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/src/client/RequestManager.js +25 -1
- package/dist/npm/src/client/RequestManager.js.map +1 -1
- package/dist/npm/src/client/connection.d.ts +8 -11
- package/dist/npm/src/client/connection.d.ts.map +1 -1
- package/dist/npm/src/client/connection.js +8 -54
- package/dist/npm/src/client/connection.js.map +1 -1
- package/dist/npm/src/client/index.d.ts +56 -78
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +155 -42
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/client/partialPayment.d.ts +4 -2
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js.map +1 -1
- package/dist/npm/src/errors.d.ts.map +1 -1
- package/dist/npm/src/errors.js +1 -2
- package/dist/npm/src/errors.js.map +1 -1
- package/dist/npm/src/index.d.ts +1 -1
- package/dist/npm/src/index.d.ts.map +1 -1
- package/dist/npm/src/index.js +1 -3
- package/dist/npm/src/index.js.map +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js +1 -1
- package/dist/npm/src/models/ledger/AccountRoot.js.map +1 -1
- package/dist/npm/src/models/ledger/Offer.js +1 -1
- package/dist/npm/src/models/ledger/Offer.js.map +1 -1
- package/dist/npm/src/models/ledger/RippleState.js +1 -1
- package/dist/npm/src/models/ledger/RippleState.js.map +1 -1
- package/dist/npm/src/models/ledger/SignerList.js +1 -1
- package/dist/npm/src/models/ledger/SignerList.js.map +1 -1
- package/dist/npm/src/models/methods/index.d.ts +12 -1
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledger.d.ts +35 -7
- package/dist/npm/src/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/src/models/methods/subscribe.d.ts +3 -0
- package/dist/npm/src/models/methods/subscribe.d.ts.map +1 -1
- package/dist/npm/src/models/methods/tx.d.ts +1 -1
- package/dist/npm/src/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js +1 -1
- package/dist/npm/src/models/transactions/AMMDeposit.js.map +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.js +1 -1
- package/dist/npm/src/models/transactions/AMMWithdraw.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenAcceptOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCancelOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js +1 -1
- package/dist/npm/src/models/transactions/NFTokenCreateOffer.js.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts +4 -0
- package/dist/npm/src/models/transactions/NFTokenMint.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js +1 -1
- package/dist/npm/src/models/transactions/NFTokenMint.js.map +1 -1
- package/dist/npm/src/models/transactions/XChainModifyBridge.js +1 -1
- package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -1
- package/dist/npm/src/models/transactions/accountSet.js +2 -2
- package/dist/npm/src/models/transactions/accountSet.js.map +1 -1
- package/dist/npm/src/models/transactions/enableAmendment.js +1 -1
- package/dist/npm/src/models/transactions/enableAmendment.js.map +1 -1
- package/dist/npm/src/models/transactions/metadata.d.ts +9 -1
- package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/metadata.js.map +1 -1
- package/dist/npm/src/models/transactions/offerCreate.js +1 -1
- package/dist/npm/src/models/transactions/offerCreate.js.map +1 -1
- package/dist/npm/src/models/transactions/payment.d.ts +5 -0
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/payment.js +1 -1
- package/dist/npm/src/models/transactions/payment.js.map +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js +1 -1
- package/dist/npm/src/models/transactions/paymentChannelClaim.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +4 -3
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/transactions/trustSet.js +1 -1
- package/dist/npm/src/models/transactions/trustSet.js.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +6 -2
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +9 -28
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/src/sugar/balances.d.ts +2 -17
- package/dist/npm/src/sugar/balances.d.ts.map +1 -1
- package/dist/npm/src/sugar/balances.js +2 -60
- package/dist/npm/src/sugar/balances.js.map +1 -1
- package/dist/npm/src/sugar/getOrderbook.d.ts +19 -5
- package/dist/npm/src/sugar/getOrderbook.d.ts.map +1 -1
- package/dist/npm/src/sugar/getOrderbook.js +72 -53
- package/dist/npm/src/sugar/getOrderbook.js.map +1 -1
- package/dist/npm/src/sugar/index.d.ts +0 -4
- package/dist/npm/src/sugar/index.d.ts.map +1 -1
- package/dist/npm/src/sugar/index.js +0 -13
- package/dist/npm/src/sugar/index.js.map +1 -1
- package/dist/npm/src/sugar/submit.d.ts +6 -9
- package/dist/npm/src/sugar/submit.d.ts.map +1 -1
- package/dist/npm/src/sugar/submit.js +5 -22
- package/dist/npm/src/sugar/submit.js.map +1 -1
- package/dist/npm/src/utils/collections.d.ts +7 -0
- package/dist/npm/src/utils/collections.d.ts.map +1 -0
- package/dist/npm/src/utils/collections.js +22 -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/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/sugar/autofill.d.ts +6 -2
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +9 -28
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/balances.d.ts +2 -17
- package/dist/npm/sugar/balances.d.ts.map +1 -1
- package/dist/npm/sugar/balances.js +2 -60
- package/dist/npm/sugar/balances.js.map +1 -1
- package/dist/npm/sugar/getOrderbook.d.ts +19 -5
- package/dist/npm/sugar/getOrderbook.d.ts.map +1 -1
- package/dist/npm/sugar/getOrderbook.js +72 -53
- package/dist/npm/sugar/getOrderbook.js.map +1 -1
- package/dist/npm/sugar/index.d.ts +0 -4
- package/dist/npm/sugar/index.d.ts.map +1 -1
- package/dist/npm/sugar/index.js +0 -13
- package/dist/npm/sugar/index.js.map +1 -1
- package/dist/npm/sugar/submit.d.ts +6 -9
- package/dist/npm/sugar/submit.d.ts.map +1 -1
- package/dist/npm/sugar/submit.js +5 -22
- package/dist/npm/sugar/submit.js.map +1 -1
- package/dist/npm/utils/collections.d.ts +7 -0
- package/dist/npm/utils/collections.d.ts.map +1 -0
- package/dist/npm/utils/collections.js +22 -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/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/package.json +23 -25
- package/src/Wallet/authorizeChannel.ts +26 -0
- package/src/Wallet/fundWallet.ts +151 -212
- package/src/Wallet/index.ts +28 -25
- package/src/Wallet/signer.ts +32 -43
- package/src/Wallet/walletFromSecretNumbers.ts +1 -1
- package/src/client/RequestManager.ts +40 -14
- package/src/client/connection.ts +20 -89
- package/src/client/index.ts +704 -269
- package/src/client/partialPayment.ts +14 -8
- package/src/errors.ts +1 -3
- package/src/index.ts +1 -3
- package/src/models/ledger/Ledger.ts +1 -1
- package/src/models/methods/index.ts +175 -0
- package/src/models/methods/ledger.ts +149 -20
- package/src/models/methods/subscribe.ts +36 -0
- package/src/models/methods/tx.ts +2 -1
- package/src/models/transactions/NFTokenAcceptOffer.ts +6 -0
- package/src/models/transactions/NFTokenCancelOffer.ts +6 -0
- package/src/models/transactions/NFTokenCreateOffer.ts +6 -0
- package/src/models/transactions/NFTokenMint.ts +6 -0
- package/src/models/transactions/metadata.ts +31 -1
- package/src/models/transactions/payment.ts +6 -0
- package/src/models/transactions/transaction.ts +6 -4
- package/src/sugar/autofill.ts +84 -88
- package/src/sugar/balances.ts +8 -116
- package/src/sugar/getOrderbook.ts +138 -61
- package/src/sugar/index.ts +0 -8
- package/src/sugar/submit.ts +114 -132
- package/src/utils/collections.ts +53 -0
- package/src/utils/getBalanceChanges.ts +2 -3
- package/src/utils/getNFTokenID.ts +18 -16
- package/src/utils/hashes/sha512Half.ts +4 -7
- package/dist/npm/client/BroadcastClient.d.ts +0 -7
- package/dist/npm/client/BroadcastClient.d.ts.map +0 -1
- package/dist/npm/client/BroadcastClient.js +0 -49
- package/dist/npm/client/BroadcastClient.js.map +0 -1
- package/dist/npm/client/WSWrapper.d.ts +0 -25
- package/dist/npm/client/WSWrapper.d.ts.map +0 -1
- package/dist/npm/client/WSWrapper.js +0 -44
- package/dist/npm/client/WSWrapper.js.map +0 -1
- package/dist/npm/src/client/BroadcastClient.d.ts +0 -7
- package/dist/npm/src/client/BroadcastClient.d.ts.map +0 -1
- package/dist/npm/src/client/BroadcastClient.js +0 -49
- package/dist/npm/src/client/BroadcastClient.js.map +0 -1
- package/dist/npm/src/client/WSWrapper.d.ts +0 -25
- package/dist/npm/src/client/WSWrapper.d.ts.map +0 -1
- package/dist/npm/src/client/WSWrapper.js +0 -44
- package/dist/npm/src/client/WSWrapper.js.map +0 -1
- package/dist/npm/src/sugar/getLedgerIndex.d.ts +0 -3
- package/dist/npm/src/sugar/getLedgerIndex.d.ts.map +0 -1
- package/dist/npm/src/sugar/getLedgerIndex.js +0 -22
- package/dist/npm/src/sugar/getLedgerIndex.js.map +0 -1
- package/dist/npm/sugar/getLedgerIndex.d.ts +0 -3
- package/dist/npm/sugar/getLedgerIndex.d.ts.map +0 -1
- package/dist/npm/sugar/getLedgerIndex.js +0 -22
- package/dist/npm/sugar/getLedgerIndex.js.map +0 -1
- package/src/client/BroadcastClient.ts +0 -84
- package/src/client/WSWrapper.ts +0 -106
- package/src/sugar/getLedgerIndex.ts +0 -15
package/src/sugar/submit.ts
CHANGED
@@ -6,7 +6,6 @@ import { Signer } from '../models/common'
|
|
6
6
|
import { TxRequest, TxResponse } from '../models/methods'
|
7
7
|
import { Transaction } from '../models/transactions'
|
8
8
|
import { BaseTransaction } from '../models/transactions/common'
|
9
|
-
import { hashes } from '../utils'
|
10
9
|
|
11
10
|
/** Approximate time for a ledger to close, in milliseconds */
|
12
11
|
const LEDGER_CLOSE_TIME = 1000
|
@@ -17,130 +16,31 @@ async function sleep(ms: number): Promise<void> {
|
|
17
16
|
})
|
18
17
|
}
|
19
18
|
|
20
|
-
|
21
|
-
* Submits a signed/unsigned transaction.
|
22
|
-
* Steps performed on a transaction:
|
23
|
-
* 1. Autofill.
|
24
|
-
* 2. Sign & Encode.
|
25
|
-
* 3. Submit.
|
26
|
-
*
|
27
|
-
* @param this - A Client.
|
28
|
-
* @param transaction - A transaction to autofill, sign & encode, and submit.
|
29
|
-
* @param opts - (Optional) Options used to sign and submit a transaction.
|
30
|
-
* @param opts.autofill - If true, autofill a transaction.
|
31
|
-
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
32
|
-
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
33
|
-
* @returns A promise that contains SubmitResponse.
|
34
|
-
* @throws RippledError if submit request fails.
|
35
|
-
*/
|
36
|
-
async function submit(
|
37
|
-
this: Client,
|
38
|
-
transaction: Transaction | string,
|
39
|
-
opts?: {
|
40
|
-
// If true, autofill a transaction.
|
41
|
-
autofill?: boolean
|
42
|
-
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
43
|
-
failHard?: boolean
|
44
|
-
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
45
|
-
wallet?: Wallet
|
46
|
-
},
|
47
|
-
): Promise<SubmitResponse> {
|
48
|
-
const signedTx = await getSignedTx(this, transaction, opts)
|
49
|
-
return submitRequest(this, signedTx, opts?.failHard)
|
50
|
-
}
|
19
|
+
// Helper functions
|
51
20
|
|
52
21
|
/**
|
53
|
-
*
|
54
|
-
* validated ledger (or has errored/will not be included for some reason).
|
55
|
-
* See [Reliable Transaction Submission](https://xrpl.org/reliable-transaction-submission.html).
|
56
|
-
*
|
57
|
-
* @example
|
58
|
-
*
|
59
|
-
* ```ts
|
60
|
-
* const { Client, Wallet } = require('xrpl')
|
61
|
-
* const client = new Client('wss://s.altnet.rippletest.net:51233')
|
62
|
-
*
|
63
|
-
* async function submitTransaction() {
|
64
|
-
* const senderWallet = client.fundWallet()
|
65
|
-
* const recipientWallet = client.fundWallet()
|
66
|
-
*
|
67
|
-
* const transaction = {
|
68
|
-
* TransactionType: 'Payment',
|
69
|
-
* Account: senderWallet.address,
|
70
|
-
* Destination: recipientWallet.address,
|
71
|
-
* Amount: '10'
|
72
|
-
* }
|
73
|
-
*
|
74
|
-
* try {
|
75
|
-
* await client.submit(signedTransaction, { wallet: senderWallet })
|
76
|
-
* console.log(result)
|
77
|
-
* } catch (error) {
|
78
|
-
* console.error(`Failed to submit transaction: ${error}`)
|
79
|
-
* }
|
80
|
-
* }
|
81
|
-
*
|
82
|
-
* submitTransaction()
|
83
|
-
* ```
|
22
|
+
* Submits a request to the client with a signed transaction.
|
84
23
|
*
|
85
|
-
*
|
24
|
+
* @param client - The client to submit the request to.
|
25
|
+
* @param signedTransaction - The signed transaction to submit. It can be either a Transaction object or a
|
26
|
+
* string (encode from ripple-binary-codec) representation of the transaction.
|
27
|
+
* @param [failHard=false] - Optional. Determines whether the submission should fail hard (true) or not (false). Default is false.
|
28
|
+
* @returns A promise that resolves with the response from the client.
|
29
|
+
* @throws {ValidationError} If the signed transaction is not valid (not signed).
|
86
30
|
*
|
87
|
-
*
|
88
|
-
*
|
31
|
+
* @example
|
32
|
+
* import { Client } from "xrpl"
|
33
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233");
|
34
|
+
* await client.connect();
|
35
|
+
* const signedTransaction = createSignedTransaction();
|
36
|
+
* // Example 1: Submitting a Transaction object
|
37
|
+
* const response1 = await submitRequest(client, signedTransaction);
|
89
38
|
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
93
|
-
* @param opts - (Optional) Options used to sign and submit a transaction.
|
94
|
-
* @param opts.autofill - If true, autofill a transaction.
|
95
|
-
* @param opts.failHard - If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
96
|
-
* @param opts.wallet - A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
97
|
-
* @throws Connection errors: If the `Client` object is unable to establish a connection to the specified WebSocket endpoint,
|
98
|
-
* an error will be thrown.
|
99
|
-
* @throws Transaction errors: If the submitted transaction is invalid or cannot be included in a validated ledger for any
|
100
|
-
* reason, the promise returned by `submitAndWait()` will be rejected with an error. This could include issues with insufficient
|
101
|
-
* balance, invalid transaction fields, or other issues specific to the transaction being submitted.
|
102
|
-
* @throws Ledger errors: If the ledger being used to submit the transaction is undergoing maintenance or otherwise unavailable,
|
103
|
-
* an error will be thrown.
|
104
|
-
* @throws Timeout errors: If the transaction takes longer than the specified timeout period to be included in a validated
|
105
|
-
* ledger, the promise returned by `submitAndWait()` will be rejected with an error.
|
106
|
-
* @returns A promise that contains TxResponse, that will return when the transaction has been validated.
|
39
|
+
* // Example 2: Submitting a string representation of the transaction
|
40
|
+
* const signedTransactionString = encode(signedTransaction);
|
41
|
+
* const response2 = await submitRequest(client, signedTransactionString, true);
|
107
42
|
*/
|
108
|
-
async function
|
109
|
-
this: Client,
|
110
|
-
transaction: T | string,
|
111
|
-
opts?: {
|
112
|
-
// If true, autofill a transaction.
|
113
|
-
autofill?: boolean
|
114
|
-
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
115
|
-
failHard?: boolean
|
116
|
-
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
117
|
-
wallet?: Wallet
|
118
|
-
},
|
119
|
-
): Promise<TxResponse<T>> {
|
120
|
-
const signedTx = await getSignedTx(this, transaction, opts)
|
121
|
-
|
122
|
-
const lastLedger = getLastLedgerSequence(signedTx)
|
123
|
-
if (lastLedger == null) {
|
124
|
-
throw new ValidationError(
|
125
|
-
'Transaction must contain a LastLedgerSequence value for reliable submission.',
|
126
|
-
)
|
127
|
-
}
|
128
|
-
|
129
|
-
const response = await submitRequest(this, signedTx, opts?.failHard)
|
130
|
-
|
131
|
-
const txHash = hashes.hashSignedTx(signedTx)
|
132
|
-
return waitForFinalTransactionOutcome(
|
133
|
-
this,
|
134
|
-
txHash,
|
135
|
-
lastLedger,
|
136
|
-
response.result.engine_result,
|
137
|
-
)
|
138
|
-
}
|
139
|
-
|
140
|
-
// Helper functions
|
141
|
-
|
142
|
-
// Encodes and submits a signed transaction.
|
143
|
-
async function submitRequest(
|
43
|
+
export async function submitRequest(
|
144
44
|
client: Client,
|
145
45
|
signedTransaction: Transaction | string,
|
146
46
|
failHard = false,
|
@@ -161,14 +61,49 @@ async function submitRequest(
|
|
161
61
|
return client.request(request)
|
162
62
|
}
|
163
63
|
|
164
|
-
|
165
|
-
*
|
166
|
-
*
|
167
|
-
*
|
168
|
-
*
|
64
|
+
/**
|
65
|
+
* Waits for the final outcome of a transaction by polling the ledger until the result can be considered final,
|
66
|
+
* meaning it has either been included in a validated ledger, or the transaction's lastLedgerSequence has been
|
67
|
+
* surpassed by the latest ledger sequence (meaning it will never be included in a validated ledger).
|
68
|
+
*
|
69
|
+
* @template T - The type of the transaction. Defaults to `Transaction`.
|
70
|
+
* @param client - The client to use for requesting transaction information.
|
71
|
+
* @param txHash - The hash of the transaction to wait for.
|
72
|
+
* @param lastLedger - The last ledger sequence of the transaction.
|
73
|
+
* @param submissionResult - The preliminary result of the transaction.
|
74
|
+
* @returns A promise that resolves with the final transaction response.
|
75
|
+
*
|
76
|
+
* @throws {XrplError} If the latest ledger sequence surpasses the transaction's lastLedgerSequence.
|
77
|
+
*
|
78
|
+
* @example
|
79
|
+
* import { hashes, Client } from "xrpl"
|
80
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233")
|
81
|
+
* await client.connect()
|
82
|
+
*
|
83
|
+
* const transaction = createTransaction() // your transaction function
|
84
|
+
*
|
85
|
+
* const signedTx = await getSignedTx(this, transaction)
|
86
|
+
*
|
87
|
+
* const lastLedger = getLastLedgerSequence(signedTx)
|
88
|
+
*
|
89
|
+
* if (lastLedger == null) {
|
90
|
+
* throw new ValidationError(
|
91
|
+
* 'Transaction must contain a LastLedgerSequence value for reliable submission.',
|
92
|
+
* )
|
93
|
+
* }
|
94
|
+
*
|
95
|
+
* const response = await submitRequest(this, signedTx, opts?.failHard)
|
96
|
+
*
|
97
|
+
* const txHash = hashes.hashSignedTx(signedTx)
|
98
|
+
* return waitForFinalTransactionOutcome(
|
99
|
+
* this,
|
100
|
+
* txHash,
|
101
|
+
* lastLedger,
|
102
|
+
* response.result.engine_result,
|
103
|
+
* )
|
169
104
|
*/
|
170
105
|
// eslint-disable-next-line max-params, max-lines-per-function -- this function needs to display and do with more information.
|
171
|
-
async function waitForFinalTransactionOutcome<
|
106
|
+
export async function waitForFinalTransactionOutcome<
|
172
107
|
T extends BaseTransaction = Transaction,
|
173
108
|
>(
|
174
109
|
client: Client,
|
@@ -248,8 +183,40 @@ function isSigned(transaction: Transaction | string): boolean {
|
|
248
183
|
return tx.SigningPubKey != null && tx.TxnSignature != null
|
249
184
|
}
|
250
185
|
|
251
|
-
|
252
|
-
|
186
|
+
/**
|
187
|
+
* Updates a transaction with `autofill` then signs it if it is unsigned.
|
188
|
+
*
|
189
|
+
* @param client - The client from which to retrieve the signed transaction.
|
190
|
+
* @param transaction - The transaction to retrieve. It can be either a Transaction object or
|
191
|
+
* a string (encode from ripple-binary-codec) representation of the transaction.
|
192
|
+
* @param [options={}] - Optional. Additional options for retrieving the signed transaction.
|
193
|
+
* @param [options.autofill=true] - Optional. Determines whether the transaction should be autofilled (true)
|
194
|
+
* or not (false). Default is true.
|
195
|
+
* @param [options.wallet] - Optional. A wallet to sign the transaction. It must be provided when submitting
|
196
|
+
* an unsigned transaction. Default is undefined.
|
197
|
+
* @returns A promise that resolves with the signed transaction.
|
198
|
+
*
|
199
|
+
* @throws {ValidationError} If the transaction is not signed and no wallet is provided.
|
200
|
+
*
|
201
|
+
* @example
|
202
|
+
* import { Client } from "xrpl"
|
203
|
+
* import { encode } from "ripple-binary-codec"
|
204
|
+
*
|
205
|
+
* const client = new Client("wss://s.altnet.rippletest.net:51233");
|
206
|
+
* await client.connect():
|
207
|
+
* const transaction = createTransaction(); // createTransaction is your function to create a transaction
|
208
|
+
* const options = {
|
209
|
+
* autofill: true,
|
210
|
+
* wallet: myWallet,
|
211
|
+
* };
|
212
|
+
*
|
213
|
+
* // Example 1: Retrieving a signed Transaction object
|
214
|
+
* const signedTx1 = await getSignedTx(client, transaction, options);
|
215
|
+
*
|
216
|
+
* // Example 2: Retrieving a string representation of the signed transaction
|
217
|
+
* const signedTxString = await getSignedTx(client, encode(transaction), options);
|
218
|
+
*/
|
219
|
+
export async function getSignedTx(
|
253
220
|
client: Client,
|
254
221
|
transaction: Transaction | string,
|
255
222
|
{
|
@@ -258,8 +225,6 @@ async function getSignedTx(
|
|
258
225
|
}: {
|
259
226
|
// If true, autofill a transaction.
|
260
227
|
autofill?: boolean
|
261
|
-
// If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
|
262
|
-
failHard?: boolean
|
263
228
|
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
264
229
|
wallet?: Wallet
|
265
230
|
} = {},
|
@@ -288,7 +253,26 @@ async function getSignedTx(
|
|
288
253
|
}
|
289
254
|
|
290
255
|
// checks if there is a LastLedgerSequence as a part of the transaction
|
291
|
-
|
256
|
+
/**
|
257
|
+
* Retrieves the last ledger sequence from a transaction.
|
258
|
+
*
|
259
|
+
* @param transaction - The transaction to retrieve the last ledger sequence from. It can be either a Transaction object or
|
260
|
+
* a string (encode from ripple-binary-codec) representation of the transaction.
|
261
|
+
* @returns The last ledger sequence of the transaction, or null if not available.
|
262
|
+
*
|
263
|
+
* @example
|
264
|
+
* const transaction = createTransaction(); // your function to create a transaction
|
265
|
+
*
|
266
|
+
* // Example 1: Retrieving the last ledger sequence from a Transaction object
|
267
|
+
* const lastLedgerSequence1 = getLastLedgerSequence(transaction);
|
268
|
+
* console.log(lastLedgerSequence1); // Output: 12345
|
269
|
+
*
|
270
|
+
* // Example 2: Retrieving the last ledger sequence from a string representation of the transaction
|
271
|
+
* const transactionString = encode(transaction);
|
272
|
+
* const lastLedgerSequence2 = getLastLedgerSequence(transactionString);
|
273
|
+
* console.log(lastLedgerSequence2); // Output: 67890
|
274
|
+
*/
|
275
|
+
export function getLastLedgerSequence(
|
292
276
|
transaction: Transaction | string,
|
293
277
|
): number | null {
|
294
278
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
@@ -301,5 +285,3 @@ function isAccountDelete(transaction: Transaction | string): boolean {
|
|
301
285
|
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
|
302
286
|
return tx.TransactionType === 'AccountDelete'
|
303
287
|
}
|
304
|
-
|
305
|
-
export { submit, submitAndWait }
|
@@ -0,0 +1,53 @@
|
|
1
|
+
type ValueOf<T> = T[keyof T]
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Creates an object composed of keys generated from the results of running each element of collection thru iteratee.
|
5
|
+
* The order of grouped values is determined by the order they occur in collection.
|
6
|
+
* The corresponding value of each key is an array of elements responsible for generating the key.
|
7
|
+
*
|
8
|
+
* Similar to lodash's groupBy
|
9
|
+
*
|
10
|
+
* @param array - array to iterate over
|
11
|
+
* @param iteratee - function that returns key of the group to place the item
|
12
|
+
*
|
13
|
+
* @returns a map of arrays
|
14
|
+
*/
|
15
|
+
export function groupBy<T>(
|
16
|
+
array: T[],
|
17
|
+
iteratee: (value: T, index: number, array: T[]) => string,
|
18
|
+
): { [p: string]: T[] } {
|
19
|
+
// eslint-disable-next-line max-params -- need all the params for the fallback
|
20
|
+
return array.reduce<{ [key: string]: T[] }>(function predicate(
|
21
|
+
acc,
|
22
|
+
value,
|
23
|
+
index,
|
24
|
+
arrayReference,
|
25
|
+
) {
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- being safe for js users
|
27
|
+
;(acc[iteratee(value, index, arrayReference)] ||= []).push(value)
|
28
|
+
return acc
|
29
|
+
},
|
30
|
+
{})
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Creates an object composed of the own and inherited enumerable string keyed properties of object that
|
35
|
+
* predicate doesn't return truthy for.
|
36
|
+
*
|
37
|
+
* @param obj - Object to have properties removed.
|
38
|
+
* @param predicate - function that returns whether the property should be removed from the obj.
|
39
|
+
*
|
40
|
+
* @returns object
|
41
|
+
*/
|
42
|
+
export function omitBy<T extends object>(
|
43
|
+
obj: T,
|
44
|
+
predicate: (objElement: ValueOf<T>, k: string | number | symbol) => boolean,
|
45
|
+
): Partial<T> {
|
46
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- We know the keys are properties of T
|
47
|
+
const keys: Array<keyof T> = Object.keys(obj) as Array<keyof T>
|
48
|
+
const keysToKeep = keys.filter((kb) => !predicate(obj[kb], kb))
|
49
|
+
return keysToKeep.reduce((acc: Partial<T>, key: keyof T) => {
|
50
|
+
acc[key] = obj[key]
|
51
|
+
return acc
|
52
|
+
}, {})
|
53
|
+
}
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import BigNumber from 'bignumber.js'
|
2
|
-
import flatten from 'lodash/flatten'
|
3
|
-
import groupBy from 'lodash/groupBy'
|
4
2
|
|
5
3
|
import {
|
6
4
|
Amount,
|
@@ -10,6 +8,7 @@ import {
|
|
10
8
|
Node,
|
11
9
|
} from '../models'
|
12
10
|
|
11
|
+
import { groupBy } from './collections'
|
13
12
|
import { dropsToXrp } from './xrpConversion'
|
14
13
|
|
15
14
|
interface BalanceChange {
|
@@ -182,5 +181,5 @@ export default function getBalanceChanges(
|
|
182
181
|
}
|
183
182
|
return []
|
184
183
|
})
|
185
|
-
return groupByAccount(
|
184
|
+
return groupByAccount(quantities.flat())
|
186
185
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import flatMap from 'lodash/flatMap'
|
2
1
|
import { decode } from 'ripple-binary-codec'
|
3
2
|
|
4
3
|
import { NFToken } from '../models/ledger/NFTokenPage'
|
@@ -33,6 +32,7 @@ function ensureDecodedMeta(
|
|
33
32
|
* @returns The NFTokenID for the minted NFT.
|
34
33
|
* @throws if meta is not TransactionMetadata.
|
35
34
|
*/
|
35
|
+
// eslint-disable-next-line max-lines-per-function -- This function has a lot of documentation
|
36
36
|
export default function getNFTokenID(
|
37
37
|
meta: TransactionMetadata | string | undefined,
|
38
38
|
): string | undefined {
|
@@ -57,7 +57,6 @@ export default function getNFTokenID(
|
|
57
57
|
* not changed. Thus why we add the additional condition to check
|
58
58
|
* if the PreviousFields contains NFTokens
|
59
59
|
*/
|
60
|
-
|
61
60
|
const affectedNodes = decodedMeta.AffectedNodes.filter((node) => {
|
62
61
|
if (isCreatedNode(node)) {
|
63
62
|
return node.CreatedNode.LedgerEntryType === 'NFTokenPage'
|
@@ -72,25 +71,28 @@ export default function getNFTokenID(
|
|
72
71
|
})
|
73
72
|
/* eslint-disable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
|
74
73
|
const previousTokenIDSet = new Set(
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
affectedNodes
|
75
|
+
.flatMap((node) => {
|
76
|
+
const nftokens = isModifiedNode(node)
|
77
|
+
? (node.ModifiedNode.PreviousFields?.NFTokens as NFToken[])
|
78
|
+
: []
|
79
|
+
return nftokens.map((token) => token.NFToken.NFTokenID)
|
80
|
+
})
|
81
|
+
.filter((id) => Boolean(id)),
|
81
82
|
)
|
82
83
|
|
83
84
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
|
84
|
-
const finalTokenIDs =
|
85
|
-
(
|
86
|
-
(
|
87
|
-
(node as
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
const finalTokenIDs = affectedNodes
|
86
|
+
.flatMap((node) =>
|
87
|
+
(
|
88
|
+
(((node as ModifiedNode).ModifiedNode?.FinalFields?.NFTokens ??
|
89
|
+
(node as CreatedNode).CreatedNode?.NewFields
|
90
|
+
?.NFTokens) as NFToken[]) ?? []
|
91
|
+
).map((token) => token.NFToken.NFTokenID),
|
92
|
+
)
|
93
|
+
.filter((nftokenID) => Boolean(nftokenID))
|
91
94
|
/* eslint-enable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
|
92
95
|
/* eslint-enable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
|
93
|
-
|
94
96
|
const nftokenID = finalTokenIDs.find((id) => !previousTokenIDSet.has(id))
|
95
97
|
|
96
98
|
return nftokenID
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { sha512 } from '@xrplf/isomorphic/sha512'
|
2
|
+
import { bytesToHex, hexToBytes } from '@xrplf/isomorphic/utils'
|
2
3
|
|
3
|
-
const
|
4
|
+
const HASH_BYTES = 32
|
4
5
|
|
5
6
|
/**
|
6
7
|
* Compute a sha512Half Hash of a hex string.
|
@@ -9,11 +10,7 @@ const HASH_SIZE = 64
|
|
9
10
|
* @returns Hash of hex.
|
10
11
|
*/
|
11
12
|
function sha512Half(hex: string): string {
|
12
|
-
return
|
13
|
-
.update(Buffer.from(hex, 'hex'))
|
14
|
-
.digest('hex')
|
15
|
-
.toUpperCase()
|
16
|
-
.slice(0, HASH_SIZE)
|
13
|
+
return bytesToHex(sha512(hexToBytes(hex)).slice(0, HASH_BYTES))
|
17
14
|
}
|
18
15
|
|
19
16
|
export default sha512Half
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"BroadcastClient.d.ts","sourceRoot":"","sources":["../../../src/client/BroadcastClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,CAAA;AAiBzC,qBAAa,eAAgB,SAAQ,MAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBASf,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB;IAsCjE,OAAO,CAAC,cAAc;CAkBvB"}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.BroadcastClient = void 0;
|
13
|
-
const _1 = require(".");
|
14
|
-
class BroadcastClient extends _1.Client {
|
15
|
-
constructor(servers, options = {}) {
|
16
|
-
super(servers[0], options);
|
17
|
-
const clients = servers.map((server) => new _1.Client(server, options));
|
18
|
-
this.clients = clients;
|
19
|
-
this.getMethodNames().forEach((name) => {
|
20
|
-
this[name] = (...args) => __awaiter(this, void 0, void 0, function* () { return Promise.race(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client[name](...args); }))); });
|
21
|
-
});
|
22
|
-
this.connect = () => __awaiter(this, void 0, void 0, function* () {
|
23
|
-
yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.connect(); })));
|
24
|
-
});
|
25
|
-
this.disconnect = () => __awaiter(this, void 0, void 0, function* () {
|
26
|
-
yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.disconnect(); })));
|
27
|
-
});
|
28
|
-
this.isConnected = () => clients.map((client) => client.isConnected()).every(Boolean);
|
29
|
-
clients.forEach((client) => {
|
30
|
-
client.on('error', (errorCode, errorMessage, data) => this.emit('error', errorCode, errorMessage, data));
|
31
|
-
});
|
32
|
-
}
|
33
|
-
getMethodNames() {
|
34
|
-
const methodNames = [];
|
35
|
-
const firstClient = this.clients[0];
|
36
|
-
const methods = Object.getOwnPropertyNames(firstClient);
|
37
|
-
methods.push(...Object.getOwnPropertyNames(Object.getPrototypeOf(firstClient)));
|
38
|
-
for (const name of methods) {
|
39
|
-
if (typeof firstClient[name] === 'function' &&
|
40
|
-
name !== 'constructor' &&
|
41
|
-
name !== 'on') {
|
42
|
-
methodNames.push(name);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return methodNames;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
exports.BroadcastClient = BroadcastClient;
|
49
|
-
//# sourceMappingURL=BroadcastClient.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"BroadcastClient.js","sourceRoot":"","sources":["../../../src/client/BroadcastClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wBAAyC;AAiBzC,MAAa,eAAgB,SAAQ,SAAM;IAUzC,YAAmB,OAAiB,EAAE,UAAyB,EAAE;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;QAE1B,MAAM,OAAO,GAAa,OAAO,CAAC,GAAG,CACnC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,SAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxC,CAAA;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;YAC7C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAO,GAAG,IAAI,EAAoB,EAAE,gDAG/C,OAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAO,MAAM,EAAE,EAAE,gDAAC,OAAA,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA,GAAA,CAAC,CAAC,CAAA,GAAA,CAAA;QAEtE,CAAC,CAAC,CAAA;QAGF,IAAI,CAAC,OAAO,GAAG,GAAwB,EAAE;YACvC,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAO,MAAM,EAAE,EAAE,gDAAC,OAAA,MAAM,CAAC,OAAO,EAAE,CAAA,GAAA,CAAC,CAAC,CAAA;QACpE,CAAC,CAAA,CAAA;QACD,IAAI,CAAC,UAAU,GAAG,GAAwB,EAAE;YAC1C,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAO,MAAM,EAAE,EAAE,gDAAC,OAAA,MAAM,CAAC,UAAU,EAAE,CAAA,GAAA,CAAC,CAAC,CAAA;QACvE,CAAC,CAAA,CAAA;QACD,IAAI,CAAC,WAAW,GAAG,GAAY,EAAE,CAC/B,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAE9D,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CACnD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,CAClD,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAOO,cAAc;QACpB,MAAM,WAAW,GAAa,EAAE,CAAA;QAChC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnC,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CACV,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAClE,CAAA;QACD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YAC1B,IACE,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,UAAU;gBACvC,IAAI,KAAK,aAAa;gBACtB,IAAI,KAAK,IAAI,EACb;gBACA,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACvB;SACF;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAlED,0CAkEC"}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
|
-
import { EventEmitter } from 'events';
|
4
|
-
interface WSWrapperOptions {
|
5
|
-
perMessageDeflate: boolean;
|
6
|
-
handshakeTimeout: number;
|
7
|
-
protocolVersion: number;
|
8
|
-
origin: string;
|
9
|
-
maxPayload: number;
|
10
|
-
followRedirects: boolean;
|
11
|
-
maxRedirects: number;
|
12
|
-
}
|
13
|
-
export default class WSWrapper extends EventEmitter {
|
14
|
-
static CONNECTING: number;
|
15
|
-
static OPEN: number;
|
16
|
-
static CLOSING: number;
|
17
|
-
static CLOSED: number;
|
18
|
-
private readonly ws;
|
19
|
-
constructor(url: string, _protocols: string | string[] | WSWrapperOptions | undefined, _websocketOptions: WSWrapperOptions);
|
20
|
-
get readyState(): number;
|
21
|
-
close(code?: number, reason?: Buffer): void;
|
22
|
-
send(message: string): void;
|
23
|
-
}
|
24
|
-
export {};
|
25
|
-
//# sourceMappingURL=WSWrapper.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"WSWrapper.d.ts","sourceRoot":"","sources":["../../../src/client/WSWrapper.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAcrC,UAAU,gBAAgB;IACxB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;CACrB;AAMD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,YAAY;IACjD,OAAc,UAAU,SAAI;IAC5B,OAAc,IAAI,SAAI;IACtB,OAAc,OAAO,SAAI;IAEzB,OAAc,MAAM,SAAI;IACxB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAW;gBAU5B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,EAC5D,iBAAiB,EAAE,gBAAgB;IAkCrC,IAAW,UAAU,IAAI,MAAM,CAE9B;IAQM,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAW3C,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGnC"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const events_1 = require("events");
|
4
|
-
class WSWrapper extends events_1.EventEmitter {
|
5
|
-
constructor(url, _protocols, _websocketOptions) {
|
6
|
-
super();
|
7
|
-
this.setMaxListeners(Infinity);
|
8
|
-
this.ws = new WebSocket(url);
|
9
|
-
this.ws.onclose = (closeEvent) => {
|
10
|
-
let reason;
|
11
|
-
if (closeEvent.reason) {
|
12
|
-
const enc = new TextEncoder();
|
13
|
-
reason = enc.encode(closeEvent.reason);
|
14
|
-
}
|
15
|
-
this.emit('close', closeEvent.code, reason);
|
16
|
-
};
|
17
|
-
this.ws.onopen = () => {
|
18
|
-
this.emit('open');
|
19
|
-
};
|
20
|
-
this.ws.onerror = (error) => {
|
21
|
-
this.emit('error', error);
|
22
|
-
};
|
23
|
-
this.ws.onmessage = (message) => {
|
24
|
-
this.emit('message', message.data);
|
25
|
-
};
|
26
|
-
}
|
27
|
-
get readyState() {
|
28
|
-
return this.ws.readyState;
|
29
|
-
}
|
30
|
-
close(code, reason) {
|
31
|
-
if (this.readyState === 1) {
|
32
|
-
this.ws.close(code, reason);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
send(message) {
|
36
|
-
this.ws.send(message);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
exports.default = WSWrapper;
|
40
|
-
WSWrapper.CONNECTING = 0;
|
41
|
-
WSWrapper.OPEN = 1;
|
42
|
-
WSWrapper.CLOSING = 2;
|
43
|
-
WSWrapper.CLOSED = 3;
|
44
|
-
//# sourceMappingURL=WSWrapper.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"WSWrapper.js","sourceRoot":"","sources":["../../../src/client/WSWrapper.ts"],"names":[],"mappings":";;AACA,mCAAqC;AA4BrC,MAAqB,SAAU,SAAQ,qBAAY;IAejD,YACE,GAAW,EACX,UAA4D,EAC5D,iBAAmC;QAEnC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAE9B,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAA;QAE5B,IAAI,CAAC,EAAE,CAAC,OAAO,GAAG,CAAC,UAAsB,EAAQ,EAAE;YACjD,IAAI,MAA8B,CAAA;YAClC,IAAI,UAAU,CAAC,MAAM,EAAE;gBACrB,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;gBAC7B,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;aACvC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,GAAS,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnB,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,OAAO,GAAG,CAAC,KAAK,EAAQ,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,OAAqB,EAAQ,EAAE;YAClD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACpC,CAAC,CAAA;IACH,CAAC;IAOD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAA;IAC3B,CAAC;IAQM,KAAK,CAAC,IAAa,EAAE,MAAe;QACzC,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE;YACzB,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;SAC5B;IACH,CAAC;IAOM,IAAI,CAAC,OAAe;QACzB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;;AA3EH,4BA4EC;AA3Ee,oBAAU,GAAG,CAAC,CAAA;AACd,cAAI,GAAG,CAAC,CAAA;AACR,iBAAO,GAAG,CAAC,CAAA;AAEX,gBAAM,GAAG,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"BroadcastClient.d.ts","sourceRoot":"","sources":["../../../../src/client/BroadcastClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,CAAA;AAiBzC,qBAAa,eAAgB,SAAQ,MAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBASf,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB;IAsCjE,OAAO,CAAC,cAAc;CAkBvB"}
|