@bithomp/xrpl-api 3.7.30 → 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/parse/outcome/orderbook_changes.js +5 -4
- package/lib/parse/specification/offer-create.js +1 -0
- 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/lib/types/offers.d.ts +1 -0
- package/package.json +11 -11
package/lib/connection.js
CHANGED
|
@@ -45,7 +45,8 @@ const common_1 = require("./common");
|
|
|
45
45
|
const utils_1 = require("./common/utils");
|
|
46
46
|
const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
|
|
47
47
|
const RECONNECT_TIMEOUT = 1000 * 5;
|
|
48
|
-
const LEDGER_CLOSED_TIMEOUT = 1000 *
|
|
48
|
+
const LEDGER_CLOSED_TIMEOUT = 1000 * 15;
|
|
49
|
+
const SLOW_RECONNECT_TIMEOUT = LEDGER_CLOSED_TIMEOUT * 5;
|
|
49
50
|
const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
|
|
50
51
|
const AVAILABLE_LEDGER_INDEX_WINDOW = 1000;
|
|
51
52
|
exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
|
|
@@ -98,6 +99,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
98
99
|
this.client = new XRPLConnection.Connection(this.url, (0, common_1.removeUndefined)({ timeout: this.timeout, connectionTimeout: this.connectionTimeout }));
|
|
99
100
|
this.setupEmitter();
|
|
100
101
|
await this.client.connect();
|
|
102
|
+
this.latency = [];
|
|
101
103
|
await this.updateServerInfo();
|
|
102
104
|
await this.subscribe();
|
|
103
105
|
this.connectionValidation("connect");
|
|
@@ -114,7 +116,7 @@ class Connection extends events_1.EventEmitter {
|
|
|
114
116
|
this.removeClient();
|
|
115
117
|
let reconnectDelay = LEDGER_CLOSED_TIMEOUT;
|
|
116
118
|
if (SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage)) {
|
|
117
|
-
reconnectDelay =
|
|
119
|
+
reconnectDelay = SLOW_RECONNECT_TIMEOUT;
|
|
118
120
|
}
|
|
119
121
|
this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, reconnectDelay);
|
|
120
122
|
}
|
|
@@ -185,10 +187,10 @@ class Connection extends events_1.EventEmitter {
|
|
|
185
187
|
}
|
|
186
188
|
const waitTime = (0, utils_1.getTimestamp)() + RECONNECT_TIMEOUT;
|
|
187
189
|
while (!this.client || !this.isConnected()) {
|
|
188
|
-
await (0, utils_1.sleep)(100);
|
|
189
190
|
if (this.shutdown) {
|
|
190
191
|
return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
|
|
191
192
|
}
|
|
193
|
+
await (0, utils_1.sleep)(100);
|
|
192
194
|
if ((0, utils_1.getTimestamp)() > waitTime) {
|
|
193
195
|
return { error: "notConnected", error_message: "Not connected.", status: "error" };
|
|
194
196
|
}
|
|
@@ -68,24 +68,25 @@ function parseChangeAmount(node, type) {
|
|
|
68
68
|
return lodash_1.default.assign({}, finalAmount, { value: value });
|
|
69
69
|
}
|
|
70
70
|
function parseOrderChange(node) {
|
|
71
|
-
const flags = (0, offer_flags_1.default)(node.finalFields.Flags);
|
|
72
71
|
const takerPays = parseChangeAmount(node, "TakerPays");
|
|
73
72
|
const takerGets = parseChangeAmount(node, "TakerGets");
|
|
73
|
+
const fields = Object.keys(node.finalFields).length > 0 ? node.finalFields : node.newFields;
|
|
74
|
+
const flags = (0, offer_flags_1.default)(fields.Flags);
|
|
74
75
|
const orderChange = (0, common_1.removeUndefined)({
|
|
75
76
|
flags,
|
|
76
77
|
takerGets,
|
|
77
78
|
takerPays,
|
|
78
|
-
sequence:
|
|
79
|
+
sequence: fields.Sequence,
|
|
79
80
|
status: parseOrderStatus(node),
|
|
80
81
|
makerExchangeRate: getQuality(node),
|
|
81
82
|
expirationTime: getExpirationTime(node),
|
|
82
|
-
domainID:
|
|
83
|
+
domainID: fields.DomainID,
|
|
83
84
|
direction: (node.finalFields.Flags & xrpl_1.LedgerEntry.OfferFlags.lsfSell) === 0 ? "buy" : "sell",
|
|
84
85
|
quantity: flags.sell === true ? takerGets : takerPays,
|
|
85
86
|
totalPrice: flags.sell === true ? takerPays : takerGets,
|
|
86
87
|
});
|
|
87
88
|
Object.defineProperty(orderChange, "account", {
|
|
88
|
-
value:
|
|
89
|
+
value: fields.Account,
|
|
89
90
|
});
|
|
90
91
|
return orderChange;
|
|
91
92
|
}
|
|
@@ -64,6 +64,7 @@ function parseOfferCreate(tx, nativeCurrency) {
|
|
|
64
64
|
takerGets,
|
|
65
65
|
takerPays,
|
|
66
66
|
expirationTime: (0, utils_1.parseTimestamp)(tx.Expiration),
|
|
67
|
+
domainID: tx.DomainID,
|
|
67
68
|
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
68
69
|
memos: (0, memos_1.parseMemos)(tx),
|
|
69
70
|
direction: (tx.Flags & xrpl_1.OfferCreateFlags.tfSell) === 0 ? "buy" : "sell",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.decode = decode;
|
|
7
|
+
exports.encode = encode;
|
|
8
|
+
const R_B58_DICT = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
|
|
9
|
+
const base_x_1 = __importDefault(require("base-x"));
|
|
10
|
+
const base58 = (0, base_x_1.default)(R_B58_DICT);
|
|
11
|
+
function decode(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return Buffer.from(base58.decode(value));
|
|
17
|
+
}
|
|
18
|
+
catch (_err) {
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function encode(buffer) {
|
|
23
|
+
if (!buffer) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return base58.encode(buffer);
|
|
28
|
+
}
|
|
29
|
+
catch (_err) {
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Connection, ConnectionOptions } from "./connection";
|
|
2
|
+
import { LedgerIndex } from "./models/ledger";
|
|
3
|
+
export * from "./ledger";
|
|
4
|
+
export declare let feeCushion: number;
|
|
5
|
+
export declare let logger: any;
|
|
6
|
+
export interface ClientOptions extends ConnectionOptions {
|
|
7
|
+
feeCushion?: number;
|
|
8
|
+
maxFeeXRP?: string;
|
|
9
|
+
logger?: any;
|
|
10
|
+
nativeCurrency?: "XRP" | "XAH";
|
|
11
|
+
loadBalancing?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ClientConnection {
|
|
14
|
+
url: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
connectionTimeout?: number;
|
|
18
|
+
networkID?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function setup(servers: ClientConnection[], options?: ClientOptions): void;
|
|
21
|
+
export declare function connect(): Promise<void>;
|
|
22
|
+
export declare function disconnect(): Promise<void>;
|
|
23
|
+
export declare function getNativeCurrency(): string;
|
|
24
|
+
export declare function findConnection(type?: string, url?: string, strongFilter?: boolean, hash?: string, networkID?: number): Connection | null;
|
|
25
|
+
export declare function findConnectionByLedger(ledgerIndex?: LedgerIndex, ledgerHash?: string, networkID?: number): Connection | null;
|
|
@@ -0,0 +1,192 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.logger = exports.feeCushion = void 0;
|
|
18
|
+
exports.setup = setup;
|
|
19
|
+
exports.connect = connect;
|
|
20
|
+
exports.disconnect = disconnect;
|
|
21
|
+
exports.getNativeCurrency = getNativeCurrency;
|
|
22
|
+
exports.findConnection = findConnection;
|
|
23
|
+
exports.findConnectionByLedger = findConnectionByLedger;
|
|
24
|
+
const connection_1 = require("./connection");
|
|
25
|
+
const common_1 = require("./common");
|
|
26
|
+
__exportStar(require("./ledger"), exports);
|
|
27
|
+
exports.feeCushion = 1.3;
|
|
28
|
+
let clientConnections = [];
|
|
29
|
+
let loadBalancing = false;
|
|
30
|
+
let nativeCurrency = common_1.MAINNET_NATIVE_CURRENCY;
|
|
31
|
+
function setup(servers, options = {}) {
|
|
32
|
+
exports.logger = options.logger;
|
|
33
|
+
exports.logger?.debug({
|
|
34
|
+
service: "Bithomp::XRPL::Client",
|
|
35
|
+
function: "setup",
|
|
36
|
+
});
|
|
37
|
+
if (servers) {
|
|
38
|
+
disconnect();
|
|
39
|
+
clientConnections = [];
|
|
40
|
+
for (const server of servers) {
|
|
41
|
+
clientConnections.push(new connection_1.Connection(server.url, server.type, {
|
|
42
|
+
logger: options.logger,
|
|
43
|
+
timeout: server.timeout,
|
|
44
|
+
connectionTimeout: server.connectionTimeout,
|
|
45
|
+
networkID: server.networkID,
|
|
46
|
+
apiVersion: options.apiVersion,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options.feeCushion) {
|
|
51
|
+
exports.feeCushion = options.feeCushion;
|
|
52
|
+
}
|
|
53
|
+
if (options.nativeCurrency) {
|
|
54
|
+
nativeCurrency = options.nativeCurrency;
|
|
55
|
+
}
|
|
56
|
+
loadBalancing = options.loadBalancing === true;
|
|
57
|
+
}
|
|
58
|
+
async function connect() {
|
|
59
|
+
exports.logger?.debug({
|
|
60
|
+
service: "Bithomp::XRPL::Client",
|
|
61
|
+
function: "connect",
|
|
62
|
+
});
|
|
63
|
+
await Promise.all(clientConnections.map(async (connection) => {
|
|
64
|
+
await connection.connect();
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
async function disconnect() {
|
|
68
|
+
exports.logger?.debug({
|
|
69
|
+
service: "Bithomp::XRPL::Client",
|
|
70
|
+
function: "disconnect",
|
|
71
|
+
});
|
|
72
|
+
await Promise.all(clientConnections.map(async (connection) => {
|
|
73
|
+
await connection.disconnect();
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
function getNativeCurrency() {
|
|
77
|
+
return nativeCurrency || common_1.MAINNET_NATIVE_CURRENCY;
|
|
78
|
+
}
|
|
79
|
+
function findConnection(type, url, strongFilter, hash, networkID) {
|
|
80
|
+
if (!strongFilter) {
|
|
81
|
+
if (clientConnections.length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
else if (clientConnections.length === 1) {
|
|
85
|
+
return clientConnections[0];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
let connections = clientConnections.filter((con) => {
|
|
89
|
+
if (!con.isConnected()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (typeof networkID === "number" && typeof con.getNetworkID() === "number") {
|
|
93
|
+
if (con.getNetworkID() !== networkID) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (typeof url === "string" && con.url !== url) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (typeof hash === "string" && con.hash !== hash) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (typeof type !== "string") {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (con.types.length === 0) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const foundTypes = type.split(",").map((t) => {
|
|
110
|
+
t = t.trim();
|
|
111
|
+
if (t[0] === "!") {
|
|
112
|
+
return !con.types.includes(t.slice(1));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return con.types.includes(t);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
for (const found of foundTypes) {
|
|
119
|
+
if (!found) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
if (strongFilter === undefined || strongFilter === false) {
|
|
126
|
+
if (connections.length === 0) {
|
|
127
|
+
connections = clientConnections.filter((con) => {
|
|
128
|
+
if (!con.isConnected()) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (typeof networkID === "number" && typeof con.getNetworkID() === "number") {
|
|
132
|
+
if (con.getNetworkID() !== networkID) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (connections.length === 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
else if (connections.length === 1) {
|
|
144
|
+
return connections[0];
|
|
145
|
+
}
|
|
146
|
+
if (loadBalancing) {
|
|
147
|
+
const index = Math.floor(Math.random() * connections.length);
|
|
148
|
+
return connections[index];
|
|
149
|
+
}
|
|
150
|
+
connections = connections.sort(sortHelperConnections);
|
|
151
|
+
return connections[0];
|
|
152
|
+
}
|
|
153
|
+
function findConnectionByLedger(ledgerIndex, ledgerHash, networkID) {
|
|
154
|
+
if (ledgerHash) {
|
|
155
|
+
return findConnection("history", undefined, false, undefined, networkID);
|
|
156
|
+
}
|
|
157
|
+
if (typeof ledgerIndex === "string" || ledgerIndex === undefined) {
|
|
158
|
+
return findConnection(undefined, undefined, false, undefined, networkID);
|
|
159
|
+
}
|
|
160
|
+
const availableConnections = clientConnections.filter((con) => {
|
|
161
|
+
if (!con.isConnected()) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if (typeof networkID === "number" && typeof con.getNetworkID() === "number") {
|
|
165
|
+
if (con.getNetworkID() !== networkID) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return con.isLedgerIndexPresent(ledgerIndex);
|
|
170
|
+
});
|
|
171
|
+
if (availableConnections.length === 0) {
|
|
172
|
+
return findConnection(undefined, undefined, false, undefined, networkID);
|
|
173
|
+
}
|
|
174
|
+
else if (availableConnections.length === 1) {
|
|
175
|
+
return availableConnections[0];
|
|
176
|
+
}
|
|
177
|
+
if (loadBalancing) {
|
|
178
|
+
const index = Math.floor(Math.random() * availableConnections.length);
|
|
179
|
+
return availableConnections[index];
|
|
180
|
+
}
|
|
181
|
+
const sortedConnections = availableConnections.sort(sortHelperConnections);
|
|
182
|
+
return sortedConnections[0];
|
|
183
|
+
}
|
|
184
|
+
function sortHelperConnections(a, b) {
|
|
185
|
+
if (a.getLatencyMs() < b.getLatencyMs()) {
|
|
186
|
+
return -1;
|
|
187
|
+
}
|
|
188
|
+
if (a.getLatencyMs() > b.getLatencyMs()) {
|
|
189
|
+
return 1;
|
|
190
|
+
}
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = exports.XrplApiError = void 0;
|
|
4
|
+
const xrpl_api_error_1 = require("./xrpl_api_error");
|
|
5
|
+
Object.defineProperty(exports, "XrplApiError", { enumerable: true, get: function () { return xrpl_api_error_1.XrplApiError; } });
|
|
6
|
+
const validation_error_1 = require("./validation_error");
|
|
7
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.ValidationError; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
const xrpl_api_error_1 = require("./xrpl_api_error");
|
|
5
|
+
class ValidationError extends xrpl_api_error_1.XrplApiError {
|
|
6
|
+
}
|
|
7
|
+
exports.ValidationError = ValidationError;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XrplApiError = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
class XrplApiError extends Error {
|
|
7
|
+
constructor(message = "", data) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = (0, utils_1.getConstructorName)(this);
|
|
10
|
+
this.message = message;
|
|
11
|
+
this.data = data;
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
let result = `[${this.name}(${this.message}`;
|
|
18
|
+
if (this.data) {
|
|
19
|
+
result += `, ${(0, util_1.inspect)(this.data)}`;
|
|
20
|
+
}
|
|
21
|
+
result += ")]";
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
inspect() {
|
|
25
|
+
return this.toString();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.XrplApiError = XrplApiError;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as errors from "./errors";
|
|
2
|
+
import sha512Half from "./sha512Half";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export { errors, sha512Half };
|
|
5
|
+
export declare const MAINNET_NATIVE_CURRENCY = "XRP";
|
|
6
|
+
export declare const XAHAU_NATIVE_CURRENCY = "XAH";
|
|
7
|
+
export declare const dropsInXRP = 1000000;
|
|
8
|
+
export declare const ACCOUNT_ZERO = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
9
|
+
export declare const BLACKHOLE_ACCOUNTS: string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.BLACKHOLE_ACCOUNTS = exports.ACCOUNT_ZERO = exports.dropsInXRP = exports.XAHAU_NATIVE_CURRENCY = exports.MAINNET_NATIVE_CURRENCY = exports.sha512Half = exports.errors = void 0;
|
|
43
|
+
const errors = __importStar(require("./errors"));
|
|
44
|
+
exports.errors = errors;
|
|
45
|
+
const sha512Half_1 = __importDefault(require("./sha512Half"));
|
|
46
|
+
exports.sha512Half = sha512Half_1.default;
|
|
47
|
+
__exportStar(require("./utils"), exports);
|
|
48
|
+
exports.MAINNET_NATIVE_CURRENCY = "XRP";
|
|
49
|
+
exports.XAHAU_NATIVE_CURRENCY = "XAH";
|
|
50
|
+
exports.dropsInXRP = 1000000;
|
|
51
|
+
exports.ACCOUNT_ZERO = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
52
|
+
exports.BLACKHOLE_ACCOUNTS = [
|
|
53
|
+
exports.ACCOUNT_ZERO,
|
|
54
|
+
"rrrrrrrrrrrrrrrrrrrrBZbvji",
|
|
55
|
+
"rrrrrrrrrrrrrrrrrNAMEtxvNvQ",
|
|
56
|
+
"rrrrrrrrrrrrrrrrrrrn5RM1rHd",
|
|
57
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const crypto_1 = require("crypto");
|
|
4
|
+
const HASH_SIZE = 64;
|
|
5
|
+
function sha512Half(hex) {
|
|
6
|
+
return (0, crypto_1.createHash)('sha512')
|
|
7
|
+
.update(Buffer.from(hex, 'hex'))
|
|
8
|
+
.digest('hex')
|
|
9
|
+
.toUpperCase()
|
|
10
|
+
.slice(0, HASH_SIZE);
|
|
11
|
+
}
|
|
12
|
+
exports.default = sha512Half;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
export type SortDirection = -1 | 0 | 1;
|
|
3
|
+
export declare function signum(num: number): SortDirection;
|
|
4
|
+
export declare function compareTransactions(first: any, second: any): SortDirection;
|
|
5
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
export declare function getTimestamp(): number;
|
|
7
|
+
export declare function createMarker(hash: string, marker?: any): any;
|
|
8
|
+
export declare function parseMarker(marker?: any): any;
|
|
9
|
+
export declare function dropsToXrp(drops: BigNumber.Value): string;
|
|
10
|
+
export declare function xrpToDrops(xrp: BigNumber.Value): string;
|
|
11
|
+
export declare function removeUndefined<T extends object>(obj: T): T;
|
|
12
|
+
export declare function emptyObjectToUndefined<T extends object>(obj: T): T | undefined;
|
|
13
|
+
export declare function getConstructorName(object: object): string | undefined;
|
|
14
|
+
export declare function isClioResponse(response: any): boolean;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.signum = signum;
|
|
7
|
+
exports.compareTransactions = compareTransactions;
|
|
8
|
+
exports.sleep = sleep;
|
|
9
|
+
exports.getTimestamp = getTimestamp;
|
|
10
|
+
exports.createMarker = createMarker;
|
|
11
|
+
exports.parseMarker = parseMarker;
|
|
12
|
+
exports.dropsToXrp = dropsToXrp;
|
|
13
|
+
exports.xrpToDrops = xrpToDrops;
|
|
14
|
+
exports.removeUndefined = removeUndefined;
|
|
15
|
+
exports.emptyObjectToUndefined = emptyObjectToUndefined;
|
|
16
|
+
exports.getConstructorName = getConstructorName;
|
|
17
|
+
exports.isClioResponse = isClioResponse;
|
|
18
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
19
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
20
|
+
const errors_1 = require("./errors");
|
|
21
|
+
const index_1 = require("./index");
|
|
22
|
+
function signum(num) {
|
|
23
|
+
return num === 0 ? 0 : num > 0 ? 1 : -1;
|
|
24
|
+
}
|
|
25
|
+
function compareTransactions(first, second) {
|
|
26
|
+
if (!first.tx || !first.meta || !second.tx || !second.meta) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
if (first.tx.ledger_index === second.tx.ledger_index) {
|
|
30
|
+
return signum(first.meta.TransactionIndex - second.meta.TransactionIndex);
|
|
31
|
+
}
|
|
32
|
+
return first.tx.ledger_index < second.tx.ledger_index ? -1 : 1;
|
|
33
|
+
}
|
|
34
|
+
async function sleep(ms) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
setTimeout(resolve, ms);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function getTimestamp() {
|
|
40
|
+
return new Date().getTime();
|
|
41
|
+
}
|
|
42
|
+
function createMarker(hash, marker) {
|
|
43
|
+
if (marker === undefined) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (marker === null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (typeof marker === "string") {
|
|
50
|
+
return `${hash},${marker}`;
|
|
51
|
+
}
|
|
52
|
+
if (typeof marker === "object") {
|
|
53
|
+
marker.bithompHash = hash;
|
|
54
|
+
}
|
|
55
|
+
return marker;
|
|
56
|
+
}
|
|
57
|
+
function parseMarker(marker) {
|
|
58
|
+
let hash;
|
|
59
|
+
if (typeof marker === "object" && marker.bithompHash) {
|
|
60
|
+
hash = marker.bithompHash;
|
|
61
|
+
delete marker.bithompHash;
|
|
62
|
+
return { hash, marker };
|
|
63
|
+
}
|
|
64
|
+
if (typeof marker !== "string") {
|
|
65
|
+
return { hash, marker };
|
|
66
|
+
}
|
|
67
|
+
if (marker) {
|
|
68
|
+
const markerParams = marker.split(",");
|
|
69
|
+
if (markerParams.length > 1) {
|
|
70
|
+
hash = markerParams[0];
|
|
71
|
+
markerParams.shift();
|
|
72
|
+
marker = markerParams.join(",");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { hash, marker };
|
|
76
|
+
}
|
|
77
|
+
function dropsToXrp(drops) {
|
|
78
|
+
if (typeof drops === "string") {
|
|
79
|
+
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
80
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
81
|
+
}
|
|
82
|
+
else if (drops === ".") {
|
|
83
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a BigNumber or string-encoded number.`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
drops = new bignumber_js_1.default(drops).toString(10);
|
|
87
|
+
if (drops.includes(".")) {
|
|
88
|
+
throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has too many decimal places.`);
|
|
89
|
+
}
|
|
90
|
+
if (!drops.match(/^-?[0-9]+$/)) {
|
|
91
|
+
throw new errors_1.ValidationError(`dropsToXrp: failed sanity check - value '${drops}', does not match (^-?[0-9]+$).`);
|
|
92
|
+
}
|
|
93
|
+
return new bignumber_js_1.default(drops).dividedBy(index_1.dropsInXRP).toString(10);
|
|
94
|
+
}
|
|
95
|
+
function xrpToDrops(xrp) {
|
|
96
|
+
if (typeof xrp === "string") {
|
|
97
|
+
if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
98
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
99
|
+
}
|
|
100
|
+
else if (xrp === ".") {
|
|
101
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a BigNumber or string-encoded number.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
xrp = new bignumber_js_1.default(xrp).toString(10);
|
|
105
|
+
if (!xrp.match(/^-?[0-9.]+$/)) {
|
|
106
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}', does not match (^-?[0-9.]+$).`);
|
|
107
|
+
}
|
|
108
|
+
const components = xrp.split(".");
|
|
109
|
+
if (components.length > 2) {
|
|
110
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}' has too many decimal points.`);
|
|
111
|
+
}
|
|
112
|
+
const fraction = components[1] || "0";
|
|
113
|
+
if (fraction.length > 6) {
|
|
114
|
+
throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
|
|
115
|
+
}
|
|
116
|
+
return new bignumber_js_1.default(xrp).times(index_1.dropsInXRP).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
|
|
117
|
+
}
|
|
118
|
+
function removeUndefined(obj) {
|
|
119
|
+
return lodash_1.default.omitBy(obj, (value) => value == null);
|
|
120
|
+
}
|
|
121
|
+
function emptyObjectToUndefined(obj) {
|
|
122
|
+
if (lodash_1.default.isEmpty(obj)) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return obj;
|
|
126
|
+
}
|
|
127
|
+
function getConstructorName(object) {
|
|
128
|
+
if (object.constructor.name) {
|
|
129
|
+
return object.constructor.name;
|
|
130
|
+
}
|
|
131
|
+
const constructorString = object.constructor.toString();
|
|
132
|
+
const functionConstructor = constructorString.match(/^function\s+([^(]*)/);
|
|
133
|
+
const classConstructor = constructorString.match(/^class\s([^\s]*)/);
|
|
134
|
+
if (functionConstructor) {
|
|
135
|
+
return functionConstructor[1];
|
|
136
|
+
}
|
|
137
|
+
else if (classConstructor) {
|
|
138
|
+
return classConstructor[1];
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
function isClioResponse(response) {
|
|
143
|
+
if (!response || !response.warnings) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return response.warnings?.some((w) => w.id === 2001);
|
|
147
|
+
}
|