@bithomp/xrpl-api 3.7.31 → 3.7.37
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/lib/connection.js +5 -3
- package/lib/src/base58.d.ts +2 -0
- package/lib/src/base58.js +32 -0
- package/lib/src/client.d.ts +25 -0
- package/lib/src/client.js +192 -0
- package/lib/src/common/errors/index.d.ts +3 -0
- package/lib/src/common/errors/index.js +7 -0
- package/lib/src/common/errors/validation_error.d.ts +4 -0
- package/lib/src/common/errors/validation_error.js +7 -0
- package/lib/src/common/errors/xrpl_api_error.d.ts +9 -0
- package/lib/src/common/errors/xrpl_api_error.js +28 -0
- package/lib/src/common/index.d.ts +9 -0
- package/lib/src/common/index.js +57 -0
- package/lib/src/common/sha512Half.d.ts +2 -0
- package/lib/src/common/sha512Half.js +12 -0
- package/lib/src/common/utils.d.ts +14 -0
- package/lib/src/common/utils.js +147 -0
- package/lib/src/connection.d.ts +76 -0
- package/lib/src/connection.js +653 -0
- package/lib/src/faucet.d.ts +58 -0
- package/lib/src/faucet.js +129 -0
- package/lib/src/index.d.ts +9 -0
- package/lib/src/index.js +45 -0
- package/lib/src/ledger/account_info.d.ts +16 -0
- package/lib/src/ledger/account_info.js +112 -0
- package/lib/src/ledger/account_lines.d.ts +11 -0
- package/lib/src/ledger/account_lines.js +90 -0
- package/lib/src/ledger/account_namespace.d.ts +7 -0
- package/lib/src/ledger/account_namespace.js +72 -0
- package/lib/src/ledger/account_nfts.d.ts +21 -0
- package/lib/src/ledger/account_nfts.js +199 -0
- package/lib/src/ledger/account_objects.d.ts +44 -0
- package/lib/src/ledger/account_objects.js +222 -0
- package/lib/src/ledger/account_offers.d.ts +13 -0
- package/lib/src/ledger/account_offers.js +142 -0
- package/lib/src/ledger/account_tx.d.ts +37 -0
- package/lib/src/ledger/account_tx.js +376 -0
- package/lib/src/ledger/amm_info.d.ts +13 -0
- package/lib/src/ledger/amm_info.js +114 -0
- package/lib/src/ledger/book_offers.d.ts +15 -0
- package/lib/src/ledger/book_offers.js +102 -0
- package/lib/src/ledger/currency.d.ts +28 -0
- package/lib/src/ledger/currency.js +250 -0
- package/lib/src/ledger/fee.d.ts +13 -0
- package/lib/src/ledger/fee.js +99 -0
- package/lib/src/ledger/gateway_balances.d.ts +16 -0
- package/lib/src/ledger/gateway_balances.js +119 -0
- package/lib/src/ledger/index.d.ts +21 -0
- package/lib/src/ledger/index.js +37 -0
- package/lib/src/ledger/ledger.d.ts +16 -0
- package/lib/src/ledger/ledger.js +99 -0
- package/lib/src/ledger/ledger_entry.d.ts +16 -0
- package/lib/src/ledger/ledger_entry.js +118 -0
- package/lib/src/ledger/manifest.d.ts +8 -0
- package/lib/src/ledger/manifest.js +67 -0
- package/lib/src/ledger/nft_info.d.ts +4 -0
- package/lib/src/ledger/nft_info.js +67 -0
- package/lib/src/ledger/server_definitions.d.ts +7 -0
- package/lib/src/ledger/server_definitions.js +65 -0
- package/lib/src/ledger/server_info.d.ts +8 -0
- package/lib/src/ledger/server_info.js +65 -0
- package/lib/src/ledger/transaction.d.ts +47 -0
- package/lib/src/ledger/transaction.js +440 -0
- package/lib/src/ledger/vl-v2.d.ts +3 -0
- package/lib/src/ledger/vl-v2.js +124 -0
- package/lib/src/ledger/vl.d.ts +4 -0
- package/lib/src/ledger/vl.js +131 -0
- package/lib/src/models/account_info.d.ts +184 -0
- package/lib/src/models/account_info.js +139 -0
- package/lib/src/models/account_lines.d.ts +26 -0
- package/lib/src/models/account_lines.js +2 -0
- package/lib/src/models/account_namespace.d.ts +16 -0
- package/lib/src/models/account_namespace.js +2 -0
- package/lib/src/models/account_nfts.d.ts +20 -0
- package/lib/src/models/account_nfts.js +92 -0
- package/lib/src/models/account_object.d.ts +61 -0
- package/lib/src/models/account_object.js +125 -0
- package/lib/src/models/account_offers.d.ts +9 -0
- package/lib/src/models/account_offers.js +2 -0
- package/lib/src/models/account_uritokens.d.ts +11 -0
- package/lib/src/models/account_uritokens.js +2 -0
- package/lib/src/models/amm_info.d.ts +1 -0
- package/lib/src/models/amm_info.js +4 -0
- package/lib/src/models/base_model.d.ts +15 -0
- package/lib/src/models/base_model.js +2 -0
- package/lib/src/models/book_offers.d.ts +9 -0
- package/lib/src/models/book_offers.js +40 -0
- package/lib/src/models/gateway_balances.d.ts +19 -0
- package/lib/src/models/gateway_balances.js +2 -0
- package/lib/src/models/index.d.ts +38 -0
- package/lib/src/models/index.js +82 -0
- package/lib/src/models/ledger.d.ts +7 -0
- package/lib/src/models/ledger.js +20 -0
- package/lib/src/models/manifest.d.ts +25 -0
- package/lib/src/models/manifest.js +199 -0
- package/lib/src/models/mptoken.d.ts +7 -0
- package/lib/src/models/mptoken.js +59 -0
- package/lib/src/models/path_find.d.ts +11 -0
- package/lib/src/models/path_find.js +2 -0
- package/lib/src/models/server_definitions.d.ts +33 -0
- package/lib/src/models/server_definitions.js +2 -0
- package/lib/src/models/transaction.d.ts +52 -0
- package/lib/src/models/transaction.js +141 -0
- package/lib/src/models/transactions/CronSet.d.ts +3 -0
- package/lib/src/models/transactions/CronSet.js +2 -0
- package/lib/src/models/transactions/SetRemarks.d.ts +3 -0
- package/lib/src/models/transactions/SetRemarks.js +2 -0
- package/lib/src/models/transactions/URITokenMint.d.ts +3 -0
- package/lib/src/models/transactions/URITokenMint.js +2 -0
- package/lib/src/models/vl.d.ts +82 -0
- package/lib/src/models/vl.js +498 -0
- package/lib/src/parse/index.d.ts +6 -0
- package/lib/src/parse/index.js +46 -0
- package/lib/src/parse/ledger/account-fields.d.ts +5 -0
- package/lib/src/parse/ledger/account-fields.js +43 -0
- package/lib/src/parse/ledger/account-info.d.ts +3 -0
- package/lib/src/parse/ledger/account-info.js +15 -0
- package/lib/src/parse/ledger/account-order.d.ts +18 -0
- package/lib/src/parse/ledger/account-order.js +48 -0
- package/lib/src/parse/ledger/account-settings-flags.d.ts +2 -0
- package/lib/src/parse/ledger/account-settings-flags.js +77 -0
- package/lib/src/parse/ledger/account.d.ts +1 -0
- package/lib/src/parse/ledger/account.js +7 -0
- package/lib/src/parse/ledger/amount.d.ts +3 -0
- package/lib/src/parse/ledger/amount.js +25 -0
- package/lib/src/parse/ledger/asset.d.ts +3 -0
- package/lib/src/parse/ledger/asset.js +19 -0
- package/lib/src/parse/ledger/auth-accounts.d.ts +3 -0
- package/lib/src/parse/ledger/auth-accounts.js +18 -0
- package/lib/src/parse/ledger/credential-flags.d.ts +5 -0
- package/lib/src/parse/ledger/credential-flags.js +8 -0
- package/lib/src/parse/ledger/credential.d.ts +3 -0
- package/lib/src/parse/ledger/credential.js +13 -0
- package/lib/src/parse/ledger/currency-amount.d.ts +3 -0
- package/lib/src/parse/ledger/currency-amount.js +13 -0
- package/lib/src/parse/ledger/delegate.d.ts +2 -0
- package/lib/src/parse/ledger/delegate.js +11 -0
- package/lib/src/parse/ledger/destination.d.ts +2 -0
- package/lib/src/parse/ledger/destination.js +12 -0
- package/lib/src/parse/ledger/emit_details.d.ts +2 -0
- package/lib/src/parse/ledger/emit_details.js +14 -0
- package/lib/src/parse/ledger/flags.d.ts +4 -0
- package/lib/src/parse/ledger/flags.js +17 -0
- package/lib/src/parse/ledger/gateway-balances.d.ts +3 -0
- package/lib/src/parse/ledger/gateway-balances.js +31 -0
- package/lib/src/parse/ledger/genesis-mints.d.ts +2 -0
- package/lib/src/parse/ledger/genesis-mints.js +17 -0
- package/lib/src/parse/ledger/import.d.ts +2 -0
- package/lib/src/parse/ledger/import.js +40 -0
- package/lib/src/parse/ledger/index.d.ts +6 -0
- package/lib/src/parse/ledger/index.js +29 -0
- package/lib/src/parse/ledger/ledger.d.ts +2 -0
- package/lib/src/parse/ledger/ledger.js +98 -0
- package/lib/src/parse/ledger/memos.d.ts +4 -0
- package/lib/src/parse/ledger/memos.js +27 -0
- package/lib/src/parse/ledger/mptoken-flags.d.ts +6 -0
- package/lib/src/parse/ledger/mptoken-flags.js +8 -0
- package/lib/src/parse/ledger/mptoken-issuance-flags.d.ts +6 -0
- package/lib/src/parse/ledger/mptoken-issuance-flags.js +8 -0
- package/lib/src/parse/ledger/nftoken-flags.d.ts +5 -0
- package/lib/src/parse/ledger/nftoken-flags.js +8 -0
- package/lib/src/parse/ledger/nftoken-offer-flags.d.ts +5 -0
- package/lib/src/parse/ledger/nftoken-offer-flags.js +8 -0
- package/lib/src/parse/ledger/offer-flags.d.ts +5 -0
- package/lib/src/parse/ledger/offer-flags.js +8 -0
- package/lib/src/parse/ledger/orderbook-order.d.ts +21 -0
- package/lib/src/parse/ledger/orderbook-order.js +42 -0
- package/lib/src/parse/ledger/permissions.d.ts +2 -0
- package/lib/src/parse/ledger/permissions.js +9 -0
- package/lib/src/parse/ledger/regular-key.d.ts +2 -0
- package/lib/src/parse/ledger/regular-key.js +14 -0
- package/lib/src/parse/ledger/remark-flags.d.ts +5 -0
- package/lib/src/parse/ledger/remark-flags.js +8 -0
- package/lib/src/parse/ledger/remarks.d.ts +3 -0
- package/lib/src/parse/ledger/remarks.js +37 -0
- package/lib/src/parse/ledger/signers.d.ts +2 -0
- package/lib/src/parse/ledger/signers.js +12 -0
- package/lib/src/parse/ledger/source.d.ts +3 -0
- package/lib/src/parse/ledger/source.js +28 -0
- package/lib/src/parse/ledger/trustline-flags.d.ts +5 -0
- package/lib/src/parse/ledger/trustline-flags.js +8 -0
- package/lib/src/parse/ledger/tx-account-set-flags.d.ts +4 -0
- package/lib/src/parse/ledger/tx-account-set-flags.js +36 -0
- package/lib/src/parse/ledger/tx-amm-clawback-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-clawback-flags.js +8 -0
- package/lib/src/parse/ledger/tx-amm-deposit-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-deposit-flags.js +8 -0
- package/lib/src/parse/ledger/tx-amm-withdraw-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-withdraw-flags.js +8 -0
- package/lib/src/parse/ledger/tx-batch-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-batch-flags.js +8 -0
- package/lib/src/parse/ledger/tx-cron-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-cron-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-global-flags.d.ts +5 -0
- package/lib/src/parse/ledger/tx-global-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-authorize-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-authorize-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-nftoken-mint-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-nftoken-mint-flags.js +8 -0
- package/lib/src/parse/ledger/tx-nftoken-offer-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-nftoken-offer-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-offer-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-offer-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-payment-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-payment-flags.js +8 -0
- package/lib/src/parse/ledger/tx-trust-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-trust-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-uritoken-mint-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-uritoken-mint-flags.js +8 -0
- package/lib/src/parse/ledger/uritoken-flags.d.ts +5 -0
- package/lib/src/parse/ledger/uritoken-flags.js +8 -0
- package/lib/src/parse/mptoken_normalize.d.ts +5 -0
- package/lib/src/parse/mptoken_normalize.js +215 -0
- package/lib/src/parse/outcome/account_setting_changes.d.ts +4 -0
- package/lib/src/parse/outcome/account_setting_changes.js +67 -0
- package/lib/src/parse/outcome/affected_objects.d.ts +7 -0
- package/lib/src/parse/outcome/affected_objects.js +147 -0
- package/lib/src/parse/outcome/amendment_changes.d.ts +8 -0
- package/lib/src/parse/outcome/amendment_changes.js +84 -0
- package/lib/src/parse/outcome/amm_changes.d.ts +52 -0
- package/lib/src/parse/outcome/amm_changes.js +214 -0
- package/lib/src/parse/outcome/balance_changes.d.ts +24 -0
- package/lib/src/parse/outcome/balance_changes.js +337 -0
- package/lib/src/parse/outcome/channel_changes.d.ts +20 -0
- package/lib/src/parse/outcome/channel_changes.js +70 -0
- package/lib/src/parse/outcome/check_changes.d.ts +17 -0
- package/lib/src/parse/outcome/check_changes.js +63 -0
- package/lib/src/parse/outcome/credential_changes.d.ts +16 -0
- package/lib/src/parse/outcome/credential_changes.js +59 -0
- package/lib/src/parse/outcome/cron_changes.d.ts +13 -0
- package/lib/src/parse/outcome/cron_changes.js +72 -0
- package/lib/src/parse/outcome/delegate_changes.d.ts +12 -0
- package/lib/src/parse/outcome/delegate_changes.js +59 -0
- package/lib/src/parse/outcome/delivered_amount.d.ts +4 -0
- package/lib/src/parse/outcome/delivered_amount.js +63 -0
- package/lib/src/parse/outcome/did_changes.d.ts +14 -0
- package/lib/src/parse/outcome/did_changes.js +50 -0
- package/lib/src/parse/outcome/emitted_txns.d.ts +9 -0
- package/lib/src/parse/outcome/emitted_txns.js +57 -0
- package/lib/src/parse/outcome/escrow_changes.d.ts +16 -0
- package/lib/src/parse/outcome/escrow_changes.js +75 -0
- package/lib/src/parse/outcome/hooks_executions.d.ts +13 -0
- package/lib/src/parse/outcome/hooks_executions.js +42 -0
- package/lib/src/parse/outcome/index.d.ts +26 -0
- package/lib/src/parse/outcome/index.js +55 -0
- package/lib/src/parse/outcome/locked_balance_changes.d.ts +20 -0
- package/lib/src/parse/outcome/locked_balance_changes.js +117 -0
- package/lib/src/parse/outcome/mptoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/mptoken_changes.js +113 -0
- package/lib/src/parse/outcome/mptoken_issuance_changes.d.ts +1 -0
- package/lib/src/parse/outcome/mptoken_issuance_changes.js +119 -0
- package/lib/src/parse/outcome/nftoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/nftoken_changes.js +234 -0
- package/lib/src/parse/outcome/nftoken_offer_changes.d.ts +2 -0
- package/lib/src/parse/outcome/nftoken_offer_changes.js +106 -0
- package/lib/src/parse/outcome/oracle_changes.d.ts +29 -0
- package/lib/src/parse/outcome/oracle_changes.js +150 -0
- package/lib/src/parse/outcome/orderbook_changes.d.ts +21 -0
- package/lib/src/parse/outcome/orderbook_changes.js +108 -0
- package/lib/src/parse/outcome/orderbook_quality.d.ts +2 -0
- package/lib/src/parse/outcome/orderbook_quality.js +49 -0
- package/lib/src/parse/outcome/remarks_changes.d.ts +14 -0
- package/lib/src/parse/outcome/remarks_changes.js +68 -0
- package/lib/src/parse/outcome/unl_report_changes.d.ts +13 -0
- package/lib/src/parse/outcome/unl_report_changes.js +48 -0
- package/lib/src/parse/outcome/uritoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/uritoken_changes.js +83 -0
- package/lib/src/parse/outcome/uritoken_sell_offer_changes.d.ts +1 -0
- package/lib/src/parse/outcome/uritoken_sell_offer_changes.js +105 -0
- package/lib/src/parse/outcome.d.ts +4 -0
- package/lib/src/parse/outcome.js +264 -0
- package/lib/src/parse/specification/account-delete.d.ts +4 -0
- package/lib/src/parse/specification/account-delete.js +59 -0
- package/lib/src/parse/specification/amendment.d.ts +3 -0
- package/lib/src/parse/specification/amendment.js +50 -0
- package/lib/src/parse/specification/amm-bid.d.ts +4 -0
- package/lib/src/parse/specification/amm-bid.js +66 -0
- package/lib/src/parse/specification/amm-clawback.d.ts +4 -0
- package/lib/src/parse/specification/amm-clawback.js +65 -0
- package/lib/src/parse/specification/amm-create.d.ts +4 -0
- package/lib/src/parse/specification/amm-create.js +62 -0
- package/lib/src/parse/specification/amm-delete.d.ts +4 -0
- package/lib/src/parse/specification/amm-delete.js +61 -0
- package/lib/src/parse/specification/amm-deposit.d.ts +4 -0
- package/lib/src/parse/specification/amm-deposit.js +66 -0
- package/lib/src/parse/specification/amm-vote.d.ts +4 -0
- package/lib/src/parse/specification/amm-vote.js +62 -0
- package/lib/src/parse/specification/amm-withdraw.d.ts +4 -0
- package/lib/src/parse/specification/amm-withdraw.js +66 -0
- package/lib/src/parse/specification/batch.d.ts +4 -0
- package/lib/src/parse/specification/batch.js +83 -0
- package/lib/src/parse/specification/check-cancel.d.ts +4 -0
- package/lib/src/parse/specification/check-cancel.js +58 -0
- package/lib/src/parse/specification/check-cash.d.ts +4 -0
- package/lib/src/parse/specification/check-cash.js +64 -0
- package/lib/src/parse/specification/check-create.d.ts +4 -0
- package/lib/src/parse/specification/check-create.js +67 -0
- package/lib/src/parse/specification/clawback.d.ts +4 -0
- package/lib/src/parse/specification/clawback.js +62 -0
- package/lib/src/parse/specification/credential-accept.d.ts +4 -0
- package/lib/src/parse/specification/credential-accept.js +56 -0
- package/lib/src/parse/specification/credential-create.d.ts +4 -0
- package/lib/src/parse/specification/credential-create.js +58 -0
- package/lib/src/parse/specification/credential-delete.d.ts +4 -0
- package/lib/src/parse/specification/credential-delete.js +57 -0
- package/lib/src/parse/specification/cron-set.d.ts +3 -0
- package/lib/src/parse/specification/cron-set.js +62 -0
- package/lib/src/parse/specification/cron.d.ts +3 -0
- package/lib/src/parse/specification/cron.js +47 -0
- package/lib/src/parse/specification/delegate-set.d.ts +4 -0
- package/lib/src/parse/specification/delegate-set.js +60 -0
- package/lib/src/parse/specification/deposit-preauth.d.ts +4 -0
- package/lib/src/parse/specification/deposit-preauth.js +62 -0
- package/lib/src/parse/specification/did-delete.d.ts +4 -0
- package/lib/src/parse/specification/did-delete.js +57 -0
- package/lib/src/parse/specification/did-set.d.ts +4 -0
- package/lib/src/parse/specification/did-set.js +60 -0
- package/lib/src/parse/specification/escrow-cancel.d.ts +4 -0
- package/lib/src/parse/specification/escrow-cancel.js +59 -0
- package/lib/src/parse/specification/escrow-create.d.ts +4 -0
- package/lib/src/parse/specification/escrow-create.js +64 -0
- package/lib/src/parse/specification/escrow-finish.d.ts +4 -0
- package/lib/src/parse/specification/escrow-finish.js +61 -0
- package/lib/src/parse/specification/fee-update.d.ts +3 -0
- package/lib/src/parse/specification/fee-update.js +69 -0
- package/lib/src/parse/specification/genesis-mint.d.ts +3 -0
- package/lib/src/parse/specification/genesis-mint.js +53 -0
- package/lib/src/parse/specification/import.d.ts +3 -0
- package/lib/src/parse/specification/import.js +55 -0
- package/lib/src/parse/specification/invoke.d.ts +3 -0
- package/lib/src/parse/specification/invoke.js +54 -0
- package/lib/src/parse/specification/mptoken-authorize.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-authorize.js +60 -0
- package/lib/src/parse/specification/mptoken-issuance-create.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-create.js +62 -0
- package/lib/src/parse/specification/mptoken-issuance-destroy.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-destroy.js +56 -0
- package/lib/src/parse/specification/mptoken-issuance-set.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-set.js +60 -0
- package/lib/src/parse/specification/nftoken-accept-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-accept-offer.js +58 -0
- package/lib/src/parse/specification/nftoken-burn.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-burn.js +56 -0
- package/lib/src/parse/specification/nftoken-cancel-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-cancel-offer.js +56 -0
- package/lib/src/parse/specification/nftoken-create-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-create-offer.js +69 -0
- package/lib/src/parse/specification/nftoken-mint.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-mint.js +73 -0
- package/lib/src/parse/specification/nftoken-modify.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-modify.js +58 -0
- package/lib/src/parse/specification/offer-cancel.d.ts +4 -0
- package/lib/src/parse/specification/offer-cancel.js +58 -0
- package/lib/src/parse/specification/offer-create.d.ts +4 -0
- package/lib/src/parse/specification/offer-create.js +78 -0
- package/lib/src/parse/specification/oracle-delete.d.ts +4 -0
- package/lib/src/parse/specification/oracle-delete.js +56 -0
- package/lib/src/parse/specification/oracle-set.d.ts +4 -0
- package/lib/src/parse/specification/oracle-set.js +62 -0
- package/lib/src/parse/specification/payment-channel-claim.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-claim.js +67 -0
- package/lib/src/parse/specification/payment-channel-create.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-create.js +68 -0
- package/lib/src/parse/specification/payment-channel-fund.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-fund.js +65 -0
- package/lib/src/parse/specification/payment.d.ts +4 -0
- package/lib/src/parse/specification/payment.js +75 -0
- package/lib/src/parse/specification/permissioned-domain-set.d.ts +4 -0
- package/lib/src/parse/specification/permissioned-domain-set.js +56 -0
- package/lib/src/parse/specification/remit.d.ts +3 -0
- package/lib/src/parse/specification/remit.js +90 -0
- package/lib/src/parse/specification/set-remarks.d.ts +3 -0
- package/lib/src/parse/specification/set-remarks.js +56 -0
- package/lib/src/parse/specification/settings.d.ts +4 -0
- package/lib/src/parse/specification/settings.js +64 -0
- package/lib/src/parse/specification/ticket-create.d.ts +4 -0
- package/lib/src/parse/specification/ticket-create.js +58 -0
- package/lib/src/parse/specification/trust-set.d.ts +4 -0
- package/lib/src/parse/specification/trust-set.js +80 -0
- package/lib/src/parse/specification/unl-modify.d.ts +4 -0
- package/lib/src/parse/specification/unl-modify.js +52 -0
- package/lib/src/parse/specification/unl-report.d.ts +3 -0
- package/lib/src/parse/specification/unl-report.js +51 -0
- package/lib/src/parse/specification/unrecognized.d.ts +4 -0
- package/lib/src/parse/specification/unrecognized.js +24 -0
- package/lib/src/parse/specification/uritoken-burn.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-burn.js +54 -0
- package/lib/src/parse/specification/uritoken-buy.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-buy.js +55 -0
- package/lib/src/parse/specification/uritoken-cancel-sell-offer.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-cancel-sell-offer.js +54 -0
- package/lib/src/parse/specification/uritoken-create-sell-offer.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-create-sell-offer.js +57 -0
- package/lib/src/parse/specification/uritoken-mint.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-mint.js +63 -0
- package/lib/src/parse/transaction.d.ts +168 -0
- package/lib/src/parse/transaction.js +228 -0
- package/lib/src/parse/utils.d.ts +33 -0
- package/lib/src/parse/utils.js +119 -0
- package/lib/src/types/account.d.ts +26 -0
- package/lib/src/types/account.js +2 -0
- package/lib/src/types/adjustments.d.ts +16 -0
- package/lib/src/types/adjustments.js +2 -0
- package/lib/src/types/amendments.d.ts +4 -0
- package/lib/src/types/amendments.js +2 -0
- package/lib/src/types/amm.d.ts +98 -0
- package/lib/src/types/amm.js +68 -0
- package/lib/src/types/amounts.d.ts +20 -0
- package/lib/src/types/amounts.js +2 -0
- package/lib/src/types/batch.d.ts +21 -0
- package/lib/src/types/batch.js +26 -0
- package/lib/src/types/checks.d.ts +17 -0
- package/lib/src/types/checks.js +2 -0
- package/lib/src/types/clawback.d.ts +5 -0
- package/lib/src/types/clawback.js +2 -0
- package/lib/src/types/credentials.d.ts +30 -0
- package/lib/src/types/credentials.js +10 -0
- package/lib/src/types/cron.d.ts +17 -0
- package/lib/src/types/cron.js +6 -0
- package/lib/src/types/delegate.d.ts +5 -0
- package/lib/src/types/delegate.js +2 -0
- package/lib/src/types/deposits.d.ts +11 -0
- package/lib/src/types/deposits.js +2 -0
- package/lib/src/types/did.d.ts +7 -0
- package/lib/src/types/did.js +2 -0
- package/lib/src/types/emit_details.d.ts +7 -0
- package/lib/src/types/emit_details.js +2 -0
- package/lib/src/types/escrows.d.ts +18 -0
- package/lib/src/types/escrows.js +2 -0
- package/lib/src/types/fees.d.ts +9 -0
- package/lib/src/types/fees.js +2 -0
- package/lib/src/types/gateway_balances.d.ts +11 -0
- package/lib/src/types/gateway_balances.js +2 -0
- package/lib/src/types/genesis_mint.d.ts +9 -0
- package/lib/src/types/genesis_mint.js +2 -0
- package/lib/src/types/global.d.ts +14 -0
- package/lib/src/types/global.js +26 -0
- package/lib/src/types/hooks.d.ts +14 -0
- package/lib/src/types/hooks.js +2 -0
- package/lib/src/types/import.d.ts +21 -0
- package/lib/src/types/import.js +2 -0
- package/lib/src/types/index.d.ts +31 -0
- package/lib/src/types/index.js +47 -0
- package/lib/src/types/invoke.d.ts +5 -0
- package/lib/src/types/invoke.js +2 -0
- package/lib/src/types/ledger.d.ts +46 -0
- package/lib/src/types/ledger.js +2 -0
- package/lib/src/types/ledger_data.d.ts +10 -0
- package/lib/src/types/ledger_data.js +2 -0
- package/lib/src/types/ledger_entries.d.ts +163 -0
- package/lib/src/types/ledger_entries.js +2 -0
- package/lib/src/types/memos.d.ts +12 -0
- package/lib/src/types/memos.js +2 -0
- package/lib/src/types/mptokens.d.ts +84 -0
- package/lib/src/types/mptokens.js +76 -0
- package/lib/src/types/nftokens.d.ts +62 -0
- package/lib/src/types/nftokens.js +44 -0
- package/lib/src/types/offers.d.ts +46 -0
- package/lib/src/types/offers.js +33 -0
- package/lib/src/types/oracle.d.ts +19 -0
- package/lib/src/types/oracle.js +2 -0
- package/lib/src/types/outcome.d.ts +22 -0
- package/lib/src/types/outcome.js +2 -0
- package/lib/src/types/payment_channels.d.ts +23 -0
- package/lib/src/types/payment_channels.js +2 -0
- package/lib/src/types/payments.d.ts +24 -0
- package/lib/src/types/payments.js +25 -0
- package/lib/src/types/queue_data.d.ts +15 -0
- package/lib/src/types/queue_data.js +2 -0
- package/lib/src/types/remarks.d.ts +24 -0
- package/lib/src/types/remarks.js +6 -0
- package/lib/src/types/remits.d.ts +15 -0
- package/lib/src/types/remits.js +2 -0
- package/lib/src/types/settings.d.ts +27 -0
- package/lib/src/types/settings.js +2 -0
- package/lib/src/types/signers.d.ts +22 -0
- package/lib/src/types/signers.js +2 -0
- package/lib/src/types/specification.d.ts +14 -0
- package/lib/src/types/specification.js +2 -0
- package/lib/src/types/tickets.d.ts +4 -0
- package/lib/src/types/tickets.js +2 -0
- package/lib/src/types/trustlines.d.ts +85 -0
- package/lib/src/types/trustlines.js +43 -0
- package/lib/src/types/unl_modify.d.ts +6 -0
- package/lib/src/types/unl_modify.js +2 -0
- package/lib/src/types/unl_reports.d.ts +5 -0
- package/lib/src/types/unl_reports.js +2 -0
- package/lib/src/types/unrecognized.d.ts +5 -0
- package/lib/src/types/unrecognized.js +2 -0
- package/lib/src/types/uri_tokens.d.ts +7 -0
- package/lib/src/types/uri_tokens.js +6 -0
- package/lib/src/types/uritokens.d.ts +41 -0
- package/lib/src/types/uritokens.js +22 -0
- package/lib/src/v1/transaction/payment.d.ts +14 -0
- package/lib/src/v1/transaction/payment.js +142 -0
- package/lib/src/v1/types.d.ts +9 -0
- package/lib/src/v1/types.js +2 -0
- package/lib/src/v1/utils.d.ts +7 -0
- package/lib/src/v1/utils.js +49 -0
- package/lib/src/validator.d.ts +11 -0
- package/lib/src/validator.js +130 -0
- package/lib/src/wallet.d.ts +34 -0
- package/lib/src/wallet.js +284 -0
- package/package.json +11 -11
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Connection = exports.DEFAULT_API_VERSION = void 0;
|
|
40
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
41
|
+
const events_1 = require("events");
|
|
42
|
+
const xrpl_1 = require("xrpl");
|
|
43
|
+
const ledger_1 = require("./models/ledger");
|
|
44
|
+
const common_1 = require("./common");
|
|
45
|
+
const utils_1 = require("./common/utils");
|
|
46
|
+
const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
|
|
47
|
+
const RECONNECT_TIMEOUT = 1000 * 5;
|
|
48
|
+
const LEDGER_CLOSED_TIMEOUT = 1000 * 20;
|
|
49
|
+
const SCHEDULE_RECONNECT_TIMEOUT = 1000 * 60;
|
|
50
|
+
const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
|
|
51
|
+
const AVAILABLE_LEDGER_INDEX_WINDOW = 1000;
|
|
52
|
+
exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
|
|
53
|
+
const SLOW_DOWN_ERROR_MESSAGES = [
|
|
54
|
+
"slowDown",
|
|
55
|
+
"Unexpected server response: 429",
|
|
56
|
+
"You are placing too much load on the server.",
|
|
57
|
+
];
|
|
58
|
+
class Connection extends events_1.EventEmitter {
|
|
59
|
+
constructor(url, type, options = {}) {
|
|
60
|
+
super();
|
|
61
|
+
this.types = [];
|
|
62
|
+
this.latency = [];
|
|
63
|
+
this.onlineSince = null;
|
|
64
|
+
this.serverInfo = {};
|
|
65
|
+
this.shutdown = false;
|
|
66
|
+
this.connectionWatchTimer = null;
|
|
67
|
+
this.bindConnectionWatchTimeout = this.connectionWatchTimeout.bind(this);
|
|
68
|
+
this.shutdown = false;
|
|
69
|
+
this.url = url;
|
|
70
|
+
this.type = type;
|
|
71
|
+
this.resetTypes();
|
|
72
|
+
this.client = null;
|
|
73
|
+
this.logger = options.logger;
|
|
74
|
+
this.timeout = options.timeout || LEDGER_CLOSED_TIMEOUT;
|
|
75
|
+
this.connectionTimeout = options.connectionTimeout || RECONNECT_TIMEOUT;
|
|
76
|
+
this.hash = crypto_1.default.createHash("sha256").update(url).digest("hex");
|
|
77
|
+
if (typeof options.networkID === "number") {
|
|
78
|
+
this.networkID = options.networkID;
|
|
79
|
+
}
|
|
80
|
+
this.apiVersion = options.apiVersion || exports.DEFAULT_API_VERSION;
|
|
81
|
+
this.serverInfoUpdating = false;
|
|
82
|
+
this.serverInfo = null;
|
|
83
|
+
this.streams = {
|
|
84
|
+
ledger: 1,
|
|
85
|
+
};
|
|
86
|
+
this.accounts = {};
|
|
87
|
+
this.streamsSubscribed = false;
|
|
88
|
+
}
|
|
89
|
+
scheduleReconnect(delay = RECONNECT_TIMEOUT) {
|
|
90
|
+
if (this.shutdown) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.removeWatchTimer();
|
|
94
|
+
this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, delay);
|
|
95
|
+
}
|
|
96
|
+
async connect() {
|
|
97
|
+
try {
|
|
98
|
+
this.logger?.debug({
|
|
99
|
+
service: "Bithomp::XRPL::Connection",
|
|
100
|
+
function: "connect",
|
|
101
|
+
url: this.url,
|
|
102
|
+
shutdown: this.shutdown,
|
|
103
|
+
});
|
|
104
|
+
this.removeWatchTimer();
|
|
105
|
+
this.removeClient();
|
|
106
|
+
this.client = new XRPLConnection.Connection(this.url, (0, common_1.removeUndefined)({ timeout: this.timeout, connectionTimeout: this.connectionTimeout }));
|
|
107
|
+
this.setupEmitter();
|
|
108
|
+
await this.client.connect();
|
|
109
|
+
await this.updateServerInfo();
|
|
110
|
+
await this.subscribe();
|
|
111
|
+
this.connectionValidation("connect");
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
const errorMessage = err?.message || err?.name || err;
|
|
115
|
+
this.logger?.warn({
|
|
116
|
+
service: "Bithomp::XRPL::Connection",
|
|
117
|
+
function: "connect",
|
|
118
|
+
url: this.url,
|
|
119
|
+
error: errorMessage,
|
|
120
|
+
});
|
|
121
|
+
this.removeWatchTimer();
|
|
122
|
+
this.removeClient();
|
|
123
|
+
const isSlowDown = SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage);
|
|
124
|
+
this.scheduleReconnect(isSlowDown ? SCHEDULE_RECONNECT_TIMEOUT : RECONNECT_TIMEOUT);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async disconnect() {
|
|
128
|
+
this.logger?.debug({
|
|
129
|
+
service: "Bithomp::XRPL::Connection",
|
|
130
|
+
function: "disconnect",
|
|
131
|
+
url: this.url,
|
|
132
|
+
});
|
|
133
|
+
this.shutdown = true;
|
|
134
|
+
if (this.isConnected()) {
|
|
135
|
+
await this.unsubscribe();
|
|
136
|
+
}
|
|
137
|
+
this.removeWatchTimer();
|
|
138
|
+
this.removeClient();
|
|
139
|
+
}
|
|
140
|
+
async request(request, options) {
|
|
141
|
+
const result = await this._request(request, options);
|
|
142
|
+
let validResponse = true;
|
|
143
|
+
if (result?.error) {
|
|
144
|
+
if (SLOW_DOWN_ERROR_MESSAGES.includes(result.error)) {
|
|
145
|
+
this.logger?.debug({
|
|
146
|
+
service: "Bithomp::XRPL::Connection",
|
|
147
|
+
function: "request",
|
|
148
|
+
url: this.url,
|
|
149
|
+
error: `Received slowdown error, reconnecting...`,
|
|
150
|
+
});
|
|
151
|
+
validResponse = false;
|
|
152
|
+
}
|
|
153
|
+
else if (result.error === "timeout") {
|
|
154
|
+
const timeouts = this.latency.filter((info) => info.delta >= this.timeout).length;
|
|
155
|
+
if (timeouts >= 3) {
|
|
156
|
+
this.logger?.debug({
|
|
157
|
+
service: "Bithomp::XRPL::Connection",
|
|
158
|
+
function: "request",
|
|
159
|
+
url: this.url,
|
|
160
|
+
error: `Too many timeouts (${timeouts}) in last ${this.latency.length} requests, reconnecting...`,
|
|
161
|
+
});
|
|
162
|
+
validResponse = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (result.error.toLowerCase().startsWith("websocket was closed")) {
|
|
166
|
+
this.logger?.debug({
|
|
167
|
+
service: "Bithomp::XRPL::Connection",
|
|
168
|
+
function: "request",
|
|
169
|
+
url: this.url,
|
|
170
|
+
error: "Websocket was closed, reconnecting...",
|
|
171
|
+
});
|
|
172
|
+
validResponse = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (validResponse) {
|
|
176
|
+
if (result?.error !== "notConnected") {
|
|
177
|
+
this.connectionValidation("request");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.removeClient();
|
|
182
|
+
const isSlowDown = SLOW_DOWN_ERROR_MESSAGES.includes(result?.error);
|
|
183
|
+
this.scheduleReconnect(isSlowDown ? SCHEDULE_RECONNECT_TIMEOUT : RECONNECT_TIMEOUT);
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
async _request(request, options) {
|
|
188
|
+
try {
|
|
189
|
+
if (options?.skip_subscription_update !== true &&
|
|
190
|
+
(request.command === "subscribe" || request.command === "unsubscribe")) {
|
|
191
|
+
return this.updateSubscriptions(request);
|
|
192
|
+
}
|
|
193
|
+
const waitTime = (0, utils_1.getTimestamp)() + RECONNECT_TIMEOUT;
|
|
194
|
+
while (!this.client || !this.isConnected()) {
|
|
195
|
+
await (0, utils_1.sleep)(100);
|
|
196
|
+
if (this.shutdown) {
|
|
197
|
+
return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
|
|
198
|
+
}
|
|
199
|
+
if ((0, utils_1.getTimestamp)() > waitTime) {
|
|
200
|
+
return { error: "notConnected", error_message: "Not connected.", status: "error" };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const startTimestamp = (0, utils_1.getTimestamp)();
|
|
204
|
+
if (this.apiVersion && !request.hasOwnProperty("api_version") && exports.DEFAULT_API_VERSION !== this.apiVersion) {
|
|
205
|
+
request.api_version = this.apiVersion;
|
|
206
|
+
}
|
|
207
|
+
const response = await this.client.request(request);
|
|
208
|
+
this.updateLatency((0, utils_1.getTimestamp)() - startTimestamp);
|
|
209
|
+
return response;
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
this.updateLatency(err.name === "TimeoutError" ? this.timeout : this.connectionTimeout);
|
|
213
|
+
this.logger?.debug({
|
|
214
|
+
service: "Bithomp::XRPL::Connection",
|
|
215
|
+
function: "request",
|
|
216
|
+
url: this.url,
|
|
217
|
+
error: err?.message || err?.name || err,
|
|
218
|
+
});
|
|
219
|
+
if (err.name === "TimeoutError") {
|
|
220
|
+
return { error: "timeout", error_message: "Request timeout.", status: "error" };
|
|
221
|
+
}
|
|
222
|
+
else if (err.data) {
|
|
223
|
+
return err.data;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
return { error: err?.message || err?.name || err, status: "error" };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async submit(transaction) {
|
|
231
|
+
try {
|
|
232
|
+
return await this.request({ command: "submit", tx_blob: transaction });
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
this.logger?.debug({
|
|
236
|
+
service: "Bithomp::XRPL::Connection",
|
|
237
|
+
function: "submit",
|
|
238
|
+
url: this.url,
|
|
239
|
+
error: err?.message || err?.name || err,
|
|
240
|
+
});
|
|
241
|
+
if (err.data) {
|
|
242
|
+
return err.data;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return { error: err?.message || err?.name || err };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
isConnected() {
|
|
250
|
+
if (!this.client) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (!this.client.isConnected()) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
getOnlinePeriodMs() {
|
|
259
|
+
if (this.isConnected()) {
|
|
260
|
+
return this.onlineSince ? (0, utils_1.getTimestamp)() - this.onlineSince : 0;
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
getLatencyMs() {
|
|
265
|
+
return this.latency.map((info) => info.delta).reduce((a, b) => a + b, 0) / this.latency.length || 0;
|
|
266
|
+
}
|
|
267
|
+
getNetworkID() {
|
|
268
|
+
if (typeof this.serverInfo?.network_id === "number") {
|
|
269
|
+
return this.serverInfo.network_id;
|
|
270
|
+
}
|
|
271
|
+
return this.networkID;
|
|
272
|
+
}
|
|
273
|
+
isLedgerIndexAvailable(ledgerIndex) {
|
|
274
|
+
if (typeof ledgerIndex !== "number") {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
if (!this.serverInfo?.complete_ledgers) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
const completeLedgers = this.serverInfo.complete_ledgers.split("-");
|
|
281
|
+
if (completeLedgers.length !== 2) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
completeLedgers[0] = parseInt(completeLedgers[0], 10);
|
|
285
|
+
completeLedgers[1] = parseInt(completeLedgers[1], 10);
|
|
286
|
+
if (ledgerIndex < completeLedgers[0] - AVAILABLE_LEDGER_INDEX_WINDOW ||
|
|
287
|
+
ledgerIndex > completeLedgers[1] + AVAILABLE_LEDGER_INDEX_WINDOW) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
isLedgerIndexPresent(ledgerIndex) {
|
|
293
|
+
if (typeof ledgerIndex !== "number") {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
if (!this.serverInfo?.complete_ledgers) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
const completeLedgers = this.serverInfo.complete_ledgers.split("-");
|
|
300
|
+
if (completeLedgers.length !== 2) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
completeLedgers[0] = parseInt(completeLedgers[0], 10);
|
|
304
|
+
completeLedgers[1] = parseInt(completeLedgers[1], 10);
|
|
305
|
+
if (ledgerIndex < completeLedgers[0] || ledgerIndex > completeLedgers[1]) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
updateLatency(delta) {
|
|
311
|
+
this.latency.push({
|
|
312
|
+
timestamp: new Date(),
|
|
313
|
+
delta,
|
|
314
|
+
});
|
|
315
|
+
this.latency.splice(0, this.latency.length - 10);
|
|
316
|
+
}
|
|
317
|
+
async reconnect() {
|
|
318
|
+
this.logger?.debug({
|
|
319
|
+
service: "Bithomp::XRPL::Connection",
|
|
320
|
+
function: "reconnect",
|
|
321
|
+
url: this.url,
|
|
322
|
+
shutdown: this.shutdown,
|
|
323
|
+
});
|
|
324
|
+
if (this.shutdown) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
this.emit("reconnect");
|
|
328
|
+
try {
|
|
329
|
+
this.removeClient();
|
|
330
|
+
this.resetTypes();
|
|
331
|
+
this.serverInfoUpdating = false;
|
|
332
|
+
this.onlineSince = 0;
|
|
333
|
+
this.serverInfo = null;
|
|
334
|
+
this.streamsSubscribed = false;
|
|
335
|
+
await this.connect();
|
|
336
|
+
}
|
|
337
|
+
catch (e) {
|
|
338
|
+
this.logger?.warn({
|
|
339
|
+
service: "Bithomp::XRPL::Connection",
|
|
340
|
+
function: "reconnect",
|
|
341
|
+
url: this.url,
|
|
342
|
+
error: e.message,
|
|
343
|
+
});
|
|
344
|
+
this.connectionValidation("reconnect");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
removeClient(code = 1000) {
|
|
348
|
+
try {
|
|
349
|
+
if (this.client) {
|
|
350
|
+
this.client.removeAllListeners();
|
|
351
|
+
this.client.disconnect();
|
|
352
|
+
this.client = undefined;
|
|
353
|
+
this.emit("disconnected", code);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
catch (_err) {
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
removeWatchTimer() {
|
|
360
|
+
if (this.connectionWatchTimer !== null) {
|
|
361
|
+
clearTimeout(this.connectionWatchTimer);
|
|
362
|
+
this.connectionWatchTimer = null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
setupEmitter() {
|
|
366
|
+
if (!this.client) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.client.on("connected", () => {
|
|
370
|
+
this.logger?.debug({
|
|
371
|
+
service: "Bithomp::XRPL::Connection",
|
|
372
|
+
emit: "connected",
|
|
373
|
+
url: this.url,
|
|
374
|
+
});
|
|
375
|
+
this.emit("connected");
|
|
376
|
+
this.onlineSince = (0, utils_1.getTimestamp)();
|
|
377
|
+
});
|
|
378
|
+
this.client.on("disconnected", (code) => {
|
|
379
|
+
this.logger?.debug({
|
|
380
|
+
service: "Bithomp::XRPL::Connection",
|
|
381
|
+
emit: "disconnected",
|
|
382
|
+
code,
|
|
383
|
+
url: this.url,
|
|
384
|
+
});
|
|
385
|
+
if (this.client) {
|
|
386
|
+
this.client.removeAllListeners();
|
|
387
|
+
this.client = undefined;
|
|
388
|
+
}
|
|
389
|
+
this.emit("disconnected", code);
|
|
390
|
+
if (!this.shutdown) {
|
|
391
|
+
this.scheduleReconnect(RECONNECT_TIMEOUT);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
this.client.on("error", (source, message, error) => {
|
|
395
|
+
try {
|
|
396
|
+
if (source === "noPermission") {
|
|
397
|
+
if (!error.status) {
|
|
398
|
+
error.status = "error";
|
|
399
|
+
}
|
|
400
|
+
if (this.client) {
|
|
401
|
+
this.client.requestManager.handleResponse(error);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
this.logger?.error({
|
|
406
|
+
service: "Bithomp::XRPL::Connection",
|
|
407
|
+
emit: "error",
|
|
408
|
+
source,
|
|
409
|
+
url: this.url,
|
|
410
|
+
error: message || error?.name || error,
|
|
411
|
+
});
|
|
412
|
+
this.emit("error", source, message, error);
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
this.logger?.warn({
|
|
416
|
+
service: "Bithomp::XRPL::Connection",
|
|
417
|
+
emit: "error",
|
|
418
|
+
url: this.url,
|
|
419
|
+
error: err?.message || err?.name || err,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
this.client.on("ledgerClosed", (ledgerStream) => {
|
|
424
|
+
this.onLedgerClosed(ledgerStream);
|
|
425
|
+
this.emit("ledgerClosed", ledgerStream);
|
|
426
|
+
});
|
|
427
|
+
this.client.on("transaction", (transactionStream) => {
|
|
428
|
+
this.emit("transaction", transactionStream);
|
|
429
|
+
});
|
|
430
|
+
this.client.on("validationReceived", (validation) => {
|
|
431
|
+
this.emit("validationReceived", validation);
|
|
432
|
+
});
|
|
433
|
+
this.client.on("manifestReceived", (manifest) => {
|
|
434
|
+
this.emit("manifestReceived", manifest);
|
|
435
|
+
});
|
|
436
|
+
this.client.on("peerStatusChange", (status) => {
|
|
437
|
+
this.emit("peerStatusChange", status);
|
|
438
|
+
});
|
|
439
|
+
this.client.on("consensusPhase", (consensus) => {
|
|
440
|
+
this.emit("consensusPhase", consensus);
|
|
441
|
+
});
|
|
442
|
+
this.client.on("path_find", (path) => {
|
|
443
|
+
this.emit("path_find", path);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
resetTypes() {
|
|
447
|
+
if (typeof this.type === "string") {
|
|
448
|
+
this.types = this.type.split(",").map((v) => v.trim());
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
this.types = [];
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
async updateSubscriptions(request) {
|
|
455
|
+
if (request.command === "subscribe") {
|
|
456
|
+
const addStreams = [];
|
|
457
|
+
const addAccounts = [];
|
|
458
|
+
if (request.streams) {
|
|
459
|
+
for (const stream of request.streams) {
|
|
460
|
+
if (this.streams[stream] === undefined) {
|
|
461
|
+
this.streams[stream] = 1;
|
|
462
|
+
addStreams.push(stream);
|
|
463
|
+
}
|
|
464
|
+
else if (stream !== "ledger") {
|
|
465
|
+
this.streams[stream]++;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (request.accounts) {
|
|
470
|
+
for (const account of request.accounts) {
|
|
471
|
+
if (this.accounts[account] === undefined) {
|
|
472
|
+
this.accounts[account] = 1;
|
|
473
|
+
addAccounts.push(account);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
this.accounts[account]++;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (addStreams.length > 0 || addAccounts.length > 0) {
|
|
481
|
+
return await this.subscribe(addStreams, addAccounts);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else if (request.command === "unsubscribe") {
|
|
485
|
+
const removeStreams = [];
|
|
486
|
+
const removeAccounts = [];
|
|
487
|
+
if (request.streams) {
|
|
488
|
+
for (const stream of request.streams) {
|
|
489
|
+
if (this.streams[stream] === undefined) {
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (stream !== "ledger") {
|
|
493
|
+
this.streams[stream]--;
|
|
494
|
+
}
|
|
495
|
+
if (this.streams[stream] === 0) {
|
|
496
|
+
delete this.streams[stream];
|
|
497
|
+
removeStreams.push(stream);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (request.accounts) {
|
|
502
|
+
for (const account of request.accounts) {
|
|
503
|
+
if (this.accounts[account] === undefined) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
this.accounts[account]--;
|
|
507
|
+
if (this.accounts[account] === 0) {
|
|
508
|
+
delete this.accounts[account];
|
|
509
|
+
removeAccounts.push(account);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (removeStreams.length > 0 || removeAccounts.length > 0) {
|
|
514
|
+
return await this.unsubscribe(removeStreams, removeAccounts);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return { status: "success" };
|
|
518
|
+
}
|
|
519
|
+
async subscribe(streams, accounts) {
|
|
520
|
+
if (this.shutdown) {
|
|
521
|
+
return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
|
|
522
|
+
}
|
|
523
|
+
if (this.streamsSubscribed === true && streams === undefined && accounts === undefined) {
|
|
524
|
+
return { status: "success" };
|
|
525
|
+
}
|
|
526
|
+
streams = streams || Object.keys(this.streams);
|
|
527
|
+
accounts = accounts || Object.keys(this.accounts);
|
|
528
|
+
const request = { command: "subscribe" };
|
|
529
|
+
if (streams.length > 0) {
|
|
530
|
+
request.streams = streams;
|
|
531
|
+
}
|
|
532
|
+
if (accounts.length > 0) {
|
|
533
|
+
request.accounts = accounts;
|
|
534
|
+
}
|
|
535
|
+
const result = await this.request(request, { skip_subscription_update: true });
|
|
536
|
+
if (result.result && !result.error) {
|
|
537
|
+
this.streamsSubscribed = true;
|
|
538
|
+
}
|
|
539
|
+
return result;
|
|
540
|
+
}
|
|
541
|
+
async unsubscribe(streams, accounts) {
|
|
542
|
+
if (streams === undefined && accounts === undefined) {
|
|
543
|
+
this.streamsSubscribed = false;
|
|
544
|
+
}
|
|
545
|
+
streams = streams || Object.keys(this.streams);
|
|
546
|
+
accounts = accounts || Object.keys(this.accounts);
|
|
547
|
+
const request = { command: "unsubscribe" };
|
|
548
|
+
if (streams.length > 0) {
|
|
549
|
+
request.streams = streams;
|
|
550
|
+
}
|
|
551
|
+
if (accounts.length > 0) {
|
|
552
|
+
request.accounts = accounts;
|
|
553
|
+
}
|
|
554
|
+
return await this.request(request, { skip_subscription_update: true });
|
|
555
|
+
}
|
|
556
|
+
onLedgerClosed(ledgerStream) {
|
|
557
|
+
const time = (0, utils_1.getTimestamp)();
|
|
558
|
+
const ledgerTime = (0, ledger_1.ledgerTimeToTimestamp)(ledgerStream.ledger_time);
|
|
559
|
+
if (ledgerTime < time) {
|
|
560
|
+
this.updateLatency(time - ledgerTime);
|
|
561
|
+
}
|
|
562
|
+
if (this.serverInfo) {
|
|
563
|
+
this.serverInfo.complete_ledgers = ledgerStream.validated_ledgers;
|
|
564
|
+
if (this.serverInfo.validated_ledger) {
|
|
565
|
+
this.serverInfo.validated_ledger.age = Math.round((time - ledgerTime) / 1000);
|
|
566
|
+
this.serverInfo.validated_ledger.seq = ledgerStream.ledger_index;
|
|
567
|
+
this.serverInfo.validated_ledger.hash = ledgerStream.ledger_hash;
|
|
568
|
+
this.serverInfo.validated_ledger.base_fee_xrp = (0, common_1.dropsToXrp)(ledgerStream.fee_base);
|
|
569
|
+
this.serverInfo.validated_ledger.reserve_base_xrp = (0, common_1.dropsToXrp)(ledgerStream.reserve_base);
|
|
570
|
+
this.serverInfo.validated_ledger.reserve_inc_xrp = (0, common_1.dropsToXrp)(ledgerStream.reserve_inc);
|
|
571
|
+
}
|
|
572
|
+
const serverInfoTime = new Date(this.serverInfo.time).getTime();
|
|
573
|
+
if (serverInfoTime + SERVER_INFO_UPDATE_INTERVAL < time) {
|
|
574
|
+
this.updateServerInfo();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
this.updateServerInfo();
|
|
579
|
+
}
|
|
580
|
+
this.connectionValidation("ledgerClosed");
|
|
581
|
+
}
|
|
582
|
+
async updateServerInfo() {
|
|
583
|
+
if (this.serverInfoUpdating || this.shutdown) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this.serverInfoUpdating = true;
|
|
587
|
+
try {
|
|
588
|
+
const serverInfo = await this.request({ command: "server_info" });
|
|
589
|
+
if (serverInfo?.result?.info) {
|
|
590
|
+
this.serverInfo = serverInfo.result.info;
|
|
591
|
+
if (typeof this.serverInfo?.clio_version === "string") {
|
|
592
|
+
if (!this.types.includes("clio")) {
|
|
593
|
+
this.types.push("clio");
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
const index = this.types.indexOf("clio");
|
|
598
|
+
if (index !== -1) {
|
|
599
|
+
this.types.splice(index, 1);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch (_err) {
|
|
605
|
+
}
|
|
606
|
+
this.serverInfoUpdating = false;
|
|
607
|
+
}
|
|
608
|
+
connectionValidation(event) {
|
|
609
|
+
this.logger?.debug({
|
|
610
|
+
service: "Bithomp::XRPL::Connection",
|
|
611
|
+
function: "connectionValidation",
|
|
612
|
+
event,
|
|
613
|
+
url: this.url,
|
|
614
|
+
shutdown: this.shutdown,
|
|
615
|
+
});
|
|
616
|
+
this.removeWatchTimer();
|
|
617
|
+
if (this.shutdown) {
|
|
618
|
+
this.removeClient();
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, LEDGER_CLOSED_TIMEOUT);
|
|
622
|
+
if (this.streamsSubscribed === false) {
|
|
623
|
+
this.subscribe();
|
|
624
|
+
}
|
|
625
|
+
if (this.serverInfo === null && this.isConnected()) {
|
|
626
|
+
this.updateServerInfo();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
async connectionWatchTimeout() {
|
|
630
|
+
this.logger?.debug({
|
|
631
|
+
service: "Bithomp::XRPL::Connection",
|
|
632
|
+
function: "connectionWatchTimeout",
|
|
633
|
+
url: this.url,
|
|
634
|
+
timeout: LEDGER_CLOSED_TIMEOUT,
|
|
635
|
+
shutdown: this.shutdown,
|
|
636
|
+
});
|
|
637
|
+
this.connectionWatchTimer = null;
|
|
638
|
+
this.updateLatency(LEDGER_CLOSED_TIMEOUT);
|
|
639
|
+
try {
|
|
640
|
+
await this.reconnect();
|
|
641
|
+
}
|
|
642
|
+
catch (e) {
|
|
643
|
+
this.logger?.warn({
|
|
644
|
+
service: "Bithomp::XRPL::Connection",
|
|
645
|
+
function: "connectionWatchTimeout",
|
|
646
|
+
url: this.url,
|
|
647
|
+
error: e.message,
|
|
648
|
+
});
|
|
649
|
+
this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, RECONNECT_TIMEOUT);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
exports.Connection = Connection;
|