@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
|
@@ -0,0 +1,256 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.findTransactions = exports.getTransactions = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const xrpl_1 = require("xrpl");
|
|
32
|
+
const Client = __importStar(require("../client"));
|
|
33
|
+
const utils_1 = require("../common/utils");
|
|
34
|
+
const transaction_1 = require("../models/transaction");
|
|
35
|
+
const MAX_LIMIT = 1000;
|
|
36
|
+
const DEFAULT_LIMIT = 200;
|
|
37
|
+
const MAX_LIMIT_WITH_FILTER = 20;
|
|
38
|
+
const MAX_LIMIT_WITH_TAG = 3;
|
|
39
|
+
const LIMIT_INCREASE_COUNT = 10;
|
|
40
|
+
async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
|
|
41
|
+
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
42
|
+
options.marker = marker;
|
|
43
|
+
const connection = Client.findConnection("history", undefined, undefined, hash);
|
|
44
|
+
if (!connection) {
|
|
45
|
+
throw new Error("There is no connection");
|
|
46
|
+
}
|
|
47
|
+
const response = await connection.request({
|
|
48
|
+
command: "account_tx",
|
|
49
|
+
account,
|
|
50
|
+
ledger_index_min: options.ledgerIndexMin,
|
|
51
|
+
ledger_index_max: options.ledgerIndexMax,
|
|
52
|
+
ledger_hash: options.ledgerHash,
|
|
53
|
+
ledger_index: options.ledgerIndex,
|
|
54
|
+
binary: !!options.binary,
|
|
55
|
+
forward: !!options.forward,
|
|
56
|
+
limit: options.limit,
|
|
57
|
+
marker: options.marker,
|
|
58
|
+
});
|
|
59
|
+
if (!response) {
|
|
60
|
+
return {
|
|
61
|
+
account,
|
|
62
|
+
status: "error",
|
|
63
|
+
error: "invalidResponse",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (response.error) {
|
|
67
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
68
|
+
return {
|
|
69
|
+
account,
|
|
70
|
+
error,
|
|
71
|
+
error_code,
|
|
72
|
+
error_message,
|
|
73
|
+
status,
|
|
74
|
+
validated,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const result = response?.result;
|
|
78
|
+
if (Array.isArray(result.transactions)) {
|
|
79
|
+
if (options.balanceChanges === true || options.specification === true) {
|
|
80
|
+
for (const transaction of result.transactions) {
|
|
81
|
+
if (options.balanceChanges === true) {
|
|
82
|
+
transaction.balanceChanges = (0, xrpl_1.getBalanceChanges)(transaction.meta);
|
|
83
|
+
}
|
|
84
|
+
if (options.specification === true) {
|
|
85
|
+
const details = (0, transaction_1.getAccountTxDetails)(transaction, true);
|
|
86
|
+
transaction.specification = details.specification;
|
|
87
|
+
transaction.outcome = details.outcome;
|
|
88
|
+
transaction.rawTransaction = details.rawTransaction;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
94
|
+
if (newMarker) {
|
|
95
|
+
result.marker = newMarker;
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
exports.getTransactions = getTransactions;
|
|
100
|
+
async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
|
|
101
|
+
let transactions = [];
|
|
102
|
+
let accountTransactionsError = null;
|
|
103
|
+
const formatted = options.legacy === true || options.formatted === true;
|
|
104
|
+
const timeStart = new Date();
|
|
105
|
+
options.binary = false;
|
|
106
|
+
applyLimitOptions(options);
|
|
107
|
+
await applyStartTxOptions(options);
|
|
108
|
+
while (transactions.length !== options.limit) {
|
|
109
|
+
const currentTime = new Date();
|
|
110
|
+
if (options.timeout && currentTime.getTime() - timeStart.getTime() > options.timeout) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
let limit = options.limit;
|
|
114
|
+
if (transactions.length === 0 && options.startTxHash) {
|
|
115
|
+
limit += LIMIT_INCREASE_COUNT;
|
|
116
|
+
}
|
|
117
|
+
if (options.sourceTag || options.destinationTag) {
|
|
118
|
+
limit += LIMIT_INCREASE_COUNT;
|
|
119
|
+
}
|
|
120
|
+
if (limit > MAX_LIMIT) {
|
|
121
|
+
limit = MAX_LIMIT;
|
|
122
|
+
}
|
|
123
|
+
const accountTransactions = await getTransactions(account, {
|
|
124
|
+
...options,
|
|
125
|
+
...{ balanceChanges: false, specification: false, limit },
|
|
126
|
+
});
|
|
127
|
+
if (!accountTransactions || accountTransactions.error) {
|
|
128
|
+
accountTransactionsError = accountTransactions;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
let newTransactions = accountTransactions.transactions;
|
|
132
|
+
options.marker = accountTransactions.marker;
|
|
133
|
+
newTransactions = newTransactions
|
|
134
|
+
.filter(lodash_1.default.partial(filterHelperTransactions, account, options))
|
|
135
|
+
.filter(lodash_1.default.partial(filterHelperStartTx, options));
|
|
136
|
+
if (formatted !== true && (options.balanceChanges === true || options.specification === true)) {
|
|
137
|
+
for (const newTransaction of newTransactions) {
|
|
138
|
+
if (options.balanceChanges === true) {
|
|
139
|
+
newTransaction.balanceChanges = (0, xrpl_1.getBalanceChanges)(newTransaction.meta);
|
|
140
|
+
}
|
|
141
|
+
if (options.specification === true) {
|
|
142
|
+
const details = (0, transaction_1.getAccountTxDetails)(newTransaction, true);
|
|
143
|
+
newTransaction.specification = details.specification;
|
|
144
|
+
newTransaction.outcome = details.outcome;
|
|
145
|
+
newTransaction.rawTransaction = details.rawTransaction;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
transactions = transactions.concat(newTransactions);
|
|
150
|
+
transactions = transactions.slice(0, options.limit);
|
|
151
|
+
if (options.marker === undefined) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (accountTransactionsError) {
|
|
156
|
+
return accountTransactionsError;
|
|
157
|
+
}
|
|
158
|
+
if (options.marker && transactions.length === 0) {
|
|
159
|
+
return {
|
|
160
|
+
status: "timeout",
|
|
161
|
+
error: "searchTimeout",
|
|
162
|
+
marker: options.marker,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (formatted === true) {
|
|
166
|
+
transactions = transactions.map((transaction) => (0, transaction_1.getAccountTxDetails)(transaction, options.includeRawTransactions === true));
|
|
167
|
+
}
|
|
168
|
+
return transactions;
|
|
169
|
+
}
|
|
170
|
+
exports.findTransactions = findTransactions;
|
|
171
|
+
function applyLimitOptions(options) {
|
|
172
|
+
if (options.sourceTag > 0 || options.destinationTag > 0) {
|
|
173
|
+
if (options.limit > MAX_LIMIT_WITH_TAG) {
|
|
174
|
+
options.limit = MAX_LIMIT_WITH_TAG;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (options.types || options.initiated || options.counterparty) {
|
|
178
|
+
if (options.limit > MAX_LIMIT_WITH_FILTER) {
|
|
179
|
+
options.limit = MAX_LIMIT_WITH_FILTER;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function applyStartTxOptions(options) {
|
|
184
|
+
if (options.startTxHash) {
|
|
185
|
+
const accountTransaction = await Client.getTransaction(options.startTxHash);
|
|
186
|
+
if (accountTransaction && !accountTransaction.error) {
|
|
187
|
+
options.startTx = {
|
|
188
|
+
tx: accountTransaction,
|
|
189
|
+
meta: accountTransaction.meta,
|
|
190
|
+
};
|
|
191
|
+
if (options.forward === true) {
|
|
192
|
+
options.ledgerIndexMin = options.startTx.tx.ledger_index;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
options.ledgerIndexMax = options.startTx.tx.ledger_index;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function filterHelperStartTx(options, transaction) {
|
|
201
|
+
return (!options.startTx ||
|
|
202
|
+
(options.forward === true
|
|
203
|
+
? (0, utils_1.compareTransactions)(transaction, options.startTx) > 0
|
|
204
|
+
: (0, utils_1.compareTransactions)(transaction, options.startTx) < 0));
|
|
205
|
+
}
|
|
206
|
+
function filterHelperTransactions(account, options, transaction) {
|
|
207
|
+
if (transaction.validated === false) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (options.excludeFailures === true && transaction.meta.TransactionResult !== "tesSUCCESS") {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (options.types && !options.types.includes(transaction.tx.TransactionType)) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (options.initiated === true && transaction.tx.Account !== account) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (options.initiated === false && transaction.tx.Account === account) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (options.counterparty && !counterpartyFilter(options, transaction)) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (typeof options.sourceTag === "number" && transaction.tx.SourceTag !== options.sourceTag) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (typeof options.destinationTag === "number" && transaction.tx.DestinationTag !== options.destinationTag) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
function counterpartyFilter(options, transaction) {
|
|
234
|
+
if (transaction.tx.Account === options.counterparty) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
if (transaction.tx.Destination === options.counterparty) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
if (transaction.tx.Amount?.issuer === options.counterparty) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
if (transaction.tx.SendMax?.issuer === options.counterparty) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (transaction.tx.LimitAmount?.issuer === options.counterparty) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
if (transaction.tx.Issuer === options.counterparty) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
if (transaction.tx.NFTokenMinter === options.counterparty) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LedgerIndex } from "../models/ledger";
|
|
2
|
+
import { OrderbookInfo } from "../models/book_offers";
|
|
3
|
+
import { IssuedCurrency } from "../types";
|
|
4
|
+
import { ErrorResponse } from "../models/base_model";
|
|
5
|
+
export interface GetGetBookOffers {
|
|
6
|
+
ledgerIndex?: LedgerIndex;
|
|
7
|
+
limit?: number;
|
|
8
|
+
marker?: any;
|
|
9
|
+
}
|
|
10
|
+
export declare function getBookOffers(taker: string, takerGets: IssuedCurrency, takerPays: IssuedCurrency, options?: GetGetBookOffers): Promise<object | ErrorResponse>;
|
|
11
|
+
export declare function getOrderbook(taker: string, orderbook: OrderbookInfo, options?: GetGetBookOffers): Promise<object | ErrorResponse>;
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getOrderbook = exports.getBookOffers = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
const book_offers_1 = require("../models/book_offers");
|
|
29
|
+
const utils_1 = require("../common/utils");
|
|
30
|
+
async function getBookOffers(taker, takerGets, takerPays, options = {}) {
|
|
31
|
+
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
32
|
+
options.marker = marker;
|
|
33
|
+
const connection = Client.findConnection(undefined, undefined, undefined, hash);
|
|
34
|
+
if (!connection) {
|
|
35
|
+
throw new Error("There is no connection");
|
|
36
|
+
}
|
|
37
|
+
const response = await connection.request({
|
|
38
|
+
command: "book_offers",
|
|
39
|
+
taker,
|
|
40
|
+
taker_gets: takerGets,
|
|
41
|
+
taker_pays: takerPays,
|
|
42
|
+
ledger_index: options.ledgerIndex || "validated",
|
|
43
|
+
limit: options.limit,
|
|
44
|
+
});
|
|
45
|
+
if (!response) {
|
|
46
|
+
return {
|
|
47
|
+
taker,
|
|
48
|
+
status: "error",
|
|
49
|
+
error: "invalidResponse",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (response.error) {
|
|
53
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
54
|
+
return {
|
|
55
|
+
taker,
|
|
56
|
+
error,
|
|
57
|
+
error_code,
|
|
58
|
+
error_message,
|
|
59
|
+
status,
|
|
60
|
+
validated,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const result = response.result;
|
|
64
|
+
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
65
|
+
if (newMarker) {
|
|
66
|
+
result.marker = newMarker;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
exports.getBookOffers = getBookOffers;
|
|
71
|
+
function convertIssueToTakerAmount(obj) {
|
|
72
|
+
const issuer = obj.counterparty != null ? obj.counterparty : obj.issuer != null ? obj.issuer : undefined;
|
|
73
|
+
const withIssuer = Object.assign({}, obj, { issuer });
|
|
74
|
+
delete withIssuer.counterparty;
|
|
75
|
+
return withIssuer;
|
|
76
|
+
}
|
|
77
|
+
async function getOrderbook(taker, orderbook, options = {}) {
|
|
78
|
+
const [directOfferResults, reverseOfferResults] = await Promise.all([
|
|
79
|
+
getBookOffers(taker, convertIssueToTakerAmount(orderbook.base), convertIssueToTakerAmount(orderbook.counter), options),
|
|
80
|
+
getBookOffers(taker, convertIssueToTakerAmount(orderbook.counter), convertIssueToTakerAmount(orderbook.base), options),
|
|
81
|
+
]);
|
|
82
|
+
if (directOfferResults.error) {
|
|
83
|
+
return directOfferResults;
|
|
84
|
+
}
|
|
85
|
+
if (reverseOfferResults.error) {
|
|
86
|
+
return reverseOfferResults;
|
|
87
|
+
}
|
|
88
|
+
return (0, book_offers_1.formatBidsAndAsks)(orderbook, [...directOfferResults.offers, ...reverseOfferResults.offers]);
|
|
89
|
+
}
|
|
90
|
+
exports.getOrderbook = getOrderbook;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function parseCurrencyInformation(currency: any): Promise<null | DecodeHexCurrencyInterface | DecodedNFTCurrencyInterface>;
|
|
2
|
+
interface DecodedNFTCurrencyInterface {
|
|
3
|
+
type: string;
|
|
4
|
+
currencyCode: string;
|
|
5
|
+
currency: string;
|
|
6
|
+
cti: number;
|
|
7
|
+
ctiLedger: number;
|
|
8
|
+
ctiTxIndex: number;
|
|
9
|
+
ctiValid: boolean;
|
|
10
|
+
ctiVerified: boolean;
|
|
11
|
+
timestamp?: number;
|
|
12
|
+
ctiTx: DecodedNFTCurrencyTransactionInterface;
|
|
13
|
+
}
|
|
14
|
+
interface DecodedNFTCurrencyTransactionInterface {
|
|
15
|
+
type?: string;
|
|
16
|
+
account?: string;
|
|
17
|
+
destination?: string;
|
|
18
|
+
counterparty?: string;
|
|
19
|
+
hash?: string;
|
|
20
|
+
memos?: string;
|
|
21
|
+
}
|
|
22
|
+
interface DecodeHexCurrencyInterface {
|
|
23
|
+
type: string;
|
|
24
|
+
currencyCode: string;
|
|
25
|
+
currency: string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.parseCurrencyInformation = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
const utils_1 = require("../parse/utils");
|
|
29
|
+
const transaction_1 = require("../parse/transaction");
|
|
30
|
+
const maxLength = 12;
|
|
31
|
+
async function parseCurrencyInformation(currency) {
|
|
32
|
+
if (!currency || typeof currency !== "string") {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (currency.length < 3) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (currency.length === 3 && currency.trim().toLowerCase() !== "xrp") {
|
|
39
|
+
return decodeSimple(currency);
|
|
40
|
+
}
|
|
41
|
+
if (isHex(currency)) {
|
|
42
|
+
return await decodeCurrencyHex(currency);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
exports.parseCurrencyInformation = parseCurrencyInformation;
|
|
47
|
+
function decodeSimple(currencyCode) {
|
|
48
|
+
return {
|
|
49
|
+
type: "simple",
|
|
50
|
+
currencyCode,
|
|
51
|
+
currency: currencyCode.trim(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function decodeCurrencyHex(currencyCode) {
|
|
55
|
+
const prefix = currencyCode.substring(0, 2);
|
|
56
|
+
if (prefix === "02" && isXlf15d(currencyCode)) {
|
|
57
|
+
return await decodeXlf15d(currencyCode);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return decodeHex(currencyCode);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function decodeXlf15d(currencyCode) {
|
|
64
|
+
const hex = currencyCode.toString().replace(/(00)+$/g, "");
|
|
65
|
+
const ctiHex = hex.substring(2, 16);
|
|
66
|
+
const cti = BigInt("0x" + ctiHex);
|
|
67
|
+
const ctiLedger = Number(ctiLedgerIndex(cti));
|
|
68
|
+
const ctiTxIndex = Number(ctiTransactionIndex(cti));
|
|
69
|
+
const currencyHex = hex.substring(16, hex.length);
|
|
70
|
+
const currency = (0, utils_1.hexToString)(currencyHex)?.trim()?.replace(/\0/g, "");
|
|
71
|
+
const ledgerInfo = await getLedger(ctiLedger);
|
|
72
|
+
const ledger = ledgerInfo.ledger;
|
|
73
|
+
let ctiVerified = false;
|
|
74
|
+
let ctiValid = false;
|
|
75
|
+
let timestamp;
|
|
76
|
+
let ctiTx = {};
|
|
77
|
+
if (ledger) {
|
|
78
|
+
timestamp = Math.round(new Date(ledger.close_time_human).getTime() / 1000);
|
|
79
|
+
for (const transaction of ledger.transactions) {
|
|
80
|
+
if (transaction.metaData.TransactionIndex === ctiTxIndex) {
|
|
81
|
+
const { Account: account, Destination: destination, LimitAmount: limit, Memos: memos, hash: hash, } = transaction;
|
|
82
|
+
const type = (0, transaction_1.parseTransactionType)(transaction.TransactionType);
|
|
83
|
+
ctiTx = {
|
|
84
|
+
type,
|
|
85
|
+
account,
|
|
86
|
+
destination,
|
|
87
|
+
counterparty: limit?.issuer,
|
|
88
|
+
hash,
|
|
89
|
+
memos,
|
|
90
|
+
};
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (ledger) {
|
|
96
|
+
ctiVerified = true;
|
|
97
|
+
if (ctiTx.hash) {
|
|
98
|
+
ctiValid =
|
|
99
|
+
ctiLedgerCheck(cti) === ctiLedgerCheckGen(ledger.hash) &&
|
|
100
|
+
ctiTransactionCheck(cti) === ctiTransactionCheckGen(ctiTx.hash);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (ledgerInfo.error === "lgrNotFound") {
|
|
104
|
+
ctiVerified = true;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
type: "nft",
|
|
108
|
+
currencyCode,
|
|
109
|
+
currency,
|
|
110
|
+
cti: Number(cti),
|
|
111
|
+
ctiLedger,
|
|
112
|
+
ctiTxIndex,
|
|
113
|
+
ctiValid,
|
|
114
|
+
ctiVerified,
|
|
115
|
+
timestamp,
|
|
116
|
+
ctiTx,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function decodeHex(currencyHex) {
|
|
120
|
+
const decodedHex = (0, utils_1.hexToString)(currencyHex)?.slice(0, maxLength)?.trim();
|
|
121
|
+
if (decodedHex.match(/[a-zA-Z0-9]{3,}/) && decodedHex.toLowerCase() !== "xrp") {
|
|
122
|
+
return {
|
|
123
|
+
type: "hex",
|
|
124
|
+
currencyCode: currencyHex,
|
|
125
|
+
currency: decodedHex.trim().replace(/\0/g, ""),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
async function getLedger(ledgerIndex) {
|
|
131
|
+
let ledgerInfo = null;
|
|
132
|
+
try {
|
|
133
|
+
ledgerInfo = await Client.getLedger({ ledgerIndex, transactions: true, expand: true });
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
}
|
|
137
|
+
return ledgerInfo;
|
|
138
|
+
}
|
|
139
|
+
function ctiTransactionIndex(cti) {
|
|
140
|
+
return (cti >> 32n) & 0xffffn;
|
|
141
|
+
}
|
|
142
|
+
function ctiLedgerIndex(cti) {
|
|
143
|
+
return cti & 0xffffffffn;
|
|
144
|
+
}
|
|
145
|
+
function ctiLedgerCheck(cti) {
|
|
146
|
+
return (cti >> 52n) & 0xfn;
|
|
147
|
+
}
|
|
148
|
+
function ctiTransactionCheck(cti) {
|
|
149
|
+
return (cti >> 48n) & 0xfn;
|
|
150
|
+
}
|
|
151
|
+
function ctiLedgerCheckGen(ledgerHash) {
|
|
152
|
+
return BigInt(parseInt(ledgerHash.slice(0, 1), 16));
|
|
153
|
+
}
|
|
154
|
+
function ctiTransactionCheckGen(txHash) {
|
|
155
|
+
return BigInt(parseInt(txHash.slice(0, 1), 16));
|
|
156
|
+
}
|
|
157
|
+
function isXlf15d(currencyHex) {
|
|
158
|
+
const hex = currencyHex.toString().replace(/(00)+$/g, "");
|
|
159
|
+
const xlf15d = Buffer.from(hex, "hex").slice(8).toString("utf-8").slice(0, maxLength).trim();
|
|
160
|
+
if (xlf15d.match(/[a-zA-Z0-9]{3,}/) && xlf15d.toLowerCase() !== "xrp") {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
function isHex(currencyCode) {
|
|
166
|
+
return !!currencyCode.match(/^[a-fA-F0-9]{40}$/) && !isNaN(parseInt(currencyCode, 16));
|
|
167
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getFee = void 0;
|
|
27
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
28
|
+
const Client = __importStar(require("../client"));
|
|
29
|
+
const common_1 = require("../common");
|
|
30
|
+
async function getFee(options = {}) {
|
|
31
|
+
const connection = options.connection || Client.findConnection();
|
|
32
|
+
if (!connection) {
|
|
33
|
+
throw new Error("There is no connection");
|
|
34
|
+
}
|
|
35
|
+
const response = await connection.request({
|
|
36
|
+
command: "fee",
|
|
37
|
+
});
|
|
38
|
+
const baseFee = response?.result?.drops?.base_fee;
|
|
39
|
+
if (!baseFee) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const fee = new bignumber_js_1.BigNumber(baseFee).multipliedBy(Client.feeCushion).dividedBy(common_1.dropsInXRP);
|
|
43
|
+
return fee.toString();
|
|
44
|
+
}
|
|
45
|
+
exports.getFee = getFee;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Trustline } from "../models/account_lines";
|
|
2
|
+
import { LedgerIndex } from "../models/ledger";
|
|
3
|
+
import { ErrorResponse } from "../models/base_model";
|
|
4
|
+
export interface GetBalanceSheetOptions {
|
|
5
|
+
ledgerIndex?: LedgerIndex;
|
|
6
|
+
hotwallet?: string;
|
|
7
|
+
strict?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function getBalanceSheet(account: string, options?: GetBalanceSheetOptions): Promise<object | ErrorResponse>;
|
|
10
|
+
export interface ObligationTrustline extends Trustline {
|
|
11
|
+
obligation?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function getAccountObligations(account: string): Promise<object | ErrorResponse>;
|