@bithomp/xrpl-api 2.3.6
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/LICENSE +674 -0
- package/README.md +101 -0
- package/lib/base58.d.ts +3 -0
- package/lib/base58.js +33 -0
- package/lib/client.d.ts +19 -0
- package/lib/client.js +122 -0
- package/lib/common/errors/index.d.ts +3 -0
- package/lib/common/errors/index.js +7 -0
- package/lib/common/errors/ripple_error.d.ts +9 -0
- package/lib/common/errors/ripple_error.js +28 -0
- package/lib/common/errors/utils.d.ts +2 -0
- package/lib/common/errors/utils.js +19 -0
- package/lib/common/errors/validation_error.d.ts +4 -0
- package/lib/common/errors/validation_error.js +7 -0
- package/lib/common/index.d.ts +6 -0
- package/lib/common/index.js +44 -0
- package/lib/common/sha512Half.d.ts +2 -0
- package/lib/common/sha512Half.js +12 -0
- package/lib/common/utils.d.ts +10 -0
- package/lib/common/utils.js +113 -0
- package/lib/connection.d.ts +57 -0
- package/lib/connection.js +369 -0
- package/lib/faucet.d.ts +58 -0
- package/lib/faucet.js +89 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +35 -0
- package/lib/ledger/account_info.d.ts +12 -0
- package/lib/ledger/account_info.js +78 -0
- package/lib/ledger/account_lines.d.ts +11 -0
- package/lib/ledger/account_lines.js +69 -0
- package/lib/ledger/account_nfts.d.ts +21 -0
- package/lib/ledger/account_nfts.js +185 -0
- package/lib/ledger/account_objects.d.ts +28 -0
- package/lib/ledger/account_objects.js +169 -0
- package/lib/ledger/account_offers.d.ts +8 -0
- package/lib/ledger/account_offers.js +67 -0
- package/lib/ledger/account_tx.d.ts +29 -0
- package/lib/ledger/account_tx.js +256 -0
- package/lib/ledger/book_offers.d.ts +11 -0
- package/lib/ledger/book_offers.js +90 -0
- package/lib/ledger/currency.d.ts +27 -0
- package/lib/ledger/currency.js +167 -0
- package/lib/ledger/fee.d.ts +5 -0
- package/lib/ledger/fee.js +45 -0
- package/lib/ledger/gateway_balances.d.ts +13 -0
- package/lib/ledger/gateway_balances.js +101 -0
- package/lib/ledger/index.d.ts +16 -0
- package/lib/ledger/index.js +32 -0
- package/lib/ledger/ledger.d.ts +11 -0
- package/lib/ledger/ledger.js +72 -0
- package/lib/ledger/manifest.d.ts +8 -0
- package/lib/ledger/manifest.js +56 -0
- package/lib/ledger/nft_info.d.ts +4 -0
- package/lib/ledger/nft_info.js +56 -0
- package/lib/ledger/server_info.d.ts +8 -0
- package/lib/ledger/server_info.js +54 -0
- package/lib/ledger/transaction.d.ts +37 -0
- package/lib/ledger/transaction.js +214 -0
- package/lib/ledger/vl.d.ts +10 -0
- package/lib/ledger/vl.js +92 -0
- package/lib/models/account_info.d.ts +122 -0
- package/lib/models/account_info.js +102 -0
- package/lib/models/account_lines.d.ts +24 -0
- package/lib/models/account_lines.js +2 -0
- package/lib/models/account_nfts.d.ts +19 -0
- package/lib/models/account_nfts.js +45 -0
- package/lib/models/account_object.d.ts +38 -0
- package/lib/models/account_object.js +61 -0
- package/lib/models/base_model.d.ts +14 -0
- package/lib/models/base_model.js +2 -0
- package/lib/models/book_offers.d.ts +9 -0
- package/lib/models/book_offers.js +41 -0
- package/lib/models/index.d.ts +23 -0
- package/lib/models/index.js +56 -0
- package/lib/models/ledger.d.ts +6 -0
- package/lib/models/ledger.js +20 -0
- package/lib/models/manifest.d.ts +26 -0
- package/lib/models/manifest.js +187 -0
- package/lib/models/transaction/affected_objects.d.ts +6 -0
- package/lib/models/transaction/affected_objects.js +104 -0
- package/lib/models/transaction/balance_changes.d.ts +7 -0
- package/lib/models/transaction/balance_changes.js +125 -0
- package/lib/models/transaction/channel_changes.d.ts +9 -0
- package/lib/models/transaction/channel_changes.js +57 -0
- package/lib/models/transaction/locked_balance_changes.d.ts +7 -0
- package/lib/models/transaction/locked_balance_changes.js +114 -0
- package/lib/models/transaction/nftoken_changes.d.ts +1 -0
- package/lib/models/transaction/nftoken_changes.js +163 -0
- package/lib/models/transaction/nftoken_offer_changes.d.ts +1 -0
- package/lib/models/transaction/nftoken_offer_changes.js +107 -0
- package/lib/models/transaction/orderbook_changes.d.ts +3 -0
- package/lib/models/transaction/orderbook_changes.js +136 -0
- package/lib/models/transaction/quality.d.ts +2 -0
- package/lib/models/transaction/quality.js +46 -0
- package/lib/models/transaction.d.ts +39 -0
- package/lib/models/transaction.js +45 -0
- package/lib/models/trustline.d.ts +15 -0
- package/lib/models/trustline.js +2 -0
- package/lib/models/utils.d.ts +3 -0
- package/lib/models/utils.js +19 -0
- package/lib/models/vl.d.ts +60 -0
- package/lib/models/vl.js +377 -0
- package/lib/parse/index.d.ts +3 -0
- package/lib/parse/index.js +32 -0
- package/lib/parse/ledger/account-order.d.ts +10 -0
- package/lib/parse/ledger/account-order.js +39 -0
- package/lib/parse/ledger/account-trustline.d.ts +3 -0
- package/lib/parse/ledger/account-trustline.js +27 -0
- package/lib/parse/ledger/amount.d.ts +3 -0
- package/lib/parse/ledger/amount.js +17 -0
- package/lib/parse/ledger/currency-amount.d.ts +3 -0
- package/lib/parse/ledger/currency-amount.js +13 -0
- package/lib/parse/ledger/fields.d.ts +2 -0
- package/lib/parse/ledger/fields.js +42 -0
- package/lib/parse/ledger/flags.d.ts +4 -0
- package/lib/parse/ledger/flags.js +18 -0
- package/lib/parse/ledger/index.d.ts +4 -0
- package/lib/parse/ledger/index.js +25 -0
- package/lib/parse/ledger/ledger.d.ts +2 -0
- package/lib/parse/ledger/ledger.js +61 -0
- package/lib/parse/ledger/memos.d.ts +3 -0
- package/lib/parse/ledger/memos.js +17 -0
- package/lib/parse/ledger/nftoken-flags.d.ts +5 -0
- package/lib/parse/ledger/nftoken-flags.js +8 -0
- package/lib/parse/ledger/nftoken-offer-flags.d.ts +5 -0
- package/lib/parse/ledger/nftoken-offer-flags.js +8 -0
- package/lib/parse/ledger/orderbook-order.d.ts +16 -0
- package/lib/parse/ledger/orderbook-order.js +39 -0
- package/lib/parse/ledger/pathfind.d.ts +4 -0
- package/lib/parse/ledger/pathfind.js +41 -0
- package/lib/parse/ledger/payment-channel.d.ts +16 -0
- package/lib/parse/ledger/payment-channel.js +27 -0
- package/lib/parse/ledger/ripple-amount.d.ts +3 -0
- package/lib/parse/ledger/ripple-amount.js +17 -0
- package/lib/parse/outcome/affected_objects.d.ts +6 -0
- package/lib/parse/outcome/affected_objects.js +109 -0
- package/lib/parse/outcome/balance_changes.d.ts +7 -0
- package/lib/parse/outcome/balance_changes.js +103 -0
- package/lib/parse/outcome/channel_changes.d.ts +9 -0
- package/lib/parse/outcome/channel_changes.js +53 -0
- package/lib/parse/outcome/index.d.ts +7 -0
- package/lib/parse/outcome/index.js +17 -0
- package/lib/parse/outcome/locked_balance_changes.d.ts +7 -0
- package/lib/parse/outcome/locked_balance_changes.js +92 -0
- package/lib/parse/outcome/nftoken_changes.d.ts +1 -0
- package/lib/parse/outcome/nftoken_changes.js +143 -0
- package/lib/parse/outcome/nftoken_offer_changes.d.ts +2 -0
- package/lib/parse/outcome/nftoken_offer_changes.js +107 -0
- package/lib/parse/outcome/orderbook_changes.d.ts +3 -0
- package/lib/parse/outcome/orderbook_changes.js +111 -0
- package/lib/parse/outcome/orderbook_quality.d.ts +2 -0
- package/lib/parse/outcome/orderbook_quality.js +45 -0
- package/lib/parse/outcome.d.ts +3 -0
- package/lib/parse/outcome.js +80 -0
- package/lib/parse/specification/account-delete.d.ts +3 -0
- package/lib/parse/specification/account-delete.js +42 -0
- package/lib/parse/specification/amendment.d.ts +3 -0
- package/lib/parse/specification/amendment.js +14 -0
- package/lib/parse/specification/check-cancel.d.ts +3 -0
- package/lib/parse/specification/check-cancel.js +39 -0
- package/lib/parse/specification/check-cash.d.ts +3 -0
- package/lib/parse/specification/check-cash.js +42 -0
- package/lib/parse/specification/check-create.d.ts +3 -0
- package/lib/parse/specification/check-create.js +45 -0
- package/lib/parse/specification/deposit-preauth.d.ts +3 -0
- package/lib/parse/specification/deposit-preauth.js +40 -0
- package/lib/parse/specification/escrow-cancel.d.ts +3 -0
- package/lib/parse/specification/escrow-cancel.js +40 -0
- package/lib/parse/specification/escrow-create.d.ts +3 -0
- package/lib/parse/specification/escrow-create.js +47 -0
- package/lib/parse/specification/escrow-finish.d.ts +3 -0
- package/lib/parse/specification/escrow-finish.js +42 -0
- package/lib/parse/specification/fee-update.d.ts +3 -0
- package/lib/parse/specification/fee-update.js +19 -0
- package/lib/parse/specification/nftoken-accept-offer.d.ts +3 -0
- package/lib/parse/specification/nftoken-accept-offer.js +41 -0
- package/lib/parse/specification/nftoken-burn.d.ts +3 -0
- package/lib/parse/specification/nftoken-burn.js +40 -0
- package/lib/parse/specification/nftoken-cancel-offer.d.ts +3 -0
- package/lib/parse/specification/nftoken-cancel-offer.js +39 -0
- package/lib/parse/specification/nftoken-create-offer.d.ts +3 -0
- package/lib/parse/specification/nftoken-create-offer.js +50 -0
- package/lib/parse/specification/nftoken-mint.d.ts +3 -0
- package/lib/parse/specification/nftoken-mint.js +44 -0
- package/lib/parse/specification/offer-cancel.d.ts +3 -0
- package/lib/parse/specification/offer-cancel.js +38 -0
- package/lib/parse/specification/offer-create.d.ts +3 -0
- package/lib/parse/specification/offer-create.js +53 -0
- package/lib/parse/specification/payment-channel-claim.d.ts +3 -0
- package/lib/parse/specification/payment-channel-claim.js +47 -0
- package/lib/parse/specification/payment-channel-create.d.ts +3 -0
- package/lib/parse/specification/payment-channel-create.js +47 -0
- package/lib/parse/specification/payment-channel-fund.d.ts +3 -0
- package/lib/parse/specification/payment-channel-fund.js +43 -0
- package/lib/parse/specification/payment-channel.d.ts +16 -0
- package/lib/parse/specification/payment-channel.js +27 -0
- package/lib/parse/specification/payment.d.ts +3 -0
- package/lib/parse/specification/payment.js +67 -0
- package/lib/parse/specification/settings.d.ts +2 -0
- package/lib/parse/specification/settings.js +80 -0
- package/lib/parse/specification/ticket-create.d.ts +3 -0
- package/lib/parse/specification/ticket-create.js +39 -0
- package/lib/parse/specification/trustline.d.ts +3 -0
- package/lib/parse/specification/trustline.js +57 -0
- package/lib/parse/transaction.d.ts +27 -0
- package/lib/parse/transaction.js +114 -0
- package/lib/parse/utils.d.ts +6 -0
- package/lib/parse/utils.js +38 -0
- package/lib/types/amounts.d.ts +16 -0
- package/lib/types/amounts.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -0
- package/lib/v1/common/constants.d.ts +16 -0
- package/lib/v1/common/constants.js +6 -0
- package/lib/v1/common/errors/index.d.ts +3 -0
- package/lib/v1/common/errors/index.js +7 -0
- package/lib/v1/common/errors/ripple_error.d.ts +9 -0
- package/lib/v1/common/errors/ripple_error.js +28 -0
- package/lib/v1/common/errors/utils.d.ts +2 -0
- package/lib/v1/common/errors/utils.js +19 -0
- package/lib/v1/common/errors/validation_error.d.ts +4 -0
- package/lib/v1/common/errors/validation_error.js +7 -0
- package/lib/v1/common/index.d.ts +3 -0
- package/lib/v1/common/index.js +31 -0
- package/lib/v1/common/txflags.d.ts +51 -0
- package/lib/v1/common/txflags.js +55 -0
- package/lib/v1/common/types/commands/account_info.d.ts +17 -0
- package/lib/v1/common/types/commands/account_info.js +2 -0
- package/lib/v1/common/types/commands/account_lines.d.ts +17 -0
- package/lib/v1/common/types/commands/account_lines.js +2 -0
- package/lib/v1/common/types/commands/account_objects.d.ts +26 -0
- package/lib/v1/common/types/commands/account_objects.js +2 -0
- package/lib/v1/common/types/commands/account_offers.d.ts +24 -0
- package/lib/v1/common/types/commands/account_offers.js +2 -0
- package/lib/v1/common/types/commands/book_offers.d.ts +23 -0
- package/lib/v1/common/types/commands/book_offers.js +2 -0
- package/lib/v1/common/types/commands/gateway_balances.d.ts +23 -0
- package/lib/v1/common/types/commands/gateway_balances.js +2 -0
- package/lib/v1/common/types/commands/index.d.ts +10 -0
- package/lib/v1/common/types/commands/index.js +26 -0
- package/lib/v1/common/types/commands/ledger.d.ts +18 -0
- package/lib/v1/common/types/commands/ledger.js +2 -0
- package/lib/v1/common/types/commands/ledger_data.d.ts +10 -0
- package/lib/v1/common/types/commands/ledger_data.js +2 -0
- package/lib/v1/common/types/commands/ledger_entry.d.ts +29 -0
- package/lib/v1/common/types/commands/ledger_entry.js +2 -0
- package/lib/v1/common/types/commands/path_find.d.ts +33 -0
- package/lib/v1/common/types/commands/path_find.js +2 -0
- package/lib/v1/common/types/commands/server_info.d.ts +49 -0
- package/lib/v1/common/types/commands/server_info.js +2 -0
- package/lib/v1/common/types/objects/account.d.ts +6 -0
- package/lib/v1/common/types/objects/account.js +2 -0
- package/lib/v1/common/types/objects/adjustments.d.ts +16 -0
- package/lib/v1/common/types/objects/adjustments.js +2 -0
- package/lib/v1/common/types/objects/amendments.d.ts +4 -0
- package/lib/v1/common/types/objects/amendments.js +2 -0
- package/lib/v1/common/types/objects/amounts.d.ts +13 -0
- package/lib/v1/common/types/objects/amounts.js +2 -0
- package/lib/v1/common/types/objects/checks.d.ts +17 -0
- package/lib/v1/common/types/objects/checks.js +2 -0
- package/lib/v1/common/types/objects/deposits.d.ts +5 -0
- package/lib/v1/common/types/objects/deposits.js +2 -0
- package/lib/v1/common/types/objects/escrows.d.ts +21 -0
- package/lib/v1/common/types/objects/escrows.js +2 -0
- package/lib/v1/common/types/objects/fees.d.ts +7 -0
- package/lib/v1/common/types/objects/fees.js +2 -0
- package/lib/v1/common/types/objects/flags.d.ts +5 -0
- package/lib/v1/common/types/objects/flags.js +8 -0
- package/lib/v1/common/types/objects/index.d.ts +15 -0
- package/lib/v1/common/types/objects/index.js +31 -0
- package/lib/v1/common/types/objects/ledger.d.ts +45 -0
- package/lib/v1/common/types/objects/ledger.js +2 -0
- package/lib/v1/common/types/objects/ledger_data.d.ts +10 -0
- package/lib/v1/common/types/objects/ledger_data.js +2 -0
- package/lib/v1/common/types/objects/ledger_entries.d.ts +158 -0
- package/lib/v1/common/types/objects/ledger_entries.js +2 -0
- package/lib/v1/common/types/objects/memos.d.ts +12 -0
- package/lib/v1/common/types/objects/memos.js +2 -0
- package/lib/v1/common/types/objects/nftokens.d.ts +47 -0
- package/lib/v1/common/types/objects/nftokens.js +13 -0
- package/lib/v1/common/types/objects/offers.d.ts +15 -0
- package/lib/v1/common/types/objects/offers.js +2 -0
- package/lib/v1/common/types/objects/orders.d.ts +13 -0
- package/lib/v1/common/types/objects/orders.js +2 -0
- package/lib/v1/common/types/objects/path_find.d.ts +27 -0
- package/lib/v1/common/types/objects/path_find.js +2 -0
- package/lib/v1/common/types/objects/payment_channels.d.ts +25 -0
- package/lib/v1/common/types/objects/payment_channels.js +2 -0
- package/lib/v1/common/types/objects/payments.d.ts +20 -0
- package/lib/v1/common/types/objects/payments.js +2 -0
- package/lib/v1/common/types/objects/queue_data.d.ts +15 -0
- package/lib/v1/common/types/objects/queue_data.js +2 -0
- package/lib/v1/common/types/objects/settings.d.ts +34 -0
- package/lib/v1/common/types/objects/settings.js +2 -0
- package/lib/v1/common/types/objects/signers.d.ts +6 -0
- package/lib/v1/common/types/objects/signers.js +2 -0
- package/lib/v1/common/types/objects/specification.d.ts +4 -0
- package/lib/v1/common/types/objects/specification.js +2 -0
- package/lib/v1/common/types/objects/tickets.d.ts +4 -0
- package/lib/v1/common/types/objects/tickets.js +2 -0
- package/lib/v1/common/types/objects/transactions.d.ts +21 -0
- package/lib/v1/common/types/objects/transactions.js +2 -0
- package/lib/v1/common/types/objects/trustlines.d.ts +38 -0
- package/lib/v1/common/types/objects/trustlines.js +2 -0
- package/lib/v1/common/types/pathfind-types.d.ts +59 -0
- package/lib/v1/common/types/pathfind-types.js +2 -0
- package/lib/v1/common/utils.d.ts +6 -0
- package/lib/v1/common/utils.js +58 -0
- package/lib/v1/index.d.ts +2 -0
- package/lib/v1/index.js +28 -0
- package/lib/v1/ledger/index.d.ts +1 -0
- package/lib/v1/ledger/index.js +27 -0
- package/lib/v1/ledger/parse/account-delete.d.ts +7 -0
- package/lib/v1/ledger/parse/account-delete.js +42 -0
- package/lib/v1/ledger/parse/account-order.d.ts +10 -0
- package/lib/v1/ledger/parse/account-order.js +39 -0
- package/lib/v1/ledger/parse/account-trustline.d.ts +3 -0
- package/lib/v1/ledger/parse/account-trustline.js +27 -0
- package/lib/v1/ledger/parse/amendment.d.ts +5 -0
- package/lib/v1/ledger/parse/amendment.js +14 -0
- package/lib/v1/ledger/parse/amount.d.ts +3 -0
- package/lib/v1/ledger/parse/amount.js +40 -0
- package/lib/v1/ledger/parse/cancellation.d.ts +2 -0
- package/lib/v1/ledger/parse/cancellation.js +38 -0
- package/lib/v1/ledger/parse/check-cancel.d.ts +5 -0
- package/lib/v1/ledger/parse/check-cancel.js +39 -0
- package/lib/v1/ledger/parse/check-cash.d.ts +8 -0
- package/lib/v1/ledger/parse/check-cash.js +42 -0
- package/lib/v1/ledger/parse/check-create.d.ts +10 -0
- package/lib/v1/ledger/parse/check-create.js +45 -0
- package/lib/v1/ledger/parse/currency-amount.d.ts +3 -0
- package/lib/v1/ledger/parse/currency-amount.js +13 -0
- package/lib/v1/ledger/parse/deposit-preauth.d.ts +6 -0
- package/lib/v1/ledger/parse/deposit-preauth.js +40 -0
- package/lib/v1/ledger/parse/escrow-cancellation.d.ts +2 -0
- package/lib/v1/ledger/parse/escrow-cancellation.js +40 -0
- package/lib/v1/ledger/parse/escrow-creation.d.ts +2 -0
- package/lib/v1/ledger/parse/escrow-creation.js +47 -0
- package/lib/v1/ledger/parse/escrow-execution.d.ts +2 -0
- package/lib/v1/ledger/parse/escrow-execution.js +42 -0
- package/lib/v1/ledger/parse/fee-update.d.ts +8 -0
- package/lib/v1/ledger/parse/fee-update.js +19 -0
- package/lib/v1/ledger/parse/fields.d.ts +2 -0
- package/lib/v1/ledger/parse/fields.js +42 -0
- package/lib/v1/ledger/parse/flags.d.ts +15 -0
- package/lib/v1/ledger/parse/flags.js +19 -0
- package/lib/v1/ledger/parse/index.d.ts +4 -0
- package/lib/v1/ledger/parse/index.js +25 -0
- package/lib/v1/ledger/parse/ledger.d.ts +18 -0
- package/lib/v1/ledger/parse/ledger.js +77 -0
- package/lib/v1/ledger/parse/memos.d.ts +3 -0
- package/lib/v1/ledger/parse/memos.js +17 -0
- package/lib/v1/ledger/parse/order.d.ts +3 -0
- package/lib/v1/ledger/parse/order.js +53 -0
- package/lib/v1/ledger/parse/orderbook-order.d.ts +16 -0
- package/lib/v1/ledger/parse/orderbook-order.js +66 -0
- package/lib/v1/ledger/parse/pathfind.d.ts +3 -0
- package/lib/v1/ledger/parse/pathfind.js +66 -0
- package/lib/v1/ledger/parse/payment-channel-claim.d.ts +2 -0
- package/lib/v1/ledger/parse/payment-channel-claim.js +47 -0
- package/lib/v1/ledger/parse/payment-channel-create.d.ts +2 -0
- package/lib/v1/ledger/parse/payment-channel-create.js +47 -0
- package/lib/v1/ledger/parse/payment-channel-fund.d.ts +2 -0
- package/lib/v1/ledger/parse/payment-channel-fund.js +43 -0
- package/lib/v1/ledger/parse/payment-channel.d.ts +16 -0
- package/lib/v1/ledger/parse/payment-channel.js +27 -0
- package/lib/v1/ledger/parse/payment.d.ts +2 -0
- package/lib/v1/ledger/parse/payment.js +69 -0
- package/lib/v1/ledger/parse/ripple-amount.d.ts +3 -0
- package/lib/v1/ledger/parse/ripple-amount.js +40 -0
- package/lib/v1/ledger/parse/settings.d.ts +2 -0
- package/lib/v1/ledger/parse/settings.js +82 -0
- package/lib/v1/ledger/parse/ticket-create.d.ts +2 -0
- package/lib/v1/ledger/parse/ticket-create.js +39 -0
- package/lib/v1/ledger/parse/transaction.d.ts +3 -0
- package/lib/v1/ledger/parse/transaction.js +110 -0
- package/lib/v1/ledger/parse/trustline.d.ts +2 -0
- package/lib/v1/ledger/parse/trustline.js +57 -0
- package/lib/v1/ledger/parse/utils.d.ts +6 -0
- package/lib/v1/ledger/parse/utils.js +63 -0
- package/lib/v1/ledger/parse_outcome.d.ts +2 -0
- package/lib/v1/ledger/parse_outcome.js +80 -0
- package/lib/v1/ledger/pathfind-types.d.ts +59 -0
- package/lib/v1/ledger/pathfind-types.js +2 -0
- package/lib/v1/transaction/payment.d.ts +14 -0
- package/lib/v1/transaction/payment.js +130 -0
- package/lib/v1/transaction/types.d.ts +40 -0
- package/lib/v1/transaction/types.js +2 -0
- package/lib/v1/transaction/utils.d.ts +8 -0
- package/lib/v1/transaction/utils.js +38 -0
- package/lib/validator.d.ts +12 -0
- package/lib/validator.js +134 -0
- package/lib/wallet.d.ts +17 -0
- package/lib/wallet.js +140 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @Bithomp/xrpl-api
|
|
2
|
+
|
|
3
|
+
A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger
|
|
4
|
+
Library designed to be a single point of access to the XRP Ledger. It uses multiple connections to the XRP Ledger and selects the best one for the request. If the connection is lost, the library will automatically reconnect.
|
|
5
|
+
|
|
6
|
+
The library also supports the creation of a validator list.
|
|
7
|
+
|
|
8
|
+
In an existing project (with `package.json`), install `@bithomp/xrpl-api`:
|
|
9
|
+
|
|
10
|
+
```Shell
|
|
11
|
+
# install package
|
|
12
|
+
$ npm install --save @bithomp/xrpl-api
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Example of use
|
|
16
|
+
|
|
17
|
+
## Account info
|
|
18
|
+
|
|
19
|
+
```JS
|
|
20
|
+
const BithompXRPL = require("@bithomp/xrpl-api");
|
|
21
|
+
|
|
22
|
+
// setup connection
|
|
23
|
+
const config = [
|
|
24
|
+
{
|
|
25
|
+
"url": "wss://xrplcluster.com",
|
|
26
|
+
"type": "regular,history,gateway_balances,last_close,manifest",
|
|
27
|
+
"connectionTimeout": 10000
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"url": "wss://s2.ripple.com",
|
|
31
|
+
"type": "regular,history",
|
|
32
|
+
"connectionTimeout": 10000
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"url": "wss://s2-clio.ripple.com",
|
|
36
|
+
"type": "clio,account_objects",
|
|
37
|
+
"connectionTimeout": 10000
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// Global setup for all connections, if you have multiple connections, like in example, the library will use them by type and(or) by better response time
|
|
42
|
+
BithompXRPL.Client.setup(config);
|
|
43
|
+
|
|
44
|
+
// connect to all servers
|
|
45
|
+
await BithompXRPL.Client.connect();
|
|
46
|
+
|
|
47
|
+
// send request
|
|
48
|
+
const accountInfo = await BithompXRPL.Client.getAccountInfo("rsuUjfWxrACCAwGQDsNeZUhpzXf1n1NK5Z");
|
|
49
|
+
|
|
50
|
+
// when complete, disconnect
|
|
51
|
+
BithompXRPL.Client.disconnect();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Create Validator List
|
|
55
|
+
|
|
56
|
+
_Setup connection_, it is required to get validators details from the ledger.
|
|
57
|
+
|
|
58
|
+
```JS
|
|
59
|
+
const BithompXRPL = require("@bithomp/xrpl-api");
|
|
60
|
+
// setup connection
|
|
61
|
+
const config = [
|
|
62
|
+
{
|
|
63
|
+
"url": "wss://xrplcluster.com",
|
|
64
|
+
"connectionTimeout": 10000
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
BithompXRPL.Client.setup(config);
|
|
68
|
+
|
|
69
|
+
// connect
|
|
70
|
+
await BithompXRPL.Client.connect();
|
|
71
|
+
|
|
72
|
+
// validator secrets
|
|
73
|
+
const vk = {
|
|
74
|
+
privateKey: "p__________________________",
|
|
75
|
+
publicKey: "ED________________________________",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// signing secrets
|
|
79
|
+
const sk = {
|
|
80
|
+
privateKey: "p__________________________",
|
|
81
|
+
publicKey: "03_______________________________",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// validator list, public addresses, they have to be avalable on the ledger for accessing to manifest
|
|
85
|
+
const validators = ["nHBidG3pZK11zQD6kpNDoAhDxH6WLGui6ZxSbUx7LSqLHsgzMPec"];
|
|
86
|
+
const sequence = 1; // sequence number
|
|
87
|
+
const expiration = 1696508603; // in unixtime (seconds)
|
|
88
|
+
const vl = await BithompXRPL.Client.createVL(vk, sk, sequence, expiration, validators);
|
|
89
|
+
|
|
90
|
+
// vl will contain the signed validator list with
|
|
91
|
+
// {
|
|
92
|
+
// "blob": "...",
|
|
93
|
+
// "manifest": "...", // signed with vk.privateKey and sk.privateKey
|
|
94
|
+
// "signature": "...", // signed with sk.privateKey
|
|
95
|
+
// "version": 1,
|
|
96
|
+
// "public_key": "..." // vk.publicKey
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// disconnect
|
|
100
|
+
BithompXRPL.Client.disconnect();
|
|
101
|
+
```
|
package/lib/base58.d.ts
ADDED
package/lib/base58.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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.encode = exports.decode = void 0;
|
|
7
|
+
const R_B58_DICT = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz";
|
|
8
|
+
const base_x_1 = __importDefault(require("base-x"));
|
|
9
|
+
const base58 = (0, base_x_1.default)(R_B58_DICT);
|
|
10
|
+
function decode(value) {
|
|
11
|
+
if (!value) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return Buffer.from(base58.decode(value));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
exports.decode = decode;
|
|
22
|
+
function encode(buffer) {
|
|
23
|
+
if (!buffer) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return base58.encode(buffer);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
exports.encode = encode;
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Connection, ConnectionOptions } from "./connection";
|
|
2
|
+
export * from "./ledger";
|
|
3
|
+
export declare let feeCushion: number;
|
|
4
|
+
export declare let logger: any;
|
|
5
|
+
export interface ClientOptions extends ConnectionOptions {
|
|
6
|
+
feeCushion?: number;
|
|
7
|
+
maxFeeXRP?: string;
|
|
8
|
+
logger?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface ClientConnection {
|
|
11
|
+
url: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
connectionTimeout?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function setup(servers: ClientConnection[], options?: ClientOptions): void;
|
|
17
|
+
export declare function connect(): Promise<void>;
|
|
18
|
+
export declare function disconnect(): void;
|
|
19
|
+
export declare function findConnection(type?: string, url?: string, strongFilter?: boolean, hash?: string): Connection | null;
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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.findConnection = exports.disconnect = exports.connect = exports.setup = exports.logger = exports.feeCushion = void 0;
|
|
18
|
+
const connection_1 = require("./connection");
|
|
19
|
+
__exportStar(require("./ledger"), exports);
|
|
20
|
+
exports.feeCushion = 1.3;
|
|
21
|
+
let clientConnections = [];
|
|
22
|
+
function setup(servers, options = {}) {
|
|
23
|
+
exports.logger = options.logger;
|
|
24
|
+
exports.logger?.debug({
|
|
25
|
+
service: "Bithomp::XRPL::Client",
|
|
26
|
+
function: "setup",
|
|
27
|
+
});
|
|
28
|
+
if (servers) {
|
|
29
|
+
disconnect();
|
|
30
|
+
clientConnections = [];
|
|
31
|
+
for (const server of servers) {
|
|
32
|
+
clientConnections.push(new connection_1.Connection(server.url, server.type, {
|
|
33
|
+
logger: options.logger,
|
|
34
|
+
timeout: server.timeout,
|
|
35
|
+
connectionTimeout: server.connectionTimeout,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (options.feeCushion) {
|
|
40
|
+
exports.feeCushion = options.feeCushion;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.setup = setup;
|
|
44
|
+
async function connect() {
|
|
45
|
+
exports.logger?.debug({
|
|
46
|
+
service: "Bithomp::XRPL::Client",
|
|
47
|
+
function: "connect",
|
|
48
|
+
});
|
|
49
|
+
for (const connection of clientConnections) {
|
|
50
|
+
await connection.connect();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.connect = connect;
|
|
54
|
+
function disconnect() {
|
|
55
|
+
exports.logger?.debug({
|
|
56
|
+
service: "Bithomp::XRPL::Client",
|
|
57
|
+
function: "disconnect",
|
|
58
|
+
});
|
|
59
|
+
for (const connection of clientConnections) {
|
|
60
|
+
connection.disconnect();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.disconnect = disconnect;
|
|
64
|
+
function findConnection(type, url, strongFilter, hash) {
|
|
65
|
+
if (!strongFilter) {
|
|
66
|
+
if (clientConnections.length === 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
else if (clientConnections.length === 1) {
|
|
70
|
+
return clientConnections[0];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let connections = clientConnections.filter((con) => {
|
|
74
|
+
if (!con.isConnected()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (typeof url === "string" && con.url !== url) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (typeof hash === "string" && con.hash !== hash) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (typeof type !== "string") {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (con.types.length === 0) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const foundTypes = type.split(",").map((t) => {
|
|
90
|
+
t = t.trim();
|
|
91
|
+
if (t[0] === "!") {
|
|
92
|
+
return !con.types.includes(t.slice(1));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return con.types.includes(t);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
for (const found of foundTypes) {
|
|
99
|
+
if (!found) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
if (!strongFilter) {
|
|
106
|
+
if (connections.length === 0) {
|
|
107
|
+
connections = [...clientConnections];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
connections = connections.sort(sortHelperConnections);
|
|
111
|
+
return connections[0];
|
|
112
|
+
}
|
|
113
|
+
exports.findConnection = findConnection;
|
|
114
|
+
function sortHelperConnections(a, b) {
|
|
115
|
+
if (a.getLatencyMs() < b.getLatencyMs()) {
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
if (a.getLatencyMs() > b.getLatencyMs()) {
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = exports.RippleError = void 0;
|
|
4
|
+
const ripple_error_1 = require("./ripple_error");
|
|
5
|
+
Object.defineProperty(exports, "RippleError", { enumerable: true, get: function () { return ripple_error_1.RippleError; } });
|
|
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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RippleError = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
class RippleError 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.RippleError = RippleError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConstructorName = void 0;
|
|
4
|
+
function getConstructorName(object) {
|
|
5
|
+
if (object.constructor.name) {
|
|
6
|
+
return object.constructor.name;
|
|
7
|
+
}
|
|
8
|
+
const constructorString = object.constructor.toString();
|
|
9
|
+
const functionConstructor = constructorString.match(/^function\s+([^(]*)/);
|
|
10
|
+
const classConstructor = constructorString.match(/^class\s([^\s]*)/);
|
|
11
|
+
if (functionConstructor) {
|
|
12
|
+
return functionConstructor[1];
|
|
13
|
+
}
|
|
14
|
+
else if (classConstructor) {
|
|
15
|
+
return classConstructor[1];
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
exports.getConstructorName = getConstructorName;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
const ripple_error_1 = require("./ripple_error");
|
|
5
|
+
class ValidationError extends ripple_error_1.RippleError {
|
|
6
|
+
}
|
|
7
|
+
exports.ValidationError = ValidationError;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.BLACKHOLE_ACCOUNTS = exports.dropsInXRP = exports.sha512Half = exports.errors = void 0;
|
|
33
|
+
const errors = __importStar(require("./errors"));
|
|
34
|
+
exports.errors = errors;
|
|
35
|
+
const sha512Half_1 = __importDefault(require("./sha512Half"));
|
|
36
|
+
exports.sha512Half = sha512Half_1.default;
|
|
37
|
+
__exportStar(require("./utils"), exports);
|
|
38
|
+
exports.dropsInXRP = 1000000;
|
|
39
|
+
exports.BLACKHOLE_ACCOUNTS = [
|
|
40
|
+
"rrrrrrrrrrrrrrrrrrrrrhoLvTp",
|
|
41
|
+
"rrrrrrrrrrrrrrrrrrrrBZbvji",
|
|
42
|
+
"rrrrrrrrrrrrrrrrrNAMEtxvNvQ",
|
|
43
|
+
"rrrrrrrrrrrrrrrrrrrn5RM1rHd",
|
|
44
|
+
];
|
|
@@ -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,10 @@
|
|
|
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 createMarker(hash: string, marker?: any): any;
|
|
7
|
+
export declare function parseMarker(marker?: any): any;
|
|
8
|
+
export declare function dropsToXrp(drops: BigNumber.Value): string;
|
|
9
|
+
export declare function xrpToDrops(xrp: BigNumber.Value): string;
|
|
10
|
+
export declare function removeUndefined<T extends object>(obj: T): T;
|
|
@@ -0,0 +1,113 @@
|
|
|
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.removeUndefined = exports.xrpToDrops = exports.dropsToXrp = exports.parseMarker = exports.createMarker = exports.sleep = exports.compareTransactions = exports.signum = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
function signum(num) {
|
|
11
|
+
return num === 0 ? 0 : num > 0 ? 1 : -1;
|
|
12
|
+
}
|
|
13
|
+
exports.signum = signum;
|
|
14
|
+
function compareTransactions(first, second) {
|
|
15
|
+
if (!first.tx || !first.meta || !second.tx || !second.meta) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
if (first.tx.ledger_index === second.tx.ledger_index) {
|
|
19
|
+
return signum(first.meta.TransactionIndex - second.meta.TransactionIndex);
|
|
20
|
+
}
|
|
21
|
+
return first.tx.ledger_index < second.tx.ledger_index ? -1 : 1;
|
|
22
|
+
}
|
|
23
|
+
exports.compareTransactions = compareTransactions;
|
|
24
|
+
async function sleep(ms) {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
setTimeout(resolve, ms);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.sleep = sleep;
|
|
30
|
+
function createMarker(hash, marker) {
|
|
31
|
+
if (marker === undefined) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
if (marker === null) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (typeof marker === "string") {
|
|
38
|
+
return `${hash},${marker}`;
|
|
39
|
+
}
|
|
40
|
+
if (typeof marker === "object") {
|
|
41
|
+
marker.bithompHash = hash;
|
|
42
|
+
}
|
|
43
|
+
return marker;
|
|
44
|
+
}
|
|
45
|
+
exports.createMarker = createMarker;
|
|
46
|
+
function parseMarker(marker) {
|
|
47
|
+
let hash;
|
|
48
|
+
if (typeof marker === "object" && marker.bithompHash) {
|
|
49
|
+
hash = marker.bithompHash;
|
|
50
|
+
delete marker.bithompHash;
|
|
51
|
+
return { hash, marker };
|
|
52
|
+
}
|
|
53
|
+
if (typeof marker !== "string") {
|
|
54
|
+
return { hash, marker };
|
|
55
|
+
}
|
|
56
|
+
if (marker) {
|
|
57
|
+
const markerParams = marker.split(",");
|
|
58
|
+
if (markerParams.length > 1) {
|
|
59
|
+
hash = markerParams[0];
|
|
60
|
+
markerParams.shift();
|
|
61
|
+
marker = markerParams.join(",");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { hash, marker };
|
|
65
|
+
}
|
|
66
|
+
exports.parseMarker = parseMarker;
|
|
67
|
+
function dropsToXrp(drops) {
|
|
68
|
+
if (typeof drops === "string") {
|
|
69
|
+
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
70
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}',` + ` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
71
|
+
}
|
|
72
|
+
else if (drops === ".") {
|
|
73
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}',` + ` should be a BigNumber or string-encoded number.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
drops = new bignumber_js_1.default(drops).toString(10);
|
|
77
|
+
if (drops.includes(".")) {
|
|
78
|
+
throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has` + ` too many decimal places.`);
|
|
79
|
+
}
|
|
80
|
+
if (!drops.match(/^-?[0-9]+$/)) {
|
|
81
|
+
throw new errors_1.ValidationError(`dropsToXrp: failed sanity check -` + ` value '${drops}',` + ` does not match (^-?[0-9]+$).`);
|
|
82
|
+
}
|
|
83
|
+
return new bignumber_js_1.default(drops).dividedBy(1000000.0).toString(10);
|
|
84
|
+
}
|
|
85
|
+
exports.dropsToXrp = dropsToXrp;
|
|
86
|
+
function xrpToDrops(xrp) {
|
|
87
|
+
if (typeof xrp === "string") {
|
|
88
|
+
if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
89
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}',` + ` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
90
|
+
}
|
|
91
|
+
else if (xrp === ".") {
|
|
92
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}',` + ` should be a BigNumber or string-encoded number.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
xrp = new bignumber_js_1.default(xrp).toString(10);
|
|
96
|
+
if (!xrp.match(/^-?[0-9.]+$/)) {
|
|
97
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check -` + ` value '${xrp}',` + ` does not match (^-?[0-9.]+$).`);
|
|
98
|
+
}
|
|
99
|
+
const components = xrp.split(".");
|
|
100
|
+
if (components.length > 2) {
|
|
101
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check -` + ` value '${xrp}' has` + ` too many decimal points.`);
|
|
102
|
+
}
|
|
103
|
+
const fraction = components[1] || "0";
|
|
104
|
+
if (fraction.length > 6) {
|
|
105
|
+
throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has` + ` too many decimal places.`);
|
|
106
|
+
}
|
|
107
|
+
return new bignumber_js_1.default(xrp).times(1000000.0).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
|
|
108
|
+
}
|
|
109
|
+
exports.xrpToDrops = xrpToDrops;
|
|
110
|
+
function removeUndefined(obj) {
|
|
111
|
+
return lodash_1.default.omitBy(obj, (value) => value == null);
|
|
112
|
+
}
|
|
113
|
+
exports.removeUndefined = removeUndefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import { Request, Response } from "xrpl";
|
|
4
|
+
export interface ConnectionOptions {
|
|
5
|
+
logger?: any;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
connectionTimeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface LatencyInfo {
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
delta: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ConnectionStreamsInfo {
|
|
14
|
+
ledger: number;
|
|
15
|
+
consensus?: number;
|
|
16
|
+
manifests?: number;
|
|
17
|
+
peer_status?: number;
|
|
18
|
+
transactions?: number;
|
|
19
|
+
transactions_proposed?: number;
|
|
20
|
+
server?: number;
|
|
21
|
+
validations?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ConnectionAccountsInfo {
|
|
24
|
+
[key: string]: number;
|
|
25
|
+
}
|
|
26
|
+
declare class Connection extends EventEmitter {
|
|
27
|
+
private client?;
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly type?: string;
|
|
30
|
+
readonly types: string[];
|
|
31
|
+
latency: LatencyInfo[];
|
|
32
|
+
readonly logger?: any;
|
|
33
|
+
readonly timeout?: number;
|
|
34
|
+
readonly connectionTimeout?: number;
|
|
35
|
+
readonly hash?: string;
|
|
36
|
+
private shutdown;
|
|
37
|
+
private connectionTimer;
|
|
38
|
+
streams: ConnectionStreamsInfo;
|
|
39
|
+
accounts: ConnectionAccountsInfo;
|
|
40
|
+
private streamsSubscribed;
|
|
41
|
+
constructor(url: string, type?: string, options?: ConnectionOptions);
|
|
42
|
+
connect(): Promise<void>;
|
|
43
|
+
disconnect(): Promise<void>;
|
|
44
|
+
request(request: Request, options?: any): Promise<Response | any>;
|
|
45
|
+
submit(transaction: string): Promise<Response | any>;
|
|
46
|
+
isConnected(): boolean;
|
|
47
|
+
getLatencyMs(): number;
|
|
48
|
+
private updateLatency;
|
|
49
|
+
private reconnect;
|
|
50
|
+
private setupEmitter;
|
|
51
|
+
private updateSubscriptions;
|
|
52
|
+
private subscribe;
|
|
53
|
+
private unsubscribe;
|
|
54
|
+
private connectionValidation;
|
|
55
|
+
private connectionValidationTimeout;
|
|
56
|
+
}
|
|
57
|
+
export { Connection };
|