@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,101 @@
|
|
|
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.getAccountObligations = exports.getBalanceSheet = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
32
|
+
const Client = __importStar(require("../client"));
|
|
33
|
+
async function getBalanceSheet(account, options = {}) {
|
|
34
|
+
const connection = Client.findConnection("gateway_balances");
|
|
35
|
+
if (!connection) {
|
|
36
|
+
throw new Error("There is no connection");
|
|
37
|
+
}
|
|
38
|
+
const response = await connection.request({
|
|
39
|
+
command: "gateway_balances",
|
|
40
|
+
account,
|
|
41
|
+
ledger_index: options.ledgerIndex || "validated",
|
|
42
|
+
hotwallet: options.hotwallet,
|
|
43
|
+
strict: !!options.strict,
|
|
44
|
+
});
|
|
45
|
+
if (!response) {
|
|
46
|
+
return {
|
|
47
|
+
account,
|
|
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
|
+
account,
|
|
56
|
+
error,
|
|
57
|
+
error_code,
|
|
58
|
+
error_message,
|
|
59
|
+
status,
|
|
60
|
+
validated,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return response?.result;
|
|
64
|
+
}
|
|
65
|
+
exports.getBalanceSheet = getBalanceSheet;
|
|
66
|
+
async function getAccountObligations(account) {
|
|
67
|
+
const response = (await getBalanceSheet(account));
|
|
68
|
+
if (response.error) {
|
|
69
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
70
|
+
return {
|
|
71
|
+
account,
|
|
72
|
+
error,
|
|
73
|
+
error_code,
|
|
74
|
+
error_message,
|
|
75
|
+
status,
|
|
76
|
+
validated,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const obligations = response.obligations;
|
|
80
|
+
const obligationsLines = [];
|
|
81
|
+
lodash_1.default.map(obligations, (value, currency) => {
|
|
82
|
+
obligationsLines.push(ObligationToObligationTrustline(account, value, currency));
|
|
83
|
+
});
|
|
84
|
+
delete response.obligations;
|
|
85
|
+
delete response.assets;
|
|
86
|
+
response.lines = obligationsLines;
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
exports.getAccountObligations = getAccountObligations;
|
|
90
|
+
function ObligationToObligationTrustline(account, value, currency) {
|
|
91
|
+
return {
|
|
92
|
+
account,
|
|
93
|
+
currency,
|
|
94
|
+
balance: new bignumber_js_1.default(-value).toString(),
|
|
95
|
+
limit: "0",
|
|
96
|
+
limit_peer: "0",
|
|
97
|
+
quality_in: 0,
|
|
98
|
+
quality_out: 0,
|
|
99
|
+
obligation: true,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./account_info";
|
|
2
|
+
export * from "./account_lines";
|
|
3
|
+
export * from "./account_nfts";
|
|
4
|
+
export * from "./account_objects";
|
|
5
|
+
export * from "./account_offers";
|
|
6
|
+
export * from "./account_tx";
|
|
7
|
+
export * from "./book_offers";
|
|
8
|
+
export * from "./currency";
|
|
9
|
+
export * from "./fee";
|
|
10
|
+
export * from "./gateway_balances";
|
|
11
|
+
export * from "./ledger";
|
|
12
|
+
export * from "./manifest";
|
|
13
|
+
export * from "./nft_info";
|
|
14
|
+
export * from "./server_info";
|
|
15
|
+
export * from "./transaction";
|
|
16
|
+
export * from "./vl";
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
__exportStar(require("./account_info"), exports);
|
|
18
|
+
__exportStar(require("./account_lines"), exports);
|
|
19
|
+
__exportStar(require("./account_nfts"), exports);
|
|
20
|
+
__exportStar(require("./account_objects"), exports);
|
|
21
|
+
__exportStar(require("./account_offers"), exports);
|
|
22
|
+
__exportStar(require("./account_tx"), exports);
|
|
23
|
+
__exportStar(require("./book_offers"), exports);
|
|
24
|
+
__exportStar(require("./currency"), exports);
|
|
25
|
+
__exportStar(require("./fee"), exports);
|
|
26
|
+
__exportStar(require("./gateway_balances"), exports);
|
|
27
|
+
__exportStar(require("./ledger"), exports);
|
|
28
|
+
__exportStar(require("./manifest"), exports);
|
|
29
|
+
__exportStar(require("./nft_info"), exports);
|
|
30
|
+
__exportStar(require("./server_info"), exports);
|
|
31
|
+
__exportStar(require("./transaction"), exports);
|
|
32
|
+
__exportStar(require("./vl"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LedgerIndex } from "../models/ledger";
|
|
2
|
+
export interface GetLedgerOptions {
|
|
3
|
+
ledgerIndex?: LedgerIndex;
|
|
4
|
+
transactions?: boolean;
|
|
5
|
+
expand?: boolean;
|
|
6
|
+
legacy?: boolean;
|
|
7
|
+
formatted?: boolean;
|
|
8
|
+
includeRawTransactions?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function getLedger(options?: GetLedgerOptions): Promise<object>;
|
|
11
|
+
export declare function getLedgerIndex(options?: GetLedgerOptions): Promise<number | undefined>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.getLedgerIndex = exports.getLedger = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
const ledger_1 = require("../parse/ledger/ledger");
|
|
29
|
+
async function getLedger(options = {}) {
|
|
30
|
+
const formatted = options.legacy === true || options.formatted === true;
|
|
31
|
+
const connection = Client.findConnection("history");
|
|
32
|
+
if (!connection) {
|
|
33
|
+
throw new Error("There is no connection");
|
|
34
|
+
}
|
|
35
|
+
const response = await connection.request({
|
|
36
|
+
command: "ledger",
|
|
37
|
+
ledger_index: options.ledgerIndex || "validated",
|
|
38
|
+
transactions: !!options.transactions,
|
|
39
|
+
expand: !!options.expand,
|
|
40
|
+
});
|
|
41
|
+
if (response.error) {
|
|
42
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
43
|
+
return {
|
|
44
|
+
error,
|
|
45
|
+
error_code,
|
|
46
|
+
error_message,
|
|
47
|
+
status,
|
|
48
|
+
validated,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const result = response?.result;
|
|
52
|
+
if (!result) {
|
|
53
|
+
return {
|
|
54
|
+
status: "error",
|
|
55
|
+
error: "invalidResponse",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (formatted === true) {
|
|
59
|
+
result.ledger = (0, ledger_1.parseLedger)(result.ledger, options.includeRawTransactions === true);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
exports.getLedger = getLedger;
|
|
64
|
+
async function getLedgerIndex(options = {}) {
|
|
65
|
+
const ledgerInfo = await Client.getLedger(options);
|
|
66
|
+
const ledger = ledgerInfo?.ledger;
|
|
67
|
+
if (ledger) {
|
|
68
|
+
return parseInt(ledger.ledger_index, 10);
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
exports.getLedgerIndex = getLedgerIndex;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Connection } from "../connection";
|
|
2
|
+
import { LedgerIndex } from "../models/ledger";
|
|
3
|
+
import { ErrorResponse } from "../models/base_model";
|
|
4
|
+
export interface GetManifestOptions {
|
|
5
|
+
ledgerIndex?: LedgerIndex;
|
|
6
|
+
connection?: Connection;
|
|
7
|
+
}
|
|
8
|
+
export declare function getManifest(publicKey: string, options?: GetManifestOptions): Promise<object | ErrorResponse>;
|
|
@@ -0,0 +1,56 @@
|
|
|
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.getManifest = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
async function getManifest(publicKey, options = {}) {
|
|
29
|
+
const connection = options.connection || Client.findConnection("manifest");
|
|
30
|
+
if (!connection) {
|
|
31
|
+
throw new Error("There is no connection");
|
|
32
|
+
}
|
|
33
|
+
const response = await connection.request({
|
|
34
|
+
command: "manifest",
|
|
35
|
+
public_key: publicKey,
|
|
36
|
+
});
|
|
37
|
+
if (!response) {
|
|
38
|
+
return {
|
|
39
|
+
public_key: publicKey,
|
|
40
|
+
status: "error",
|
|
41
|
+
error: "invalidResponse",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (response.error) {
|
|
45
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
46
|
+
return {
|
|
47
|
+
error,
|
|
48
|
+
error_code,
|
|
49
|
+
error_message,
|
|
50
|
+
status,
|
|
51
|
+
validated,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return response?.result;
|
|
55
|
+
}
|
|
56
|
+
exports.getManifest = getManifest;
|
|
@@ -0,0 +1,56 @@
|
|
|
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.getNftInfo = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
async function getNftInfo(nft_id, options = {}) {
|
|
29
|
+
const connection = Client.findConnection("clio", undefined, true);
|
|
30
|
+
if (!connection) {
|
|
31
|
+
throw new Error("There is no connection");
|
|
32
|
+
}
|
|
33
|
+
const response = await connection.request({
|
|
34
|
+
command: "nft_info",
|
|
35
|
+
nft_id,
|
|
36
|
+
});
|
|
37
|
+
if (!response) {
|
|
38
|
+
return {
|
|
39
|
+
nft_id,
|
|
40
|
+
status: "error",
|
|
41
|
+
error: "invalidResponse",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (response.error) {
|
|
45
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
46
|
+
return {
|
|
47
|
+
error,
|
|
48
|
+
error_code,
|
|
49
|
+
error_message,
|
|
50
|
+
status,
|
|
51
|
+
validated,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return response?.result;
|
|
55
|
+
}
|
|
56
|
+
exports.getNftInfo = getNftInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Connection } from "../connection";
|
|
2
|
+
import { ErrorResponse } from "../models/base_model";
|
|
3
|
+
export interface GetServerInfoOptions {
|
|
4
|
+
url?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
connection?: Connection;
|
|
7
|
+
}
|
|
8
|
+
export declare function getServerInfo(options?: GetServerInfoOptions): Promise<object | ErrorResponse>;
|
|
@@ -0,0 +1,54 @@
|
|
|
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.getServerInfo = void 0;
|
|
27
|
+
const Client = __importStar(require("../client"));
|
|
28
|
+
async function getServerInfo(options = {}) {
|
|
29
|
+
const connection = options.connection || Client.findConnection(options.type, options.url, true);
|
|
30
|
+
if (!connection) {
|
|
31
|
+
throw new Error("There is no connection");
|
|
32
|
+
}
|
|
33
|
+
const response = await connection.request({
|
|
34
|
+
command: "server_info",
|
|
35
|
+
});
|
|
36
|
+
if (!response) {
|
|
37
|
+
return {
|
|
38
|
+
status: "error",
|
|
39
|
+
error: "invalidResponse",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (response.error) {
|
|
43
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
44
|
+
return {
|
|
45
|
+
error,
|
|
46
|
+
error_code,
|
|
47
|
+
error_message,
|
|
48
|
+
status,
|
|
49
|
+
validated,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return response?.result;
|
|
53
|
+
}
|
|
54
|
+
exports.getServerInfo = getServerInfo;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { XrplDefinitionsBase } from "ripple-binary-codec";
|
|
2
|
+
import { Connection } from "../connection";
|
|
3
|
+
import { TransactionResponse, FormattedTransaction, AccountPaymentParamsInterface } from "../models/transaction";
|
|
4
|
+
import { FormattedMemo } from "../v1/common/types/objects";
|
|
5
|
+
import { ErrorResponse } from "../models/base_model";
|
|
6
|
+
export interface GetTransactionOptions {
|
|
7
|
+
binary?: boolean;
|
|
8
|
+
minLedger?: number;
|
|
9
|
+
maxLedger?: number;
|
|
10
|
+
balanceChanges?: boolean;
|
|
11
|
+
specification?: boolean;
|
|
12
|
+
legacy?: boolean;
|
|
13
|
+
formatted?: boolean;
|
|
14
|
+
includeRawTransaction?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function getTransaction(transaction: string, options?: GetTransactionOptions): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
|
|
17
|
+
interface LegacyPaymentInterface {
|
|
18
|
+
sourceAddress: string;
|
|
19
|
+
sourceTag?: number;
|
|
20
|
+
sourceValue: string;
|
|
21
|
+
sourceCurrency: string;
|
|
22
|
+
destinationAddress: string;
|
|
23
|
+
destinationTag?: number;
|
|
24
|
+
destinationValue: string;
|
|
25
|
+
destinationCurrency: string;
|
|
26
|
+
networkID?: number;
|
|
27
|
+
memos: FormattedMemo[];
|
|
28
|
+
secret: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function legacyPayment(data: LegacyPaymentInterface, definitions?: XrplDefinitionsBase): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
|
|
31
|
+
export declare function getAccountPaymentParams(account: string, connection?: Connection): Promise<AccountPaymentParamsInterface | ErrorResponse>;
|
|
32
|
+
export interface SubmitOptionsInterface {
|
|
33
|
+
connection?: Connection;
|
|
34
|
+
definitions?: XrplDefinitionsBase;
|
|
35
|
+
}
|
|
36
|
+
export declare function submit(signedTransaction: string, options?: SubmitOptionsInterface): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
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.submit = exports.getAccountPaymentParams = exports.legacyPayment = exports.getTransaction = void 0;
|
|
27
|
+
const xrpl = __importStar(require("xrpl"));
|
|
28
|
+
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
|
29
|
+
const Client = __importStar(require("../client"));
|
|
30
|
+
const utils_1 = require("../common/utils");
|
|
31
|
+
const transaction_1 = require("../models/transaction");
|
|
32
|
+
const payment_1 = require("../v1/transaction/payment");
|
|
33
|
+
const common_1 = require("../common");
|
|
34
|
+
const wallet_1 = require("../wallet");
|
|
35
|
+
const submitErrorsGroup = ["tem", "tef", "tel", "ter"];
|
|
36
|
+
const FEE_LIMIT = 0.5;
|
|
37
|
+
const LEDGER_CLOSE_TIME_AWAIT = 2000;
|
|
38
|
+
const MAX_LEDGERS_AWAIT = 5;
|
|
39
|
+
async function getTransaction(transaction, options = {}) {
|
|
40
|
+
const formatted = options.legacy === true || options.formatted === true;
|
|
41
|
+
const connection = Client.findConnection("history");
|
|
42
|
+
if (!connection) {
|
|
43
|
+
throw new Error("There is no connection");
|
|
44
|
+
}
|
|
45
|
+
const response = await connection.request({
|
|
46
|
+
command: "tx",
|
|
47
|
+
transaction,
|
|
48
|
+
binary: !!options.binary,
|
|
49
|
+
min_ledger: options.minLedger,
|
|
50
|
+
max_ledger: options.maxLedger,
|
|
51
|
+
});
|
|
52
|
+
if (!response) {
|
|
53
|
+
return {
|
|
54
|
+
status: "error",
|
|
55
|
+
error: "invalidResponse",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (response.error) {
|
|
59
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
60
|
+
return {
|
|
61
|
+
transaction,
|
|
62
|
+
error,
|
|
63
|
+
error_code,
|
|
64
|
+
error_message,
|
|
65
|
+
status,
|
|
66
|
+
validated,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const result = response?.result;
|
|
70
|
+
if (typeof result === "object") {
|
|
71
|
+
if (formatted === true) {
|
|
72
|
+
return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true);
|
|
73
|
+
}
|
|
74
|
+
if (options.balanceChanges === true && typeof result.meta === "object") {
|
|
75
|
+
result.balanceChanges = xrpl.getBalanceChanges(result.meta);
|
|
76
|
+
}
|
|
77
|
+
if (options.specification === true) {
|
|
78
|
+
const details = (0, transaction_1.getTxDetails)(result, true);
|
|
79
|
+
result.specification = details.specification;
|
|
80
|
+
result.outcome = details.outcome;
|
|
81
|
+
result.rawTransaction = details.rawTransaction;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
exports.getTransaction = getTransaction;
|
|
87
|
+
async function legacyPayment(data, definitions) {
|
|
88
|
+
const connection = Client.findConnection();
|
|
89
|
+
if (!connection) {
|
|
90
|
+
throw new Error("There is no connection");
|
|
91
|
+
}
|
|
92
|
+
const txPayment = {
|
|
93
|
+
source: {
|
|
94
|
+
address: data.sourceAddress,
|
|
95
|
+
tag: data.sourceTag,
|
|
96
|
+
maxAmount: {
|
|
97
|
+
value: data.sourceValue.toString(),
|
|
98
|
+
currency: data.sourceCurrency,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
destination: {
|
|
102
|
+
address: data.destinationAddress,
|
|
103
|
+
tag: data.destinationTag,
|
|
104
|
+
amount: {
|
|
105
|
+
value: data.destinationValue.toString(),
|
|
106
|
+
currency: data.destinationCurrency,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
networkID: data.networkID,
|
|
110
|
+
memos: data.memos,
|
|
111
|
+
};
|
|
112
|
+
const transaction = (0, payment_1.createPaymentTransaction)(data.sourceAddress, txPayment);
|
|
113
|
+
const paymentParams = await getAccountPaymentParams(data.sourceAddress, connection);
|
|
114
|
+
if ("error" in paymentParams) {
|
|
115
|
+
return paymentParams;
|
|
116
|
+
}
|
|
117
|
+
transaction.Fee = paymentParams.fee;
|
|
118
|
+
transaction.Sequence = paymentParams.sequence;
|
|
119
|
+
transaction.LastLedgerSequence = paymentParams.lastLedgerSequence;
|
|
120
|
+
const wallet = xrpl.Wallet.fromSeed(data.secret);
|
|
121
|
+
const signedTransaction = (0, wallet_1.singTransaction)(wallet, transaction, false, definitions).tx_blob;
|
|
122
|
+
return await submit(signedTransaction, { connection, definitions });
|
|
123
|
+
}
|
|
124
|
+
exports.legacyPayment = legacyPayment;
|
|
125
|
+
async function getAccountPaymentParams(account, connection) {
|
|
126
|
+
try {
|
|
127
|
+
const feePromise = new Promise(async (resolve) => {
|
|
128
|
+
const baseFee = await Client.getFee({ connection });
|
|
129
|
+
let fee = parseFloat(baseFee);
|
|
130
|
+
if (fee > FEE_LIMIT) {
|
|
131
|
+
fee = FEE_LIMIT;
|
|
132
|
+
}
|
|
133
|
+
resolve((0, common_1.xrpToDrops)(fee));
|
|
134
|
+
});
|
|
135
|
+
const sequencePromise = new Promise(async (resolve, rejects) => {
|
|
136
|
+
const accountInfo = await Client.getAccountInfo(account, { connection });
|
|
137
|
+
if (!accountInfo) {
|
|
138
|
+
return rejects(new Error("Account not found"));
|
|
139
|
+
}
|
|
140
|
+
if ("error" in accountInfo) {
|
|
141
|
+
return rejects(new Error(accountInfo.error));
|
|
142
|
+
}
|
|
143
|
+
resolve(accountInfo?.account_data?.Sequence);
|
|
144
|
+
});
|
|
145
|
+
const lastLedgerSequencePromise = new Promise(async (resolve) => {
|
|
146
|
+
const ledgerIndex = await Client.getLedgerIndex();
|
|
147
|
+
if (ledgerIndex !== undefined) {
|
|
148
|
+
resolve(ledgerIndex + MAX_LEDGERS_AWAIT);
|
|
149
|
+
}
|
|
150
|
+
resolve(undefined);
|
|
151
|
+
});
|
|
152
|
+
const result = await Promise.all([feePromise, sequencePromise, lastLedgerSequencePromise]);
|
|
153
|
+
return {
|
|
154
|
+
fee: result[0],
|
|
155
|
+
sequence: result[1],
|
|
156
|
+
lastLedgerSequence: result[2],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
return {
|
|
161
|
+
account,
|
|
162
|
+
status: "error",
|
|
163
|
+
error: e.message,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.getAccountPaymentParams = getAccountPaymentParams;
|
|
168
|
+
async function submit(signedTransaction, options = {}) {
|
|
169
|
+
const connection = options.connection || Client.findConnection();
|
|
170
|
+
if (!connection) {
|
|
171
|
+
throw new Error("There is no connection");
|
|
172
|
+
}
|
|
173
|
+
const response = await connection.submit(signedTransaction);
|
|
174
|
+
if (response.error) {
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
const result = response?.result;
|
|
178
|
+
const resultGroup = result?.engine_result.slice(0, 3);
|
|
179
|
+
if (submitErrorsGroup.includes(resultGroup) && result?.engine_result !== "terQUEUED") {
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
const txHash = result.tx_json?.hash;
|
|
183
|
+
if (!txHash) {
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
let lastLedger = 0;
|
|
187
|
+
const transaction = (0, ripple_binary_codec_1.decode)(signedTransaction, options.definitions);
|
|
188
|
+
if (transaction.LastLedgerSequence) {
|
|
189
|
+
lastLedger = transaction.LastLedgerSequence;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const ledgerIndex = await Client.getLedgerIndex();
|
|
193
|
+
if (ledgerIndex !== undefined) {
|
|
194
|
+
lastLedger = ledgerIndex + MAX_LEDGERS_AWAIT;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return await waitForFinalTransactionOutcome(txHash, lastLedger);
|
|
198
|
+
}
|
|
199
|
+
exports.submit = submit;
|
|
200
|
+
async function waitForFinalTransactionOutcome(txHash, lastLedger) {
|
|
201
|
+
await (0, utils_1.sleep)(LEDGER_CLOSE_TIME_AWAIT);
|
|
202
|
+
const tx = await getTransaction(txHash);
|
|
203
|
+
const error = tx?.error;
|
|
204
|
+
if (error === "Not connected") {
|
|
205
|
+
return tx;
|
|
206
|
+
}
|
|
207
|
+
if (!tx || error === "txnNotFound" || tx.validated !== true) {
|
|
208
|
+
const ledgerIndex = await Client.getLedgerIndex();
|
|
209
|
+
if (ledgerIndex === undefined || lastLedger > ledgerIndex) {
|
|
210
|
+
return waitForFinalTransactionOutcome(txHash, lastLedger);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return tx;
|
|
214
|
+
}
|