@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,82 @@
|
|
|
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
|
+
const _ = __importStar(require("lodash"));
|
|
30
|
+
const assert = __importStar(require("assert"));
|
|
31
|
+
const account_info_1 = require("../../../models/account_info");
|
|
32
|
+
const common_1 = require("../../common");
|
|
33
|
+
const fields_1 = __importDefault(require("./fields"));
|
|
34
|
+
const memos_1 = __importDefault(require("./memos"));
|
|
35
|
+
function getAccountRootModifiedNode(tx) {
|
|
36
|
+
const modifiedNodes = tx.meta.AffectedNodes.filter(node => node.ModifiedNode?.LedgerEntryType === 'AccountRoot');
|
|
37
|
+
assert.ok(modifiedNodes.length === 1);
|
|
38
|
+
return modifiedNodes[0].ModifiedNode;
|
|
39
|
+
}
|
|
40
|
+
function parseFlags(tx) {
|
|
41
|
+
const settings = {};
|
|
42
|
+
if (tx.TransactionType !== 'AccountSet') {
|
|
43
|
+
return settings;
|
|
44
|
+
}
|
|
45
|
+
const node = getAccountRootModifiedNode(tx);
|
|
46
|
+
const oldFlags = _.get(node.PreviousFields, 'Flags');
|
|
47
|
+
const newFlags = _.get(node.FinalFields, 'Flags');
|
|
48
|
+
if (oldFlags != null && newFlags != null) {
|
|
49
|
+
const changedFlags = oldFlags ^ newFlags;
|
|
50
|
+
const setFlags = newFlags & changedFlags;
|
|
51
|
+
const clearedFlags = oldFlags & changedFlags;
|
|
52
|
+
Object.entries(account_info_1.AccountRootFlagsKeys).forEach(entry => {
|
|
53
|
+
const [flagName, flagValue] = entry;
|
|
54
|
+
if (setFlags & flagValue) {
|
|
55
|
+
settings[flagName] = true;
|
|
56
|
+
}
|
|
57
|
+
else if (clearedFlags & flagValue) {
|
|
58
|
+
settings[flagName] = false;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const oldField = _.get(node.PreviousFields, 'AccountTxnID');
|
|
63
|
+
const newField = _.get(node.FinalFields, 'AccountTxnID');
|
|
64
|
+
if (newField && !oldField) {
|
|
65
|
+
settings.enableTransactionIDTracking = true;
|
|
66
|
+
}
|
|
67
|
+
else if (oldField && !newField) {
|
|
68
|
+
settings.enableTransactionIDTracking = false;
|
|
69
|
+
}
|
|
70
|
+
return settings;
|
|
71
|
+
}
|
|
72
|
+
function parseSettings(tx) {
|
|
73
|
+
const txType = tx.TransactionType;
|
|
74
|
+
assert.ok(txType === 'AccountSet' ||
|
|
75
|
+
txType === 'SetRegularKey' ||
|
|
76
|
+
txType === 'SignerListSet');
|
|
77
|
+
const baseSettings = (0, common_1.removeUndefined)({
|
|
78
|
+
memos: (0, memos_1.default)(tx),
|
|
79
|
+
});
|
|
80
|
+
return Object.assign(baseSettings, parseFlags(tx), (0, fields_1.default)(tx));
|
|
81
|
+
}
|
|
82
|
+
exports.default = parseSettings;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("./memos"));
|
|
32
|
+
function parseTicketCreate(tx) {
|
|
33
|
+
assert.ok(tx.TransactionType === 'TicketCreate');
|
|
34
|
+
return (0, common_1.removeUndefined)({
|
|
35
|
+
memos: (0, memos_1.default)(tx),
|
|
36
|
+
ticketCount: tx.TicketCount
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.default = parseTicketCreate;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseTransaction = exports.parseTransactionType = void 0;
|
|
7
|
+
const common_1 = require("../../common");
|
|
8
|
+
const parse_outcome_1 = __importDefault(require("../parse_outcome"));
|
|
9
|
+
const settings_1 = __importDefault(require("./settings"));
|
|
10
|
+
const account_delete_1 = __importDefault(require("./account-delete"));
|
|
11
|
+
const check_cancel_1 = __importDefault(require("./check-cancel"));
|
|
12
|
+
const check_cash_1 = __importDefault(require("./check-cash"));
|
|
13
|
+
const check_create_1 = __importDefault(require("./check-create"));
|
|
14
|
+
const deposit_preauth_1 = __importDefault(require("./deposit-preauth"));
|
|
15
|
+
const escrow_cancellation_1 = __importDefault(require("./escrow-cancellation"));
|
|
16
|
+
const escrow_creation_1 = __importDefault(require("./escrow-creation"));
|
|
17
|
+
const escrow_execution_1 = __importDefault(require("./escrow-execution"));
|
|
18
|
+
const cancellation_1 = __importDefault(require("./cancellation"));
|
|
19
|
+
const order_1 = __importDefault(require("./order"));
|
|
20
|
+
const payment_1 = __importDefault(require("./payment"));
|
|
21
|
+
const payment_channel_claim_1 = __importDefault(require("./payment-channel-claim"));
|
|
22
|
+
const payment_channel_create_1 = __importDefault(require("./payment-channel-create"));
|
|
23
|
+
const payment_channel_fund_1 = __importDefault(require("./payment-channel-fund"));
|
|
24
|
+
const ticket_create_1 = __importDefault(require("./ticket-create"));
|
|
25
|
+
const trustline_1 = __importDefault(require("./trustline"));
|
|
26
|
+
const account_nfts_1 = require("../../../models/account_nfts");
|
|
27
|
+
const amendment_1 = __importDefault(require("./amendment"));
|
|
28
|
+
const fee_update_1 = __importDefault(require("./fee-update"));
|
|
29
|
+
const transactionTypeToType = {
|
|
30
|
+
AccountSet: 'settings',
|
|
31
|
+
AccountDelete: 'accountDelete',
|
|
32
|
+
CheckCancel: 'checkCancel',
|
|
33
|
+
CheckCash: 'checkCash',
|
|
34
|
+
CheckCreate: 'checkCreate',
|
|
35
|
+
DepositPreauth: 'depositPreauth',
|
|
36
|
+
EscrowCancel: 'escrowCancellation',
|
|
37
|
+
EscrowCreate: 'escrowCreation',
|
|
38
|
+
EscrowFinish: 'escrowExecution',
|
|
39
|
+
OfferCancel: 'orderCancellation',
|
|
40
|
+
OfferCreate: 'order',
|
|
41
|
+
Payment: 'payment',
|
|
42
|
+
PaymentChannelClaim: 'paymentChannelClaim',
|
|
43
|
+
PaymentChannelCreate: 'paymentChannelCreate',
|
|
44
|
+
PaymentChannelFund: 'paymentChannelFund',
|
|
45
|
+
SetRegularKey: 'settings',
|
|
46
|
+
SignerListSet: 'settings',
|
|
47
|
+
TicketCreate: 'ticketCreate',
|
|
48
|
+
TrustSet: 'trustline',
|
|
49
|
+
NFTokenBurn: 'nftokenBurn',
|
|
50
|
+
NFTokenMint: 'nftokenMint',
|
|
51
|
+
NFTokenCancelOffer: 'nftokenCancelOffer',
|
|
52
|
+
NFTokenCreateOffer: 'nftokenCreateOffer',
|
|
53
|
+
NFTokenAcceptOffer: 'nftokenAcceptOffer',
|
|
54
|
+
EnableAmendment: 'amendment',
|
|
55
|
+
SetFee: 'feeUpdate'
|
|
56
|
+
};
|
|
57
|
+
function parseTransactionType(type) {
|
|
58
|
+
return transactionTypeToType[type] || null;
|
|
59
|
+
}
|
|
60
|
+
exports.parseTransactionType = parseTransactionType;
|
|
61
|
+
const parserTypeFunc = {
|
|
62
|
+
settings: settings_1.default,
|
|
63
|
+
accountDelete: account_delete_1.default,
|
|
64
|
+
checkCancel: check_cancel_1.default,
|
|
65
|
+
checkCash: check_cash_1.default,
|
|
66
|
+
checkCreate: check_create_1.default,
|
|
67
|
+
depositPreauth: deposit_preauth_1.default,
|
|
68
|
+
escrowCancellation: escrow_cancellation_1.default,
|
|
69
|
+
escrowCreation: escrow_creation_1.default,
|
|
70
|
+
escrowExecution: escrow_execution_1.default,
|
|
71
|
+
orderCancellation: cancellation_1.default,
|
|
72
|
+
order: order_1.default,
|
|
73
|
+
payment: payment_1.default,
|
|
74
|
+
paymentChannelClaim: payment_channel_claim_1.default,
|
|
75
|
+
paymentChannelCreate: payment_channel_create_1.default,
|
|
76
|
+
paymentChannelFund: payment_channel_fund_1.default,
|
|
77
|
+
ticketCreate: ticket_create_1.default,
|
|
78
|
+
trustline: trustline_1.default,
|
|
79
|
+
nftokenBurn: account_nfts_1.parseNFTokenBurn,
|
|
80
|
+
nftokenMint: account_nfts_1.parseNFTokenMint,
|
|
81
|
+
nftokenCancelOffer: account_nfts_1.parseNFTokenCancelOffer,
|
|
82
|
+
nftokenCreateOffer: account_nfts_1.parseNFTokenCreateOffer,
|
|
83
|
+
nftokenAcceptOffer: account_nfts_1.parseNFTokenAcceptOffer,
|
|
84
|
+
amendment: amendment_1.default,
|
|
85
|
+
feeUpdate: fee_update_1.default
|
|
86
|
+
};
|
|
87
|
+
function parseTransaction(tx, includeRawTransaction) {
|
|
88
|
+
const type = parseTransactionType(tx.TransactionType);
|
|
89
|
+
const parser = parserTypeFunc[type];
|
|
90
|
+
const specification = parser
|
|
91
|
+
? parser(tx)
|
|
92
|
+
: {
|
|
93
|
+
UNAVAILABLE: 'Unrecognized transaction type.',
|
|
94
|
+
SEE_RAW_TRANSACTION: 'Since this type is unrecognized, `rawTransaction` is included in this response.'
|
|
95
|
+
};
|
|
96
|
+
if (!parser) {
|
|
97
|
+
includeRawTransaction = true;
|
|
98
|
+
}
|
|
99
|
+
const outcome = (0, parse_outcome_1.default)(tx);
|
|
100
|
+
return (0, common_1.removeUndefined)({
|
|
101
|
+
type: type,
|
|
102
|
+
address: tx.Account,
|
|
103
|
+
sequence: tx.Sequence,
|
|
104
|
+
id: tx.hash,
|
|
105
|
+
specification: (0, common_1.removeUndefined)(specification),
|
|
106
|
+
outcome: outcome ? (0, common_1.removeUndefined)(outcome) : undefined,
|
|
107
|
+
rawTransaction: includeRawTransaction ? JSON.stringify(tx) : undefined
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.parseTransaction = parseTransaction;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (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
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const xrpl_1 = require("xrpl");
|
|
31
|
+
const utils_1 = require("./utils");
|
|
32
|
+
const common_1 = require("../../common");
|
|
33
|
+
const memos_1 = __importDefault(require("./memos"));
|
|
34
|
+
function parseFlag(flagsValue, trueValue, falseValue) {
|
|
35
|
+
if (flagsValue & trueValue) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (flagsValue & falseValue) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
function parseTrustline(tx) {
|
|
44
|
+
assert.ok(tx.TransactionType === 'TrustSet');
|
|
45
|
+
return (0, common_1.removeUndefined)({
|
|
46
|
+
limit: tx.LimitAmount.value,
|
|
47
|
+
currency: tx.LimitAmount.currency,
|
|
48
|
+
counterparty: tx.LimitAmount.issuer,
|
|
49
|
+
memos: (0, memos_1.default)(tx),
|
|
50
|
+
qualityIn: (0, utils_1.parseQuality)(tx.QualityIn),
|
|
51
|
+
qualityOut: (0, utils_1.parseQuality)(tx.QualityOut),
|
|
52
|
+
ripplingDisabled: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetNoRipple, xrpl_1.TrustSetFlags.tfClearNoRipple),
|
|
53
|
+
frozen: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetFreeze, xrpl_1.TrustSetFlags.tfClearFreeze),
|
|
54
|
+
authorized: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetfAuth, 0)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.default = parseTrustline;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function adjustQualityForXRP(quality: string, takerGetsCurrency: string, takerPaysCurrency: string): string;
|
|
2
|
+
declare function parseQuality(quality?: number | null): number | undefined;
|
|
3
|
+
declare function parseTimestamp(rippleTime?: number | null): string | undefined;
|
|
4
|
+
declare function isPartialPayment(tx: any): boolean;
|
|
5
|
+
declare function hexToString(hex: string): string | undefined;
|
|
6
|
+
export { parseQuality, hexToString, parseTimestamp, adjustQualityForXRP, isPartialPayment };
|
|
@@ -0,0 +1,63 @@
|
|
|
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.isPartialPayment = exports.adjustQualityForXRP = exports.parseTimestamp = exports.hexToString = exports.parseQuality = void 0;
|
|
30
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
31
|
+
const xrpl_1 = require("xrpl");
|
|
32
|
+
const common = __importStar(require("../../common"));
|
|
33
|
+
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
|
|
34
|
+
const numeratorShift = takerPaysCurrency === 'XRP' ? -6 : 0;
|
|
35
|
+
const denominatorShift = takerGetsCurrency === 'XRP' ? -6 : 0;
|
|
36
|
+
const shift = numeratorShift - denominatorShift;
|
|
37
|
+
return shift === 0
|
|
38
|
+
? quality
|
|
39
|
+
: new bignumber_js_1.default(quality).shiftedBy(shift).toString();
|
|
40
|
+
}
|
|
41
|
+
exports.adjustQualityForXRP = adjustQualityForXRP;
|
|
42
|
+
function parseQuality(quality) {
|
|
43
|
+
if (typeof quality !== 'number') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return new bignumber_js_1.default(quality).shiftedBy(-9).toNumber();
|
|
47
|
+
}
|
|
48
|
+
exports.parseQuality = parseQuality;
|
|
49
|
+
function parseTimestamp(rippleTime) {
|
|
50
|
+
if (typeof rippleTime !== 'number') {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return common.rippleTimeToISO8601(rippleTime);
|
|
54
|
+
}
|
|
55
|
+
exports.parseTimestamp = parseTimestamp;
|
|
56
|
+
function isPartialPayment(tx) {
|
|
57
|
+
return (tx.Flags & xrpl_1.PaymentFlags.tfPartialPayment) !== 0;
|
|
58
|
+
}
|
|
59
|
+
exports.isPartialPayment = isPartialPayment;
|
|
60
|
+
function hexToString(hex) {
|
|
61
|
+
return hex ? Buffer.from(hex, 'hex').toString('utf-8') : undefined;
|
|
62
|
+
}
|
|
63
|
+
exports.hexToString = hexToString;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const transaction_1 = require("../../models/transaction");
|
|
7
|
+
const amount_1 = __importDefault(require("./parse/amount"));
|
|
8
|
+
const utils_1 = require("./parse/utils");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
function removeEmptyCounterparty(amount) {
|
|
11
|
+
if (amount.counterparty === '') {
|
|
12
|
+
delete amount.counterparty;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function removeEmptyCounterpartyInBalanceChanges(balanceChanges) {
|
|
16
|
+
Object.entries(balanceChanges).forEach(([_, changes]) => {
|
|
17
|
+
changes.forEach(removeEmptyCounterparty);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function removeEmptyCounterpartyInOrderbookChanges(orderbookChanges) {
|
|
21
|
+
Object.entries(orderbookChanges).forEach(([_, changes]) => {
|
|
22
|
+
changes.forEach((change) => {
|
|
23
|
+
Object.entries(change).forEach(removeEmptyCounterparty);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function parseDeliveredAmount(tx) {
|
|
28
|
+
if (tx.TransactionType !== 'Payment' ||
|
|
29
|
+
tx.meta.TransactionResult !== 'tesSUCCESS') {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (tx.meta.delivered_amount && tx.meta.delivered_amount === 'unavailable') {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (tx.meta.delivered_amount) {
|
|
36
|
+
return (0, amount_1.default)(tx.meta.delivered_amount);
|
|
37
|
+
}
|
|
38
|
+
if (tx.meta.DeliveredAmount) {
|
|
39
|
+
return (0, amount_1.default)(tx.meta.DeliveredAmount);
|
|
40
|
+
}
|
|
41
|
+
if (tx.Amount && !(0, utils_1.isPartialPayment)(tx)) {
|
|
42
|
+
return (0, amount_1.default)(tx.Amount);
|
|
43
|
+
}
|
|
44
|
+
if (tx.Amount && tx.ledger_index > 4594094) {
|
|
45
|
+
return (0, amount_1.default)(tx.Amount);
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
function parseOutcome(tx) {
|
|
50
|
+
const metadata = tx.meta || tx.metaData;
|
|
51
|
+
if (!metadata) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const balanceChanges = (0, transaction_1.parseBalanceChanges)(metadata);
|
|
55
|
+
const lockedBalanceChanges = (0, transaction_1.parseLockedBalanceChanges)(metadata);
|
|
56
|
+
const orderbookChanges = (0, transaction_1.parseOrderbookChanges)(metadata);
|
|
57
|
+
const channelChanges = (0, transaction_1.parseChannelChanges)(metadata);
|
|
58
|
+
const nftokenChanges = (0, transaction_1.parseNFTokenChanges)(tx);
|
|
59
|
+
const nftokenOfferChanges = (0, transaction_1.parseNFTokenOfferChanges)(tx);
|
|
60
|
+
const affectedObjects = (0, transaction_1.parseAffectedObjects)(tx);
|
|
61
|
+
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
|
|
62
|
+
removeEmptyCounterpartyInBalanceChanges(lockedBalanceChanges);
|
|
63
|
+
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
|
|
64
|
+
return (0, common_1.removeUndefined)({
|
|
65
|
+
result: tx.meta.TransactionResult,
|
|
66
|
+
timestamp: (0, utils_1.parseTimestamp)(tx.date),
|
|
67
|
+
fee: (0, common_1.dropsToXrp)(tx.Fee),
|
|
68
|
+
balanceChanges,
|
|
69
|
+
lockedBalanceChanges,
|
|
70
|
+
orderbookChanges,
|
|
71
|
+
channelChanges,
|
|
72
|
+
nftokenChanges,
|
|
73
|
+
nftokenOfferChanges,
|
|
74
|
+
affectedObjects: affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined,
|
|
75
|
+
ledgerVersion: tx.ledger_index,
|
|
76
|
+
indexInLedger: tx.meta.TransactionIndex,
|
|
77
|
+
deliveredAmount: parseDeliveredAmount(tx)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.default = parseOutcome;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Amount, RippledAmount, Adjustment, MaxAdjustment, MinAdjustment } from '../common/types/objects';
|
|
2
|
+
export type LaxLaxAmount = {
|
|
3
|
+
currency: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
issuer?: string;
|
|
6
|
+
counterparty?: string;
|
|
7
|
+
};
|
|
8
|
+
export type Path = {
|
|
9
|
+
source: Adjustment | MaxAdjustment;
|
|
10
|
+
destination: Adjustment | MinAdjustment;
|
|
11
|
+
paths: string;
|
|
12
|
+
};
|
|
13
|
+
export type GetPaths = Array<Path>;
|
|
14
|
+
export type PathFind = {
|
|
15
|
+
source: {
|
|
16
|
+
address: string;
|
|
17
|
+
amount?: Amount;
|
|
18
|
+
currencies?: Array<{
|
|
19
|
+
currency: string;
|
|
20
|
+
counterparty?: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
destination: {
|
|
24
|
+
address: string;
|
|
25
|
+
amount: LaxLaxAmount;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type PathFindRequest = {
|
|
29
|
+
command: string;
|
|
30
|
+
source_account: string;
|
|
31
|
+
destination_amount: RippledAmount;
|
|
32
|
+
destination_account: string;
|
|
33
|
+
source_currencies?: {
|
|
34
|
+
currency: string;
|
|
35
|
+
issuer?: string;
|
|
36
|
+
}[];
|
|
37
|
+
send_max?: RippledAmount;
|
|
38
|
+
};
|
|
39
|
+
export type RippledPathsResponse = {
|
|
40
|
+
alternatives: Array<{
|
|
41
|
+
paths_computed: Array<Array<{
|
|
42
|
+
type: number;
|
|
43
|
+
type_hex: string;
|
|
44
|
+
account?: string;
|
|
45
|
+
issuer?: string;
|
|
46
|
+
currency?: string;
|
|
47
|
+
}>>;
|
|
48
|
+
source_amount: RippledAmount;
|
|
49
|
+
}>;
|
|
50
|
+
type: string;
|
|
51
|
+
destination_account: string;
|
|
52
|
+
destination_amount: RippledAmount;
|
|
53
|
+
destination_currencies?: Array<string>;
|
|
54
|
+
source_account: string;
|
|
55
|
+
source_currencies?: Array<{
|
|
56
|
+
currency: string;
|
|
57
|
+
}>;
|
|
58
|
+
full_reply?: boolean;
|
|
59
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransactionJSON } from "./types";
|
|
2
|
+
import { Adjustment, MaxAdjustment, MinAdjustment, FormattedMemo } from "../common/types/objects";
|
|
3
|
+
export interface Payment {
|
|
4
|
+
source: Adjustment | MaxAdjustment;
|
|
5
|
+
destination: Adjustment | MinAdjustment;
|
|
6
|
+
paths?: string;
|
|
7
|
+
networkID?: number;
|
|
8
|
+
memos?: FormattedMemo[];
|
|
9
|
+
invoiceID?: string;
|
|
10
|
+
allowPartialPayment?: boolean;
|
|
11
|
+
noDirectRipple?: boolean;
|
|
12
|
+
limitQuality?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function createPaymentTransaction(address: string, paymentArgument: Payment): TransactionJSON;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPaymentTransaction = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const xrpl_1 = require("xrpl");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
const common_2 = require("../../common");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
function isMaxAdjustment(source) {
|
|
13
|
+
return source.maxAmount != null;
|
|
14
|
+
}
|
|
15
|
+
function isMinAdjustment(destination) {
|
|
16
|
+
return destination.minAmount != null;
|
|
17
|
+
}
|
|
18
|
+
function isXRPToXRPPayment(payment) {
|
|
19
|
+
const { source, destination } = payment;
|
|
20
|
+
const sourceCurrency = isMaxAdjustment(source) ? source.maxAmount.currency : source.amount.currency;
|
|
21
|
+
const destinationCurrency = isMinAdjustment(destination)
|
|
22
|
+
? destination.minAmount.currency
|
|
23
|
+
: destination.amount.currency;
|
|
24
|
+
return ((sourceCurrency === "XRP" || sourceCurrency === "drops") &&
|
|
25
|
+
(destinationCurrency === "XRP" || destinationCurrency === "drops"));
|
|
26
|
+
}
|
|
27
|
+
function isIOUWithoutCounterparty(amount) {
|
|
28
|
+
return amount && amount.currency !== "XRP" && amount.currency !== "drops" && amount.counterparty == null;
|
|
29
|
+
}
|
|
30
|
+
function applyAnyCounterpartyEncoding(payment) {
|
|
31
|
+
[payment.source, payment.destination].forEach((adjustment) => {
|
|
32
|
+
["amount", "minAmount", "maxAmount"].forEach((key) => {
|
|
33
|
+
if (isIOUWithoutCounterparty(adjustment[key])) {
|
|
34
|
+
adjustment[key].counterparty = adjustment.address;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function createMaximalAmount(amount) {
|
|
40
|
+
const maxXRPValue = "100000000000";
|
|
41
|
+
const maxIOUValue = "999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
|
42
|
+
let maxValue;
|
|
43
|
+
if (amount.currency === "XRP") {
|
|
44
|
+
maxValue = maxXRPValue;
|
|
45
|
+
}
|
|
46
|
+
else if (amount.currency === "drops") {
|
|
47
|
+
maxValue = (0, common_2.xrpToDrops)(maxXRPValue);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
maxValue = maxIOUValue;
|
|
51
|
+
}
|
|
52
|
+
return Object.assign({}, amount, { value: maxValue });
|
|
53
|
+
}
|
|
54
|
+
function validateAndNormalizeAddress(address, expectedTag) {
|
|
55
|
+
const classicAddress = (0, utils_1.getClassicAccountAndTag)(address, expectedTag);
|
|
56
|
+
classicAddress.tag = classicAddress.tag === false ? undefined : classicAddress.tag;
|
|
57
|
+
return classicAddress;
|
|
58
|
+
}
|
|
59
|
+
function createPaymentTransaction(address, paymentArgument) {
|
|
60
|
+
const payment = lodash_1.default.cloneDeep(paymentArgument);
|
|
61
|
+
applyAnyCounterpartyEncoding(payment);
|
|
62
|
+
const sourceAddressAndTag = validateAndNormalizeAddress(payment.source.address, payment.source.tag);
|
|
63
|
+
const addressToVerifyAgainst = validateAndNormalizeAddress(address, undefined);
|
|
64
|
+
if (addressToVerifyAgainst.classicAccount !== sourceAddressAndTag.classicAccount) {
|
|
65
|
+
throw new Error("address must match payment.source.address");
|
|
66
|
+
}
|
|
67
|
+
if (addressToVerifyAgainst.tag != null &&
|
|
68
|
+
sourceAddressAndTag.tag != null &&
|
|
69
|
+
addressToVerifyAgainst.tag !== sourceAddressAndTag.tag) {
|
|
70
|
+
throw new Error("address includes a tag that does not match payment.source.tag");
|
|
71
|
+
}
|
|
72
|
+
const destinationAddressAndTag = validateAndNormalizeAddress(payment.destination.address, payment.destination.tag);
|
|
73
|
+
if ((isMaxAdjustment(payment.source) && isMinAdjustment(payment.destination)) ||
|
|
74
|
+
(!isMaxAdjustment(payment.source) && !isMinAdjustment(payment.destination))) {
|
|
75
|
+
throw new Error("payment must specify either (source.maxAmount " +
|
|
76
|
+
"and destination.amount) or (source.amount and destination.minAmount)");
|
|
77
|
+
}
|
|
78
|
+
const destinationAmount = isMinAdjustment(payment.destination)
|
|
79
|
+
? payment.destination.minAmount
|
|
80
|
+
: payment.destination.amount;
|
|
81
|
+
const sourceAmount = isMaxAdjustment(payment.source) ? payment.source.maxAmount : payment.source.amount;
|
|
82
|
+
const amount = isMinAdjustment(payment.destination) && !isXRPToXRPPayment(payment)
|
|
83
|
+
? createMaximalAmount(destinationAmount)
|
|
84
|
+
: destinationAmount;
|
|
85
|
+
const txJSON = {
|
|
86
|
+
TransactionType: "Payment",
|
|
87
|
+
Account: sourceAddressAndTag.classicAccount,
|
|
88
|
+
Destination: destinationAddressAndTag.classicAccount,
|
|
89
|
+
Amount: (0, common_1.toRippledAmount)(amount),
|
|
90
|
+
Flags: 0,
|
|
91
|
+
};
|
|
92
|
+
if (payment.invoiceID != null) {
|
|
93
|
+
txJSON.InvoiceID = payment.invoiceID;
|
|
94
|
+
}
|
|
95
|
+
if (sourceAddressAndTag.tag != null) {
|
|
96
|
+
txJSON.SourceTag = sourceAddressAndTag.tag;
|
|
97
|
+
}
|
|
98
|
+
if (destinationAddressAndTag.tag != null) {
|
|
99
|
+
txJSON.DestinationTag = destinationAddressAndTag.tag;
|
|
100
|
+
}
|
|
101
|
+
if (payment.networkID != null) {
|
|
102
|
+
txJSON.NetworkID = payment.networkID;
|
|
103
|
+
}
|
|
104
|
+
if (payment.memos != null) {
|
|
105
|
+
txJSON.Memos = payment.memos.map(utils_1.convertMemo);
|
|
106
|
+
}
|
|
107
|
+
if (payment.noDirectRipple === true) {
|
|
108
|
+
txJSON.Flags |= xrpl_1.PaymentFlags.tfNoDirectRipple;
|
|
109
|
+
}
|
|
110
|
+
if (payment.limitQuality === true) {
|
|
111
|
+
txJSON.Flags |= xrpl_1.PaymentFlags.tfLimitQuality;
|
|
112
|
+
}
|
|
113
|
+
if (!isXRPToXRPPayment(payment)) {
|
|
114
|
+
if (payment.allowPartialPayment || isMinAdjustment(payment.destination)) {
|
|
115
|
+
txJSON.Flags |= xrpl_1.PaymentFlags.tfPartialPayment;
|
|
116
|
+
}
|
|
117
|
+
txJSON.SendMax = (0, common_1.toRippledAmount)(sourceAmount);
|
|
118
|
+
if (isMinAdjustment(payment.destination)) {
|
|
119
|
+
txJSON.DeliverMin = (0, common_1.toRippledAmount)(destinationAmount);
|
|
120
|
+
}
|
|
121
|
+
if (payment.paths != null) {
|
|
122
|
+
txJSON.Paths = JSON.parse(payment.paths);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (payment.allowPartialPayment === true) {
|
|
126
|
+
throw new Error("XRP to XRP payments cannot be partial payments");
|
|
127
|
+
}
|
|
128
|
+
return txJSON;
|
|
129
|
+
}
|
|
130
|
+
exports.createPaymentTransaction = createPaymentTransaction;
|