@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,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
4
|
+
var affected_objects_1 = require("./affected_objects");
|
|
5
|
+
Object.defineProperty(exports, "parseAffectedObjects", { enumerable: true, get: function () { return affected_objects_1.parseAffectedObjects; } });
|
|
6
|
+
var nftoken_changes_1 = require("./nftoken_changes");
|
|
7
|
+
Object.defineProperty(exports, "parseNFTokenChanges", { enumerable: true, get: function () { return nftoken_changes_1.parseNFTokenChanges; } });
|
|
8
|
+
var nftoken_offer_changes_1 = require("./nftoken_offer_changes");
|
|
9
|
+
Object.defineProperty(exports, "parseNFTokenOfferChanges", { enumerable: true, get: function () { return nftoken_offer_changes_1.parseNFTokenOfferChanges; } });
|
|
10
|
+
var balance_changes_1 = require("./balance_changes");
|
|
11
|
+
Object.defineProperty(exports, "parseBalanceChanges", { enumerable: true, get: function () { return balance_changes_1.parseBalanceChanges; } });
|
|
12
|
+
var locked_balance_changes_1 = require("./locked_balance_changes");
|
|
13
|
+
Object.defineProperty(exports, "parseLockedBalanceChanges", { enumerable: true, get: function () { return locked_balance_changes_1.parseLockedBalanceChanges; } });
|
|
14
|
+
var channel_changes_1 = require("./channel_changes");
|
|
15
|
+
Object.defineProperty(exports, "parseChannelChanges", { enumerable: true, get: function () { return channel_changes_1.parseChannelChanges; } });
|
|
16
|
+
var orderbook_changes_1 = require("./orderbook_changes");
|
|
17
|
+
Object.defineProperty(exports, "parseOrderbookChanges", { enumerable: true, get: function () { return orderbook_changes_1.parseOrderbookChanges; } });
|
|
@@ -0,0 +1,92 @@
|
|
|
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.parseFinalLockedBalances = exports.parseLockedBalanceChanges = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
const common_1 = require("../../common");
|
|
10
|
+
const utils_1 = require("../../v1/common/utils");
|
|
11
|
+
function groupByAddress(lockedBalanceChanges) {
|
|
12
|
+
const grouped = lodash_1.default.groupBy(lockedBalanceChanges, function (node) {
|
|
13
|
+
return node.address;
|
|
14
|
+
});
|
|
15
|
+
return lodash_1.default.mapValues(grouped, function (group) {
|
|
16
|
+
return lodash_1.default.map(group, function (node) {
|
|
17
|
+
return node.lockedBalance;
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function parseValue(value) {
|
|
22
|
+
return new bignumber_js_1.default(value.value || value);
|
|
23
|
+
}
|
|
24
|
+
function computeBalanceChange(node) {
|
|
25
|
+
var value = null;
|
|
26
|
+
if (node.newFields.LockedBalance) {
|
|
27
|
+
value = parseValue(node.newFields.LockedBalance);
|
|
28
|
+
}
|
|
29
|
+
else if (node.previousFields.LockedBalance && node.finalFields.LockedBalance) {
|
|
30
|
+
value = parseValue(node.finalFields.LockedBalance).minus(parseValue(node.previousFields.LockedBalance));
|
|
31
|
+
}
|
|
32
|
+
return value === null ? null : value.isZero() ? null : value;
|
|
33
|
+
}
|
|
34
|
+
function parseFinalBalance(node) {
|
|
35
|
+
if (node.newFields.LockedBalance) {
|
|
36
|
+
return parseValue(node.newFields.LockedBalance);
|
|
37
|
+
}
|
|
38
|
+
else if (node.finalFields.LockedBalance) {
|
|
39
|
+
return parseValue(node.finalFields.LockedBalance);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function parseXRPQuantity(node, valueParser) {
|
|
44
|
+
var value = valueParser(node);
|
|
45
|
+
if (value === null) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
address: node.finalFields.Account || node.newFields.Account,
|
|
50
|
+
lockedBalance: {
|
|
51
|
+
counterparty: "",
|
|
52
|
+
currency: "XRP",
|
|
53
|
+
value: (0, common_1.dropsToXrp)(value).toString(),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function parseTrustlineQuantity(node, valueParser) {
|
|
58
|
+
var value = valueParser(node);
|
|
59
|
+
if (value === null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
var fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
63
|
+
var result = {
|
|
64
|
+
address: fields.LowLimit.issuer,
|
|
65
|
+
lockedBalance: {
|
|
66
|
+
counterparty: fields.HighLimit.issuer,
|
|
67
|
+
currency: fields.LockedBalance.currency,
|
|
68
|
+
value: value.toString(),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
return [result];
|
|
72
|
+
}
|
|
73
|
+
function parseQuantities(metadata, valueParser) {
|
|
74
|
+
var values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
|
|
75
|
+
if (node.entryType === "AccountRoot") {
|
|
76
|
+
return [parseXRPQuantity(node, valueParser)];
|
|
77
|
+
}
|
|
78
|
+
else if (node.entryType === "RippleState") {
|
|
79
|
+
return parseTrustlineQuantity(node, valueParser);
|
|
80
|
+
}
|
|
81
|
+
return [];
|
|
82
|
+
});
|
|
83
|
+
return groupByAddress(lodash_1.default.compact(lodash_1.default.flatten(values)));
|
|
84
|
+
}
|
|
85
|
+
function parseLockedBalanceChanges(metadata) {
|
|
86
|
+
return parseQuantities(metadata, computeBalanceChange);
|
|
87
|
+
}
|
|
88
|
+
exports.parseLockedBalanceChanges = parseLockedBalanceChanges;
|
|
89
|
+
function parseFinalLockedBalances(metadata) {
|
|
90
|
+
return parseQuantities(metadata, parseFinalBalance);
|
|
91
|
+
}
|
|
92
|
+
exports.parseFinalLockedBalances = parseFinalLockedBalances;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseNFTokenChanges(tx: object): object;
|
|
@@ -0,0 +1,143 @@
|
|
|
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.parseNFTokenChanges = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const AddressCodec = require("ripple-address-codec");
|
|
9
|
+
const common_1 = require("../../common");
|
|
10
|
+
function parseNFTokenChanges(tx) {
|
|
11
|
+
return new NFTokenChanges(tx).call();
|
|
12
|
+
}
|
|
13
|
+
exports.parseNFTokenChanges = parseNFTokenChanges;
|
|
14
|
+
class NFTokenChanges {
|
|
15
|
+
constructor(tx) {
|
|
16
|
+
this.tx = tx;
|
|
17
|
+
this.changes = {};
|
|
18
|
+
this.affectedAccounts = [];
|
|
19
|
+
this.finalNFTokens = {};
|
|
20
|
+
this.previousNFTokens = {};
|
|
21
|
+
}
|
|
22
|
+
call() {
|
|
23
|
+
if (this.hasAffectedNodes() === false) {
|
|
24
|
+
return this.changes;
|
|
25
|
+
}
|
|
26
|
+
this.parseAffectedNodes();
|
|
27
|
+
this.parseNFTokensChanges();
|
|
28
|
+
return this.changes;
|
|
29
|
+
}
|
|
30
|
+
hasAffectedNodes() {
|
|
31
|
+
if (this.tx.meta?.AffectedNodes === undefined) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (this.tx.meta?.AffectedNodes?.length === 0) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
addChange(account, change) {
|
|
40
|
+
if (!this.changes[account]) {
|
|
41
|
+
this.changes[account] = [];
|
|
42
|
+
}
|
|
43
|
+
this.changes[account].push((0, common_1.removeUndefined)(change));
|
|
44
|
+
}
|
|
45
|
+
parseAffectedNodes() {
|
|
46
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
47
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
48
|
+
if (node?.LedgerEntryType === "NFTokenPage" && node?.LedgerIndex) {
|
|
49
|
+
const account = AddressCodec.encodeAccountID(Buffer.from(node?.LedgerIndex.slice(0, 40), "hex"));
|
|
50
|
+
if (this.affectedAccounts.includes(account) === false) {
|
|
51
|
+
this.affectedAccounts.push(account);
|
|
52
|
+
}
|
|
53
|
+
if (affectedNode.CreatedNode) {
|
|
54
|
+
this.parseFinalNFTokens(account, node.NewFields?.NFTokens);
|
|
55
|
+
}
|
|
56
|
+
if ((affectedNode.ModifiedNode || affectedNode.DeletedNode) && Array.isArray(node.PreviousFields?.NFTokens)) {
|
|
57
|
+
this.parseFinalNFTokens(account, node.FinalFields?.NFTokens);
|
|
58
|
+
this.parsePreviousNFTokens(account, node.PreviousFields?.NFTokens);
|
|
59
|
+
}
|
|
60
|
+
if (affectedNode.DeletedNode && node.PreviousFields === undefined) {
|
|
61
|
+
this.parsePreviousNFTokens(account, node.FinalFields?.NFTokens);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
parseFinalNFTokens(account, NFTokens) {
|
|
67
|
+
if (this.finalNFTokens[account] === undefined) {
|
|
68
|
+
this.finalNFTokens[account] = [];
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(NFTokens)) {
|
|
71
|
+
this.finalNFTokens[account] = lodash_1.default.concat(this.finalNFTokens[account], NFTokens);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
parsePreviousNFTokens(account, NFTokens) {
|
|
75
|
+
if (this.previousNFTokens[account] === undefined) {
|
|
76
|
+
this.previousNFTokens[account] = [];
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(NFTokens)) {
|
|
79
|
+
this.previousNFTokens[account] = lodash_1.default.concat(this.previousNFTokens[account], NFTokens);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
parseNFTokensChanges() {
|
|
83
|
+
for (const account of this.affectedAccounts) {
|
|
84
|
+
let finalTokens = [];
|
|
85
|
+
if (Array.isArray(this.finalNFTokens[account])) {
|
|
86
|
+
finalTokens = this.finalNFTokens[account].map((NFToken) => NFToken.NFToken.NFTokenID);
|
|
87
|
+
finalTokens = [...new Set(finalTokens)];
|
|
88
|
+
}
|
|
89
|
+
let previousTokens = [];
|
|
90
|
+
if (Array.isArray(this.previousNFTokens[account])) {
|
|
91
|
+
previousTokens = this.previousNFTokens[account].map((NFToken) => NFToken.NFToken.NFTokenID);
|
|
92
|
+
previousTokens = [...new Set(previousTokens)];
|
|
93
|
+
}
|
|
94
|
+
const added = lodash_1.default.difference(finalTokens, previousTokens);
|
|
95
|
+
const removed = lodash_1.default.difference(previousTokens, finalTokens);
|
|
96
|
+
for (const nftokenID of added) {
|
|
97
|
+
const uri = this.findNFTokenUri(nftokenID);
|
|
98
|
+
this.addChange(account, {
|
|
99
|
+
status: "added",
|
|
100
|
+
nftokenID,
|
|
101
|
+
uri,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
for (const nftokenID of removed) {
|
|
105
|
+
const uri = this.findNFTokenUri(nftokenID);
|
|
106
|
+
this.addChange(account, {
|
|
107
|
+
status: "removed",
|
|
108
|
+
nftokenID,
|
|
109
|
+
uri,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
findNFTokenUri(nftokenID) {
|
|
115
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
116
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
117
|
+
if (node?.LedgerEntryType === "NFTokenPage") {
|
|
118
|
+
if (Array.isArray(node.NewFields?.NFTokens)) {
|
|
119
|
+
for (const tokenNode of node.NewFields?.NFTokens) {
|
|
120
|
+
if (tokenNode.NFToken.NFTokenID === nftokenID) {
|
|
121
|
+
return tokenNode.NFToken.URI;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (Array.isArray(node.FinalFields?.NFTokens)) {
|
|
126
|
+
for (const tokenNode of node.FinalFields?.NFTokens) {
|
|
127
|
+
if (tokenNode.NFToken.NFTokenID === nftokenID) {
|
|
128
|
+
return tokenNode.NFToken.URI;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(node.PreviousFields?.NFTokens)) {
|
|
133
|
+
for (const tokenNode of node.PreviousFields?.NFTokens) {
|
|
134
|
+
if (tokenNode.NFToken.NFTokenID === nftokenID) {
|
|
135
|
+
return tokenNode.NFToken.URI;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseNFTokenOfferChanges = void 0;
|
|
4
|
+
const ledger_1 = require("../../models/ledger");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
function parseNFTokenOfferChanges(tx) {
|
|
7
|
+
return new NFTokenOfferChanges(tx).call();
|
|
8
|
+
}
|
|
9
|
+
exports.parseNFTokenOfferChanges = parseNFTokenOfferChanges;
|
|
10
|
+
class NFTokenOfferChanges {
|
|
11
|
+
constructor(tx) {
|
|
12
|
+
this.tx = tx;
|
|
13
|
+
this.changes = {};
|
|
14
|
+
}
|
|
15
|
+
call() {
|
|
16
|
+
if (this.hasAffectedNodes() === false) {
|
|
17
|
+
return this.changes;
|
|
18
|
+
}
|
|
19
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
20
|
+
this.parseAffectedNode(affectedNode);
|
|
21
|
+
}
|
|
22
|
+
return this.changes;
|
|
23
|
+
}
|
|
24
|
+
addChange(account, change) {
|
|
25
|
+
if (!this.changes[account]) {
|
|
26
|
+
this.changes[account] = [];
|
|
27
|
+
}
|
|
28
|
+
this.changes[account].push((0, common_1.removeUndefined)(change));
|
|
29
|
+
}
|
|
30
|
+
hasAffectedNodes() {
|
|
31
|
+
if (this.tx.meta?.AffectedNodes === undefined) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (this.tx.meta?.AffectedNodes?.length === 0) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
parseAffectedNode(affectedNode) {
|
|
40
|
+
if (this.isNFTokensCreateOfferNode(affectedNode)) {
|
|
41
|
+
this.parseNFTokensCreateOfferNode(affectedNode);
|
|
42
|
+
}
|
|
43
|
+
else if (this.isNFTokensDeleteOfferNode(affectedNode)) {
|
|
44
|
+
this.parseNFTokensDeleteOfferNode(affectedNode);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
isNFTokensCreateOfferNode(affectedNode) {
|
|
48
|
+
return affectedNode.CreatedNode?.LedgerEntryType === "NFTokenOffer" && affectedNode.CreatedNode?.NewFields;
|
|
49
|
+
}
|
|
50
|
+
parseNFTokensCreateOfferNode(affectedNode) {
|
|
51
|
+
const status = "created";
|
|
52
|
+
const amount = affectedNode.CreatedNode.NewFields.Amount;
|
|
53
|
+
const flags = affectedNode.CreatedNode.NewFields.Flags;
|
|
54
|
+
const nftokenID = affectedNode.CreatedNode.NewFields.NFTokenID;
|
|
55
|
+
const owner = affectedNode.CreatedNode.NewFields.Owner;
|
|
56
|
+
const index = affectedNode.CreatedNode.LedgerIndex;
|
|
57
|
+
const destination = affectedNode.CreatedNode.NewFields.Destination;
|
|
58
|
+
const prevTxHash = affectedNode.CreatedNode.NewFields.PreviousTxnID;
|
|
59
|
+
const prevLedgerIndex = affectedNode.CreatedNode.NewFields.PreviousTxnLgrSeq;
|
|
60
|
+
let expiration = affectedNode.CreatedNode.NewFields.Expiration;
|
|
61
|
+
if (typeof expiration === "number") {
|
|
62
|
+
expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
|
|
63
|
+
}
|
|
64
|
+
this.addChange(this.tx.Account, {
|
|
65
|
+
status,
|
|
66
|
+
amount,
|
|
67
|
+
flags,
|
|
68
|
+
nftokenID,
|
|
69
|
+
owner,
|
|
70
|
+
destination,
|
|
71
|
+
expiration,
|
|
72
|
+
index,
|
|
73
|
+
prevTxHash,
|
|
74
|
+
prevLedgerIndex,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
isNFTokensDeleteOfferNode(affectedNode) {
|
|
78
|
+
return affectedNode.DeletedNode?.LedgerEntryType === "NFTokenOffer" && affectedNode.DeletedNode?.FinalFields;
|
|
79
|
+
}
|
|
80
|
+
parseNFTokensDeleteOfferNode(affectedNode) {
|
|
81
|
+
const status = "deleted";
|
|
82
|
+
const amount = affectedNode.DeletedNode.FinalFields.Amount;
|
|
83
|
+
const flags = affectedNode.DeletedNode.FinalFields.Flags;
|
|
84
|
+
const nftokenID = affectedNode.DeletedNode.FinalFields.NFTokenID;
|
|
85
|
+
const owner = affectedNode.DeletedNode.FinalFields.Owner;
|
|
86
|
+
const index = affectedNode.DeletedNode.LedgerIndex;
|
|
87
|
+
const destination = affectedNode.DeletedNode.FinalFields.Destination;
|
|
88
|
+
const prevTxHash = affectedNode.DeletedNode.FinalFields.PreviousTxnID;
|
|
89
|
+
const prevLedgerIndex = affectedNode.DeletedNode.FinalFields.PreviousTxnLgrSeq;
|
|
90
|
+
let expiration = affectedNode.DeletedNode.FinalFields.Expiration;
|
|
91
|
+
if (typeof expiration === "number") {
|
|
92
|
+
expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
|
|
93
|
+
}
|
|
94
|
+
this.addChange(owner, {
|
|
95
|
+
status,
|
|
96
|
+
amount,
|
|
97
|
+
flags,
|
|
98
|
+
nftokenID,
|
|
99
|
+
owner,
|
|
100
|
+
destination,
|
|
101
|
+
expiration,
|
|
102
|
+
index,
|
|
103
|
+
prevTxHash,
|
|
104
|
+
prevLedgerIndex,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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.parseOrderbookChanges = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
9
|
+
const BigNumber = bignumber_js_1.BigNumber.clone({ DECIMAL_PLACES: 40 });
|
|
10
|
+
const common_1 = require("../../common");
|
|
11
|
+
const models_1 = require("../../models");
|
|
12
|
+
const utils_1 = require("../../v1/common/utils");
|
|
13
|
+
const orderbook_quality_1 = require("./orderbook_quality");
|
|
14
|
+
const currency_amount_1 = __importDefault(require("../ledger/currency-amount"));
|
|
15
|
+
const lsfSell = 0x00020000;
|
|
16
|
+
function convertOrderChange(order) {
|
|
17
|
+
var takerGets = order.taker_gets;
|
|
18
|
+
var takerPays = order.taker_pays;
|
|
19
|
+
var direction = order.sell ? "sell" : "buy";
|
|
20
|
+
var quantity = direction === "buy" ? takerPays : takerGets;
|
|
21
|
+
var totalPrice = direction === "buy" ? takerGets : takerPays;
|
|
22
|
+
return (0, common_1.removeUndefined)({
|
|
23
|
+
direction: direction,
|
|
24
|
+
quantity: quantity,
|
|
25
|
+
totalPrice: totalPrice,
|
|
26
|
+
sequence: order.sequence,
|
|
27
|
+
status: order.status,
|
|
28
|
+
makerExchangeRate: order.quality,
|
|
29
|
+
expirationTime: order.expiration,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getExpirationTime(node) {
|
|
33
|
+
var expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
|
|
34
|
+
if (expirationTime === undefined) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return new Date((0, models_1.ledgerTimeToTimestamp)(expirationTime)).toISOString();
|
|
38
|
+
}
|
|
39
|
+
function getQuality(node) {
|
|
40
|
+
var takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
|
|
41
|
+
var takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
|
|
42
|
+
var takerGetsCurrency = takerGets.currency || "XRP";
|
|
43
|
+
var takerPaysCurrency = takerPays.currency || "XRP";
|
|
44
|
+
var bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
|
|
45
|
+
var qualityHex = bookDirectory.substring(bookDirectory.length - 16);
|
|
46
|
+
return (0, orderbook_quality_1.parseOrderbookQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
|
|
47
|
+
}
|
|
48
|
+
function parseOrderStatus(node) {
|
|
49
|
+
if (node.diffType === "CreatedNode") {
|
|
50
|
+
return "created";
|
|
51
|
+
}
|
|
52
|
+
if (node.diffType === "ModifiedNode") {
|
|
53
|
+
return "partially-filled";
|
|
54
|
+
}
|
|
55
|
+
if (node.diffType === "DeletedNode") {
|
|
56
|
+
if (node.previousFields.hasOwnProperty("TakerPays")) {
|
|
57
|
+
return "filled";
|
|
58
|
+
}
|
|
59
|
+
return "cancelled";
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
function calculateDelta(finalAmount, previousAmount) {
|
|
64
|
+
if (previousAmount) {
|
|
65
|
+
var finalValue = new BigNumber(finalAmount.value);
|
|
66
|
+
var previousValue = new BigNumber(previousAmount.value);
|
|
67
|
+
return finalValue.minus(previousValue).abs().toString();
|
|
68
|
+
}
|
|
69
|
+
return "0";
|
|
70
|
+
}
|
|
71
|
+
function parseChangeAmount(node, type) {
|
|
72
|
+
var status = parseOrderStatus(node);
|
|
73
|
+
if (status === "cancelled") {
|
|
74
|
+
return (0, currency_amount_1.default)(node.finalFields[type]);
|
|
75
|
+
}
|
|
76
|
+
else if (status === "created") {
|
|
77
|
+
return (0, currency_amount_1.default)(node.newFields[type]);
|
|
78
|
+
}
|
|
79
|
+
var finalAmount = (0, currency_amount_1.default)(node.finalFields[type]);
|
|
80
|
+
var previousAmount = (0, currency_amount_1.default)(node.previousFields[type]);
|
|
81
|
+
var value = calculateDelta(finalAmount, previousAmount);
|
|
82
|
+
return lodash_1.default.assign({}, finalAmount, { value: value });
|
|
83
|
+
}
|
|
84
|
+
function parseOrderChange(node) {
|
|
85
|
+
var orderChange = convertOrderChange({
|
|
86
|
+
taker_pays: parseChangeAmount(node, "TakerPays"),
|
|
87
|
+
taker_gets: parseChangeAmount(node, "TakerGets"),
|
|
88
|
+
sell: (node.finalFields.Flags & lsfSell) !== 0,
|
|
89
|
+
sequence: node.finalFields.Sequence || node.newFields.Sequence,
|
|
90
|
+
status: parseOrderStatus(node),
|
|
91
|
+
quality: getQuality(node),
|
|
92
|
+
expiration: getExpirationTime(node),
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(orderChange, "account", {
|
|
95
|
+
value: node.finalFields.Account || node.newFields.Account,
|
|
96
|
+
});
|
|
97
|
+
return orderChange;
|
|
98
|
+
}
|
|
99
|
+
function groupByAddress(orderChanges) {
|
|
100
|
+
return lodash_1.default.groupBy(orderChanges, function (change) {
|
|
101
|
+
return change.account;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function parseOrderbookChanges(metadata) {
|
|
105
|
+
var nodes = (0, utils_1.normalizeNodes)(metadata);
|
|
106
|
+
var orderChanges = lodash_1.default.map(lodash_1.default.filter(nodes, function (node) {
|
|
107
|
+
return node.entryType === "Offer";
|
|
108
|
+
}), parseOrderChange);
|
|
109
|
+
return groupByAddress(orderChanges);
|
|
110
|
+
}
|
|
111
|
+
exports.parseOrderbookChanges = parseOrderbookChanges;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
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.parseOrderbookQuality = void 0;
|
|
30
|
+
const assert = __importStar(require("assert"));
|
|
31
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
32
|
+
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
|
|
33
|
+
var numeratorShift = takerPaysCurrency === "XRP" ? -6 : 0;
|
|
34
|
+
var denominatorShift = takerGetsCurrency === "XRP" ? -6 : 0;
|
|
35
|
+
var shift = numeratorShift - denominatorShift;
|
|
36
|
+
return shift === 0 ? new bignumber_js_1.default(quality).toString() : new bignumber_js_1.default(quality).shiftedBy(shift).toString();
|
|
37
|
+
}
|
|
38
|
+
function parseOrderbookQuality(qualityHex, takerGetsCurrency, takerPaysCurrency) {
|
|
39
|
+
assert.ok(qualityHex.length === 16);
|
|
40
|
+
var mantissa = new bignumber_js_1.default(qualityHex.substring(2), 16);
|
|
41
|
+
var offset = parseInt(qualityHex.substring(0, 2), 16) - 100;
|
|
42
|
+
var quality = mantissa.toString() + "e" + offset.toString();
|
|
43
|
+
return adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency);
|
|
44
|
+
}
|
|
45
|
+
exports.parseOrderbookQuality = parseOrderbookQuality;
|
|
@@ -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
|
+
exports.parseOutcome = void 0;
|
|
7
|
+
const index_1 = require("./outcome/index");
|
|
8
|
+
const amount_1 = __importDefault(require("./ledger/amount"));
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const common_1 = require("../common");
|
|
11
|
+
function removeEmptyCounterparty(amount) {
|
|
12
|
+
if (amount.counterparty === "") {
|
|
13
|
+
delete amount.counterparty;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function removeEmptyCounterpartyInBalanceChanges(balanceChanges) {
|
|
17
|
+
Object.entries(balanceChanges).forEach(([_, changes]) => {
|
|
18
|
+
changes.forEach(removeEmptyCounterparty);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function removeEmptyCounterpartyInOrderbookChanges(orderbookChanges) {
|
|
22
|
+
Object.entries(orderbookChanges).forEach(([_, changes]) => {
|
|
23
|
+
changes.forEach((change) => {
|
|
24
|
+
Object.entries(change).forEach(removeEmptyCounterparty);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function parseDeliveredAmount(tx) {
|
|
29
|
+
if (tx.TransactionType !== "Payment" || 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, index_1.parseBalanceChanges)(metadata);
|
|
55
|
+
const lockedBalanceChanges = (0, index_1.parseLockedBalanceChanges)(metadata);
|
|
56
|
+
const orderbookChanges = (0, index_1.parseOrderbookChanges)(metadata);
|
|
57
|
+
const channelChanges = (0, index_1.parseChannelChanges)(metadata);
|
|
58
|
+
const nftokenChanges = (0, index_1.parseNFTokenChanges)(tx);
|
|
59
|
+
const nftokenOfferChanges = (0, index_1.parseNFTokenOfferChanges)(tx);
|
|
60
|
+
const affectedObjects = (0, index_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.parseOutcome = parseOutcome;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 ripple_address_codec_1 = require("ripple-address-codec");
|
|
32
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
33
|
+
function parseAccountDelete(tx) {
|
|
34
|
+
assert.ok(tx.TransactionType === "AccountDelete");
|
|
35
|
+
return (0, common_1.removeUndefined)({
|
|
36
|
+
memos: (0, memos_1.default)(tx),
|
|
37
|
+
destination: tx.Destination,
|
|
38
|
+
destinationTag: tx.DestinationTag,
|
|
39
|
+
destinationXAddress: (0, ripple_address_codec_1.classicAddressToXAddress)(tx.Destination, tx.DestinationTag == null ? false : tx.DestinationTag, false),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.default = parseAccountDelete;
|