@bithomp/xrpl-api 3.7.30 → 3.7.37
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/lib/connection.js +5 -3
- package/lib/parse/outcome/orderbook_changes.js +5 -4
- package/lib/parse/specification/offer-create.js +1 -0
- package/lib/src/base58.d.ts +2 -0
- package/lib/src/base58.js +32 -0
- package/lib/src/client.d.ts +25 -0
- package/lib/src/client.js +192 -0
- package/lib/src/common/errors/index.d.ts +3 -0
- package/lib/src/common/errors/index.js +7 -0
- package/lib/src/common/errors/validation_error.d.ts +4 -0
- package/lib/src/common/errors/validation_error.js +7 -0
- package/lib/src/common/errors/xrpl_api_error.d.ts +9 -0
- package/lib/src/common/errors/xrpl_api_error.js +28 -0
- package/lib/src/common/index.d.ts +9 -0
- package/lib/src/common/index.js +57 -0
- package/lib/src/common/sha512Half.d.ts +2 -0
- package/lib/src/common/sha512Half.js +12 -0
- package/lib/src/common/utils.d.ts +14 -0
- package/lib/src/common/utils.js +147 -0
- package/lib/src/connection.d.ts +76 -0
- package/lib/src/connection.js +653 -0
- package/lib/src/faucet.d.ts +58 -0
- package/lib/src/faucet.js +129 -0
- package/lib/src/index.d.ts +9 -0
- package/lib/src/index.js +45 -0
- package/lib/src/ledger/account_info.d.ts +16 -0
- package/lib/src/ledger/account_info.js +112 -0
- package/lib/src/ledger/account_lines.d.ts +11 -0
- package/lib/src/ledger/account_lines.js +90 -0
- package/lib/src/ledger/account_namespace.d.ts +7 -0
- package/lib/src/ledger/account_namespace.js +72 -0
- package/lib/src/ledger/account_nfts.d.ts +21 -0
- package/lib/src/ledger/account_nfts.js +199 -0
- package/lib/src/ledger/account_objects.d.ts +44 -0
- package/lib/src/ledger/account_objects.js +222 -0
- package/lib/src/ledger/account_offers.d.ts +13 -0
- package/lib/src/ledger/account_offers.js +142 -0
- package/lib/src/ledger/account_tx.d.ts +37 -0
- package/lib/src/ledger/account_tx.js +376 -0
- package/lib/src/ledger/amm_info.d.ts +13 -0
- package/lib/src/ledger/amm_info.js +114 -0
- package/lib/src/ledger/book_offers.d.ts +15 -0
- package/lib/src/ledger/book_offers.js +102 -0
- package/lib/src/ledger/currency.d.ts +28 -0
- package/lib/src/ledger/currency.js +250 -0
- package/lib/src/ledger/fee.d.ts +13 -0
- package/lib/src/ledger/fee.js +99 -0
- package/lib/src/ledger/gateway_balances.d.ts +16 -0
- package/lib/src/ledger/gateway_balances.js +119 -0
- package/lib/src/ledger/index.d.ts +21 -0
- package/lib/src/ledger/index.js +37 -0
- package/lib/src/ledger/ledger.d.ts +16 -0
- package/lib/src/ledger/ledger.js +99 -0
- package/lib/src/ledger/ledger_entry.d.ts +16 -0
- package/lib/src/ledger/ledger_entry.js +118 -0
- package/lib/src/ledger/manifest.d.ts +8 -0
- package/lib/src/ledger/manifest.js +67 -0
- package/lib/src/ledger/nft_info.d.ts +4 -0
- package/lib/src/ledger/nft_info.js +67 -0
- package/lib/src/ledger/server_definitions.d.ts +7 -0
- package/lib/src/ledger/server_definitions.js +65 -0
- package/lib/src/ledger/server_info.d.ts +8 -0
- package/lib/src/ledger/server_info.js +65 -0
- package/lib/src/ledger/transaction.d.ts +47 -0
- package/lib/src/ledger/transaction.js +440 -0
- package/lib/src/ledger/vl-v2.d.ts +3 -0
- package/lib/src/ledger/vl-v2.js +124 -0
- package/lib/src/ledger/vl.d.ts +4 -0
- package/lib/src/ledger/vl.js +131 -0
- package/lib/src/models/account_info.d.ts +184 -0
- package/lib/src/models/account_info.js +139 -0
- package/lib/src/models/account_lines.d.ts +26 -0
- package/lib/src/models/account_lines.js +2 -0
- package/lib/src/models/account_namespace.d.ts +16 -0
- package/lib/src/models/account_namespace.js +2 -0
- package/lib/src/models/account_nfts.d.ts +20 -0
- package/lib/src/models/account_nfts.js +92 -0
- package/lib/src/models/account_object.d.ts +61 -0
- package/lib/src/models/account_object.js +125 -0
- package/lib/src/models/account_offers.d.ts +9 -0
- package/lib/src/models/account_offers.js +2 -0
- package/lib/src/models/account_uritokens.d.ts +11 -0
- package/lib/src/models/account_uritokens.js +2 -0
- package/lib/src/models/amm_info.d.ts +1 -0
- package/lib/src/models/amm_info.js +4 -0
- package/lib/src/models/base_model.d.ts +15 -0
- package/lib/src/models/base_model.js +2 -0
- package/lib/src/models/book_offers.d.ts +9 -0
- package/lib/src/models/book_offers.js +40 -0
- package/lib/src/models/gateway_balances.d.ts +19 -0
- package/lib/src/models/gateway_balances.js +2 -0
- package/lib/src/models/index.d.ts +38 -0
- package/lib/src/models/index.js +82 -0
- package/lib/src/models/ledger.d.ts +7 -0
- package/lib/src/models/ledger.js +20 -0
- package/lib/src/models/manifest.d.ts +25 -0
- package/lib/src/models/manifest.js +199 -0
- package/lib/src/models/mptoken.d.ts +7 -0
- package/lib/src/models/mptoken.js +59 -0
- package/lib/src/models/path_find.d.ts +11 -0
- package/lib/src/models/path_find.js +2 -0
- package/lib/src/models/server_definitions.d.ts +33 -0
- package/lib/src/models/server_definitions.js +2 -0
- package/lib/src/models/transaction.d.ts +52 -0
- package/lib/src/models/transaction.js +141 -0
- package/lib/src/models/transactions/CronSet.d.ts +3 -0
- package/lib/src/models/transactions/CronSet.js +2 -0
- package/lib/src/models/transactions/SetRemarks.d.ts +3 -0
- package/lib/src/models/transactions/SetRemarks.js +2 -0
- package/lib/src/models/transactions/URITokenMint.d.ts +3 -0
- package/lib/src/models/transactions/URITokenMint.js +2 -0
- package/lib/src/models/vl.d.ts +82 -0
- package/lib/src/models/vl.js +498 -0
- package/lib/src/parse/index.d.ts +6 -0
- package/lib/src/parse/index.js +46 -0
- package/lib/src/parse/ledger/account-fields.d.ts +5 -0
- package/lib/src/parse/ledger/account-fields.js +43 -0
- package/lib/src/parse/ledger/account-info.d.ts +3 -0
- package/lib/src/parse/ledger/account-info.js +15 -0
- package/lib/src/parse/ledger/account-order.d.ts +18 -0
- package/lib/src/parse/ledger/account-order.js +48 -0
- package/lib/src/parse/ledger/account-settings-flags.d.ts +2 -0
- package/lib/src/parse/ledger/account-settings-flags.js +77 -0
- package/lib/src/parse/ledger/account.d.ts +1 -0
- package/lib/src/parse/ledger/account.js +7 -0
- package/lib/src/parse/ledger/amount.d.ts +3 -0
- package/lib/src/parse/ledger/amount.js +25 -0
- package/lib/src/parse/ledger/asset.d.ts +3 -0
- package/lib/src/parse/ledger/asset.js +19 -0
- package/lib/src/parse/ledger/auth-accounts.d.ts +3 -0
- package/lib/src/parse/ledger/auth-accounts.js +18 -0
- package/lib/src/parse/ledger/credential-flags.d.ts +5 -0
- package/lib/src/parse/ledger/credential-flags.js +8 -0
- package/lib/src/parse/ledger/credential.d.ts +3 -0
- package/lib/src/parse/ledger/credential.js +13 -0
- package/lib/src/parse/ledger/currency-amount.d.ts +3 -0
- package/lib/src/parse/ledger/currency-amount.js +13 -0
- package/lib/src/parse/ledger/delegate.d.ts +2 -0
- package/lib/src/parse/ledger/delegate.js +11 -0
- package/lib/src/parse/ledger/destination.d.ts +2 -0
- package/lib/src/parse/ledger/destination.js +12 -0
- package/lib/src/parse/ledger/emit_details.d.ts +2 -0
- package/lib/src/parse/ledger/emit_details.js +14 -0
- package/lib/src/parse/ledger/flags.d.ts +4 -0
- package/lib/src/parse/ledger/flags.js +17 -0
- package/lib/src/parse/ledger/gateway-balances.d.ts +3 -0
- package/lib/src/parse/ledger/gateway-balances.js +31 -0
- package/lib/src/parse/ledger/genesis-mints.d.ts +2 -0
- package/lib/src/parse/ledger/genesis-mints.js +17 -0
- package/lib/src/parse/ledger/import.d.ts +2 -0
- package/lib/src/parse/ledger/import.js +40 -0
- package/lib/src/parse/ledger/index.d.ts +6 -0
- package/lib/src/parse/ledger/index.js +29 -0
- package/lib/src/parse/ledger/ledger.d.ts +2 -0
- package/lib/src/parse/ledger/ledger.js +98 -0
- package/lib/src/parse/ledger/memos.d.ts +4 -0
- package/lib/src/parse/ledger/memos.js +27 -0
- package/lib/src/parse/ledger/mptoken-flags.d.ts +6 -0
- package/lib/src/parse/ledger/mptoken-flags.js +8 -0
- package/lib/src/parse/ledger/mptoken-issuance-flags.d.ts +6 -0
- package/lib/src/parse/ledger/mptoken-issuance-flags.js +8 -0
- package/lib/src/parse/ledger/nftoken-flags.d.ts +5 -0
- package/lib/src/parse/ledger/nftoken-flags.js +8 -0
- package/lib/src/parse/ledger/nftoken-offer-flags.d.ts +5 -0
- package/lib/src/parse/ledger/nftoken-offer-flags.js +8 -0
- package/lib/src/parse/ledger/offer-flags.d.ts +5 -0
- package/lib/src/parse/ledger/offer-flags.js +8 -0
- package/lib/src/parse/ledger/orderbook-order.d.ts +21 -0
- package/lib/src/parse/ledger/orderbook-order.js +42 -0
- package/lib/src/parse/ledger/permissions.d.ts +2 -0
- package/lib/src/parse/ledger/permissions.js +9 -0
- package/lib/src/parse/ledger/regular-key.d.ts +2 -0
- package/lib/src/parse/ledger/regular-key.js +14 -0
- package/lib/src/parse/ledger/remark-flags.d.ts +5 -0
- package/lib/src/parse/ledger/remark-flags.js +8 -0
- package/lib/src/parse/ledger/remarks.d.ts +3 -0
- package/lib/src/parse/ledger/remarks.js +37 -0
- package/lib/src/parse/ledger/signers.d.ts +2 -0
- package/lib/src/parse/ledger/signers.js +12 -0
- package/lib/src/parse/ledger/source.d.ts +3 -0
- package/lib/src/parse/ledger/source.js +28 -0
- package/lib/src/parse/ledger/trustline-flags.d.ts +5 -0
- package/lib/src/parse/ledger/trustline-flags.js +8 -0
- package/lib/src/parse/ledger/tx-account-set-flags.d.ts +4 -0
- package/lib/src/parse/ledger/tx-account-set-flags.js +36 -0
- package/lib/src/parse/ledger/tx-amm-clawback-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-clawback-flags.js +8 -0
- package/lib/src/parse/ledger/tx-amm-deposit-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-deposit-flags.js +8 -0
- package/lib/src/parse/ledger/tx-amm-withdraw-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-amm-withdraw-flags.js +8 -0
- package/lib/src/parse/ledger/tx-batch-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-batch-flags.js +8 -0
- package/lib/src/parse/ledger/tx-cron-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-cron-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-global-flags.d.ts +5 -0
- package/lib/src/parse/ledger/tx-global-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-authorize-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-authorize-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-mptoken-issuance-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-nftoken-mint-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-nftoken-mint-flags.js +8 -0
- package/lib/src/parse/ledger/tx-nftoken-offer-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-nftoken-offer-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-offer-create-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-offer-create-flags.js +8 -0
- package/lib/src/parse/ledger/tx-payment-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-payment-flags.js +8 -0
- package/lib/src/parse/ledger/tx-trust-set-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-trust-set-flags.js +8 -0
- package/lib/src/parse/ledger/tx-uritoken-mint-flags.d.ts +6 -0
- package/lib/src/parse/ledger/tx-uritoken-mint-flags.js +8 -0
- package/lib/src/parse/ledger/uritoken-flags.d.ts +5 -0
- package/lib/src/parse/ledger/uritoken-flags.js +8 -0
- package/lib/src/parse/mptoken_normalize.d.ts +5 -0
- package/lib/src/parse/mptoken_normalize.js +215 -0
- package/lib/src/parse/outcome/account_setting_changes.d.ts +4 -0
- package/lib/src/parse/outcome/account_setting_changes.js +67 -0
- package/lib/src/parse/outcome/affected_objects.d.ts +7 -0
- package/lib/src/parse/outcome/affected_objects.js +147 -0
- package/lib/src/parse/outcome/amendment_changes.d.ts +8 -0
- package/lib/src/parse/outcome/amendment_changes.js +84 -0
- package/lib/src/parse/outcome/amm_changes.d.ts +52 -0
- package/lib/src/parse/outcome/amm_changes.js +214 -0
- package/lib/src/parse/outcome/balance_changes.d.ts +24 -0
- package/lib/src/parse/outcome/balance_changes.js +337 -0
- package/lib/src/parse/outcome/channel_changes.d.ts +20 -0
- package/lib/src/parse/outcome/channel_changes.js +70 -0
- package/lib/src/parse/outcome/check_changes.d.ts +17 -0
- package/lib/src/parse/outcome/check_changes.js +63 -0
- package/lib/src/parse/outcome/credential_changes.d.ts +16 -0
- package/lib/src/parse/outcome/credential_changes.js +59 -0
- package/lib/src/parse/outcome/cron_changes.d.ts +13 -0
- package/lib/src/parse/outcome/cron_changes.js +72 -0
- package/lib/src/parse/outcome/delegate_changes.d.ts +12 -0
- package/lib/src/parse/outcome/delegate_changes.js +59 -0
- package/lib/src/parse/outcome/delivered_amount.d.ts +4 -0
- package/lib/src/parse/outcome/delivered_amount.js +63 -0
- package/lib/src/parse/outcome/did_changes.d.ts +14 -0
- package/lib/src/parse/outcome/did_changes.js +50 -0
- package/lib/src/parse/outcome/emitted_txns.d.ts +9 -0
- package/lib/src/parse/outcome/emitted_txns.js +57 -0
- package/lib/src/parse/outcome/escrow_changes.d.ts +16 -0
- package/lib/src/parse/outcome/escrow_changes.js +75 -0
- package/lib/src/parse/outcome/hooks_executions.d.ts +13 -0
- package/lib/src/parse/outcome/hooks_executions.js +42 -0
- package/lib/src/parse/outcome/index.d.ts +26 -0
- package/lib/src/parse/outcome/index.js +55 -0
- package/lib/src/parse/outcome/locked_balance_changes.d.ts +20 -0
- package/lib/src/parse/outcome/locked_balance_changes.js +117 -0
- package/lib/src/parse/outcome/mptoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/mptoken_changes.js +113 -0
- package/lib/src/parse/outcome/mptoken_issuance_changes.d.ts +1 -0
- package/lib/src/parse/outcome/mptoken_issuance_changes.js +119 -0
- package/lib/src/parse/outcome/nftoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/nftoken_changes.js +234 -0
- package/lib/src/parse/outcome/nftoken_offer_changes.d.ts +2 -0
- package/lib/src/parse/outcome/nftoken_offer_changes.js +106 -0
- package/lib/src/parse/outcome/oracle_changes.d.ts +29 -0
- package/lib/src/parse/outcome/oracle_changes.js +150 -0
- package/lib/src/parse/outcome/orderbook_changes.d.ts +21 -0
- package/lib/src/parse/outcome/orderbook_changes.js +108 -0
- package/lib/src/parse/outcome/orderbook_quality.d.ts +2 -0
- package/lib/src/parse/outcome/orderbook_quality.js +49 -0
- package/lib/src/parse/outcome/remarks_changes.d.ts +14 -0
- package/lib/src/parse/outcome/remarks_changes.js +68 -0
- package/lib/src/parse/outcome/unl_report_changes.d.ts +13 -0
- package/lib/src/parse/outcome/unl_report_changes.js +48 -0
- package/lib/src/parse/outcome/uritoken_changes.d.ts +1 -0
- package/lib/src/parse/outcome/uritoken_changes.js +83 -0
- package/lib/src/parse/outcome/uritoken_sell_offer_changes.d.ts +1 -0
- package/lib/src/parse/outcome/uritoken_sell_offer_changes.js +105 -0
- package/lib/src/parse/outcome.d.ts +4 -0
- package/lib/src/parse/outcome.js +264 -0
- package/lib/src/parse/specification/account-delete.d.ts +4 -0
- package/lib/src/parse/specification/account-delete.js +59 -0
- package/lib/src/parse/specification/amendment.d.ts +3 -0
- package/lib/src/parse/specification/amendment.js +50 -0
- package/lib/src/parse/specification/amm-bid.d.ts +4 -0
- package/lib/src/parse/specification/amm-bid.js +66 -0
- package/lib/src/parse/specification/amm-clawback.d.ts +4 -0
- package/lib/src/parse/specification/amm-clawback.js +65 -0
- package/lib/src/parse/specification/amm-create.d.ts +4 -0
- package/lib/src/parse/specification/amm-create.js +62 -0
- package/lib/src/parse/specification/amm-delete.d.ts +4 -0
- package/lib/src/parse/specification/amm-delete.js +61 -0
- package/lib/src/parse/specification/amm-deposit.d.ts +4 -0
- package/lib/src/parse/specification/amm-deposit.js +66 -0
- package/lib/src/parse/specification/amm-vote.d.ts +4 -0
- package/lib/src/parse/specification/amm-vote.js +62 -0
- package/lib/src/parse/specification/amm-withdraw.d.ts +4 -0
- package/lib/src/parse/specification/amm-withdraw.js +66 -0
- package/lib/src/parse/specification/batch.d.ts +4 -0
- package/lib/src/parse/specification/batch.js +83 -0
- package/lib/src/parse/specification/check-cancel.d.ts +4 -0
- package/lib/src/parse/specification/check-cancel.js +58 -0
- package/lib/src/parse/specification/check-cash.d.ts +4 -0
- package/lib/src/parse/specification/check-cash.js +64 -0
- package/lib/src/parse/specification/check-create.d.ts +4 -0
- package/lib/src/parse/specification/check-create.js +67 -0
- package/lib/src/parse/specification/clawback.d.ts +4 -0
- package/lib/src/parse/specification/clawback.js +62 -0
- package/lib/src/parse/specification/credential-accept.d.ts +4 -0
- package/lib/src/parse/specification/credential-accept.js +56 -0
- package/lib/src/parse/specification/credential-create.d.ts +4 -0
- package/lib/src/parse/specification/credential-create.js +58 -0
- package/lib/src/parse/specification/credential-delete.d.ts +4 -0
- package/lib/src/parse/specification/credential-delete.js +57 -0
- package/lib/src/parse/specification/cron-set.d.ts +3 -0
- package/lib/src/parse/specification/cron-set.js +62 -0
- package/lib/src/parse/specification/cron.d.ts +3 -0
- package/lib/src/parse/specification/cron.js +47 -0
- package/lib/src/parse/specification/delegate-set.d.ts +4 -0
- package/lib/src/parse/specification/delegate-set.js +60 -0
- package/lib/src/parse/specification/deposit-preauth.d.ts +4 -0
- package/lib/src/parse/specification/deposit-preauth.js +62 -0
- package/lib/src/parse/specification/did-delete.d.ts +4 -0
- package/lib/src/parse/specification/did-delete.js +57 -0
- package/lib/src/parse/specification/did-set.d.ts +4 -0
- package/lib/src/parse/specification/did-set.js +60 -0
- package/lib/src/parse/specification/escrow-cancel.d.ts +4 -0
- package/lib/src/parse/specification/escrow-cancel.js +59 -0
- package/lib/src/parse/specification/escrow-create.d.ts +4 -0
- package/lib/src/parse/specification/escrow-create.js +64 -0
- package/lib/src/parse/specification/escrow-finish.d.ts +4 -0
- package/lib/src/parse/specification/escrow-finish.js +61 -0
- package/lib/src/parse/specification/fee-update.d.ts +3 -0
- package/lib/src/parse/specification/fee-update.js +69 -0
- package/lib/src/parse/specification/genesis-mint.d.ts +3 -0
- package/lib/src/parse/specification/genesis-mint.js +53 -0
- package/lib/src/parse/specification/import.d.ts +3 -0
- package/lib/src/parse/specification/import.js +55 -0
- package/lib/src/parse/specification/invoke.d.ts +3 -0
- package/lib/src/parse/specification/invoke.js +54 -0
- package/lib/src/parse/specification/mptoken-authorize.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-authorize.js +60 -0
- package/lib/src/parse/specification/mptoken-issuance-create.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-create.js +62 -0
- package/lib/src/parse/specification/mptoken-issuance-destroy.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-destroy.js +56 -0
- package/lib/src/parse/specification/mptoken-issuance-set.d.ts +4 -0
- package/lib/src/parse/specification/mptoken-issuance-set.js +60 -0
- package/lib/src/parse/specification/nftoken-accept-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-accept-offer.js +58 -0
- package/lib/src/parse/specification/nftoken-burn.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-burn.js +56 -0
- package/lib/src/parse/specification/nftoken-cancel-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-cancel-offer.js +56 -0
- package/lib/src/parse/specification/nftoken-create-offer.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-create-offer.js +69 -0
- package/lib/src/parse/specification/nftoken-mint.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-mint.js +73 -0
- package/lib/src/parse/specification/nftoken-modify.d.ts +4 -0
- package/lib/src/parse/specification/nftoken-modify.js +58 -0
- package/lib/src/parse/specification/offer-cancel.d.ts +4 -0
- package/lib/src/parse/specification/offer-cancel.js +58 -0
- package/lib/src/parse/specification/offer-create.d.ts +4 -0
- package/lib/src/parse/specification/offer-create.js +78 -0
- package/lib/src/parse/specification/oracle-delete.d.ts +4 -0
- package/lib/src/parse/specification/oracle-delete.js +56 -0
- package/lib/src/parse/specification/oracle-set.d.ts +4 -0
- package/lib/src/parse/specification/oracle-set.js +62 -0
- package/lib/src/parse/specification/payment-channel-claim.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-claim.js +67 -0
- package/lib/src/parse/specification/payment-channel-create.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-create.js +68 -0
- package/lib/src/parse/specification/payment-channel-fund.d.ts +4 -0
- package/lib/src/parse/specification/payment-channel-fund.js +65 -0
- package/lib/src/parse/specification/payment.d.ts +4 -0
- package/lib/src/parse/specification/payment.js +75 -0
- package/lib/src/parse/specification/permissioned-domain-set.d.ts +4 -0
- package/lib/src/parse/specification/permissioned-domain-set.js +56 -0
- package/lib/src/parse/specification/remit.d.ts +3 -0
- package/lib/src/parse/specification/remit.js +90 -0
- package/lib/src/parse/specification/set-remarks.d.ts +3 -0
- package/lib/src/parse/specification/set-remarks.js +56 -0
- package/lib/src/parse/specification/settings.d.ts +4 -0
- package/lib/src/parse/specification/settings.js +64 -0
- package/lib/src/parse/specification/ticket-create.d.ts +4 -0
- package/lib/src/parse/specification/ticket-create.js +58 -0
- package/lib/src/parse/specification/trust-set.d.ts +4 -0
- package/lib/src/parse/specification/trust-set.js +80 -0
- package/lib/src/parse/specification/unl-modify.d.ts +4 -0
- package/lib/src/parse/specification/unl-modify.js +52 -0
- package/lib/src/parse/specification/unl-report.d.ts +3 -0
- package/lib/src/parse/specification/unl-report.js +51 -0
- package/lib/src/parse/specification/unrecognized.d.ts +4 -0
- package/lib/src/parse/specification/unrecognized.js +24 -0
- package/lib/src/parse/specification/uritoken-burn.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-burn.js +54 -0
- package/lib/src/parse/specification/uritoken-buy.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-buy.js +55 -0
- package/lib/src/parse/specification/uritoken-cancel-sell-offer.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-cancel-sell-offer.js +54 -0
- package/lib/src/parse/specification/uritoken-create-sell-offer.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-create-sell-offer.js +57 -0
- package/lib/src/parse/specification/uritoken-mint.d.ts +3 -0
- package/lib/src/parse/specification/uritoken-mint.js +63 -0
- package/lib/src/parse/transaction.d.ts +168 -0
- package/lib/src/parse/transaction.js +228 -0
- package/lib/src/parse/utils.d.ts +33 -0
- package/lib/src/parse/utils.js +119 -0
- package/lib/src/types/account.d.ts +26 -0
- package/lib/src/types/account.js +2 -0
- package/lib/src/types/adjustments.d.ts +16 -0
- package/lib/src/types/adjustments.js +2 -0
- package/lib/src/types/amendments.d.ts +4 -0
- package/lib/src/types/amendments.js +2 -0
- package/lib/src/types/amm.d.ts +98 -0
- package/lib/src/types/amm.js +68 -0
- package/lib/src/types/amounts.d.ts +20 -0
- package/lib/src/types/amounts.js +2 -0
- package/lib/src/types/batch.d.ts +21 -0
- package/lib/src/types/batch.js +26 -0
- package/lib/src/types/checks.d.ts +17 -0
- package/lib/src/types/checks.js +2 -0
- package/lib/src/types/clawback.d.ts +5 -0
- package/lib/src/types/clawback.js +2 -0
- package/lib/src/types/credentials.d.ts +30 -0
- package/lib/src/types/credentials.js +10 -0
- package/lib/src/types/cron.d.ts +17 -0
- package/lib/src/types/cron.js +6 -0
- package/lib/src/types/delegate.d.ts +5 -0
- package/lib/src/types/delegate.js +2 -0
- package/lib/src/types/deposits.d.ts +11 -0
- package/lib/src/types/deposits.js +2 -0
- package/lib/src/types/did.d.ts +7 -0
- package/lib/src/types/did.js +2 -0
- package/lib/src/types/emit_details.d.ts +7 -0
- package/lib/src/types/emit_details.js +2 -0
- package/lib/src/types/escrows.d.ts +18 -0
- package/lib/src/types/escrows.js +2 -0
- package/lib/src/types/fees.d.ts +9 -0
- package/lib/src/types/fees.js +2 -0
- package/lib/src/types/gateway_balances.d.ts +11 -0
- package/lib/src/types/gateway_balances.js +2 -0
- package/lib/src/types/genesis_mint.d.ts +9 -0
- package/lib/src/types/genesis_mint.js +2 -0
- package/lib/src/types/global.d.ts +14 -0
- package/lib/src/types/global.js +26 -0
- package/lib/src/types/hooks.d.ts +14 -0
- package/lib/src/types/hooks.js +2 -0
- package/lib/src/types/import.d.ts +21 -0
- package/lib/src/types/import.js +2 -0
- package/lib/src/types/index.d.ts +31 -0
- package/lib/src/types/index.js +47 -0
- package/lib/src/types/invoke.d.ts +5 -0
- package/lib/src/types/invoke.js +2 -0
- package/lib/src/types/ledger.d.ts +46 -0
- package/lib/src/types/ledger.js +2 -0
- package/lib/src/types/ledger_data.d.ts +10 -0
- package/lib/src/types/ledger_data.js +2 -0
- package/lib/src/types/ledger_entries.d.ts +163 -0
- package/lib/src/types/ledger_entries.js +2 -0
- package/lib/src/types/memos.d.ts +12 -0
- package/lib/src/types/memos.js +2 -0
- package/lib/src/types/mptokens.d.ts +84 -0
- package/lib/src/types/mptokens.js +76 -0
- package/lib/src/types/nftokens.d.ts +62 -0
- package/lib/src/types/nftokens.js +44 -0
- package/lib/src/types/offers.d.ts +46 -0
- package/lib/src/types/offers.js +33 -0
- package/lib/src/types/oracle.d.ts +19 -0
- package/lib/src/types/oracle.js +2 -0
- package/lib/src/types/outcome.d.ts +22 -0
- package/lib/src/types/outcome.js +2 -0
- package/lib/src/types/payment_channels.d.ts +23 -0
- package/lib/src/types/payment_channels.js +2 -0
- package/lib/src/types/payments.d.ts +24 -0
- package/lib/src/types/payments.js +25 -0
- package/lib/src/types/queue_data.d.ts +15 -0
- package/lib/src/types/queue_data.js +2 -0
- package/lib/src/types/remarks.d.ts +24 -0
- package/lib/src/types/remarks.js +6 -0
- package/lib/src/types/remits.d.ts +15 -0
- package/lib/src/types/remits.js +2 -0
- package/lib/src/types/settings.d.ts +27 -0
- package/lib/src/types/settings.js +2 -0
- package/lib/src/types/signers.d.ts +22 -0
- package/lib/src/types/signers.js +2 -0
- package/lib/src/types/specification.d.ts +14 -0
- package/lib/src/types/specification.js +2 -0
- package/lib/src/types/tickets.d.ts +4 -0
- package/lib/src/types/tickets.js +2 -0
- package/lib/src/types/trustlines.d.ts +85 -0
- package/lib/src/types/trustlines.js +43 -0
- package/lib/src/types/unl_modify.d.ts +6 -0
- package/lib/src/types/unl_modify.js +2 -0
- package/lib/src/types/unl_reports.d.ts +5 -0
- package/lib/src/types/unl_reports.js +2 -0
- package/lib/src/types/unrecognized.d.ts +5 -0
- package/lib/src/types/unrecognized.js +2 -0
- package/lib/src/types/uri_tokens.d.ts +7 -0
- package/lib/src/types/uri_tokens.js +6 -0
- package/lib/src/types/uritokens.d.ts +41 -0
- package/lib/src/types/uritokens.js +22 -0
- package/lib/src/v1/transaction/payment.d.ts +14 -0
- package/lib/src/v1/transaction/payment.js +142 -0
- package/lib/src/v1/types.d.ts +9 -0
- package/lib/src/v1/types.js +2 -0
- package/lib/src/v1/utils.d.ts +7 -0
- package/lib/src/v1/utils.js +49 -0
- package/lib/src/validator.d.ts +11 -0
- package/lib/src/validator.js +130 -0
- package/lib/src/wallet.d.ts +34 -0
- package/lib/src/wallet.js +284 -0
- package/lib/types/offers.d.ts +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,214 @@
|
|
|
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.parseAmmChanges = parseAmmChanges;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const common_1 = require("../../common");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
11
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
12
|
+
const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
13
|
+
const client_1 = require("../../client");
|
|
14
|
+
const models_1 = require("../../models");
|
|
15
|
+
function parseAmmStatus(node) {
|
|
16
|
+
if (node.diffType === "CreatedNode") {
|
|
17
|
+
return "created";
|
|
18
|
+
}
|
|
19
|
+
if (node.diffType === "ModifiedNode") {
|
|
20
|
+
return "modified";
|
|
21
|
+
}
|
|
22
|
+
if (node.diffType === "DeletedNode") {
|
|
23
|
+
return "deleted";
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
function parseAuctionSlot(auctionSlot) {
|
|
28
|
+
const slot = {
|
|
29
|
+
account: auctionSlot.Account,
|
|
30
|
+
authAccounts: (0, auth_accounts_1.default)(auctionSlot.AuthAccounts),
|
|
31
|
+
discountedFee: auctionSlot.DiscountedFee,
|
|
32
|
+
expiration: auctionSlot.Expiration ? (0, models_1.ledgerTimeToUnixTime)(auctionSlot.Expiration) : undefined,
|
|
33
|
+
price: auctionSlot.Price,
|
|
34
|
+
timeInterval: auctionSlot.TimeInterval,
|
|
35
|
+
};
|
|
36
|
+
return (0, common_1.removeUndefined)(slot);
|
|
37
|
+
}
|
|
38
|
+
function parseVoteSlot(voteSlot) {
|
|
39
|
+
return {
|
|
40
|
+
account: voteSlot.VoteEntry.Account,
|
|
41
|
+
tradingFee: voteSlot.VoteEntry.TradingFee,
|
|
42
|
+
voteWeight: voteSlot.VoteEntry.VoteWeight,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function summarizeVoteSlotsChanges(node) {
|
|
46
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
47
|
+
const prev = node.previousFields;
|
|
48
|
+
const changes = final.VoteSlots.reduce((acc, slot) => {
|
|
49
|
+
const prevSlot = prev.VoteSlots.find((s) => s.VoteEntry.Account === slot.VoteEntry.Account);
|
|
50
|
+
if (!prevSlot) {
|
|
51
|
+
return acc.concat({
|
|
52
|
+
status: "added",
|
|
53
|
+
account: slot.VoteEntry.Account,
|
|
54
|
+
tradingFee: slot.VoteEntry.TradingFee,
|
|
55
|
+
voteWeight: slot.VoteEntry.VoteWeight,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const tradingFeeChange = slot.VoteEntry.TradingFee - prevSlot.VoteEntry.TradingFee;
|
|
59
|
+
const voteWeightChange = slot.VoteEntry.VoteWeight - prevSlot.VoteEntry.VoteWeight;
|
|
60
|
+
if (tradingFeeChange !== 0 || voteWeightChange !== 0) {
|
|
61
|
+
return acc.concat((0, common_1.removeUndefined)({
|
|
62
|
+
status: "modified",
|
|
63
|
+
account: slot.VoteEntry.Account,
|
|
64
|
+
tradingFee: slot.VoteEntry.TradingFee,
|
|
65
|
+
voteWeight: slot.VoteEntry.VoteWeight,
|
|
66
|
+
tradingFeeChange: tradingFeeChange || undefined,
|
|
67
|
+
voteWeightChange: voteWeightChange || undefined,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return acc;
|
|
71
|
+
}, []);
|
|
72
|
+
const removed = prev.VoteSlots.filter((s) => {
|
|
73
|
+
return !final.VoteSlots.find((slot) => slot.VoteEntry.Account === s.VoteEntry.Account);
|
|
74
|
+
});
|
|
75
|
+
if (removed.length > 0) {
|
|
76
|
+
return changes.concat(removed.map((s) => {
|
|
77
|
+
return {
|
|
78
|
+
status: "removed",
|
|
79
|
+
account: s.VoteEntry.Account,
|
|
80
|
+
tradingFee: s.VoteEntry.TradingFee,
|
|
81
|
+
voteWeight: s.VoteEntry.VoteWeight,
|
|
82
|
+
};
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
if (changes.length === 0) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return changes;
|
|
89
|
+
}
|
|
90
|
+
function summarizeActionSlotChanges(node) {
|
|
91
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
92
|
+
const prev = node.previousFields;
|
|
93
|
+
const changes = {};
|
|
94
|
+
if (prev.AuctionSlot) {
|
|
95
|
+
if (final.AuctionSlot.Account !== prev.AuctionSlot.Account) {
|
|
96
|
+
changes.accountChanges = final.AuctionSlot.Account;
|
|
97
|
+
}
|
|
98
|
+
if (final.AuctionSlot.DiscountedFee !== prev.AuctionSlot.DiscountedFee) {
|
|
99
|
+
changes.discountedFeeChange = final.AuctionSlot.DiscountedFee - prev.AuctionSlot.DiscountedFee;
|
|
100
|
+
}
|
|
101
|
+
if (final.AuctionSlot.Expiration !== prev.AuctionSlot.Expiration) {
|
|
102
|
+
changes.expirationChange = final.AuctionSlot.Expiration - prev.AuctionSlot.Expiration;
|
|
103
|
+
}
|
|
104
|
+
if (final.AuctionSlot.Price.value !== prev.AuctionSlot.Price.value) {
|
|
105
|
+
changes.priceChange = {
|
|
106
|
+
currency: final.AuctionSlot.Price.currency,
|
|
107
|
+
issuer: final.AuctionSlot.Price.issuer,
|
|
108
|
+
value: new bignumber_js_1.default(final.AuctionSlot.Price.value)
|
|
109
|
+
.minus(new bignumber_js_1.default(prev.AuctionSlot.Price.value))
|
|
110
|
+
.toString(10),
|
|
111
|
+
counterparty: final.AuctionSlot.Price.issuer,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (final.AuctionSlot.TimeInterval !== prev.AuctionSlot.TimeInterval) {
|
|
115
|
+
changes.timeIntervalChange = final.AuctionSlot.TimeInterval - prev.AuctionSlot.TimeInterval;
|
|
116
|
+
}
|
|
117
|
+
if (!isEqualAuthAccounts(final.AuctionSlot.AuthAccounts, prev.AuctionSlot.AuthAccounts)) {
|
|
118
|
+
const prevAuthAccounts = prev.AuctionSlot.AuthAccounts || [];
|
|
119
|
+
const finalAuthAccounts = final.AuctionSlot.AuthAccounts || [];
|
|
120
|
+
let authAccountsChanges = finalAuthAccounts.map((auth) => {
|
|
121
|
+
if (!prevAuthAccounts.includes(auth.AuthAccount.Account)) {
|
|
122
|
+
return {
|
|
123
|
+
status: "added",
|
|
124
|
+
account: auth.AuthAccount.Account,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const removed = prevAuthAccounts.filter((auth) => {
|
|
129
|
+
return !finalAuthAccounts.includes(auth.AuthAccount.Account);
|
|
130
|
+
});
|
|
131
|
+
if (removed.length > 0) {
|
|
132
|
+
authAccountsChanges = authAccountsChanges.concat(removed.map((account) => {
|
|
133
|
+
return {
|
|
134
|
+
status: "removed",
|
|
135
|
+
account: account.AuthAccount.Account,
|
|
136
|
+
};
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
changes.authAccountsChanges = authAccountsChanges;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (Object.keys(changes).length === 0) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
return (0, common_1.removeUndefined)(changes);
|
|
146
|
+
}
|
|
147
|
+
function isEqualAuthAccounts(obj1, obj2) {
|
|
148
|
+
if (obj1 === undefined && obj2 === undefined) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if ((obj1 === undefined && obj2 !== undefined) || (obj1 !== undefined && obj2 === undefined)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (obj1.length !== obj2.length) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const obj1Sorted = obj1.sort((a, b) => a.AuthAccount.Account.localeCompare(b.AuthAccount.Account));
|
|
158
|
+
const obj2Sorted = obj2.sort((a, b) => a.AuthAccount.Account.localeCompare(b.AuthAccount.Account));
|
|
159
|
+
for (let i = 0; i < obj1Sorted.length; i++) {
|
|
160
|
+
if (obj1Sorted[i].AuthAccount.Account !== obj2Sorted[i].AuthAccount.Account) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
function summarizeAmm(node) {
|
|
167
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
168
|
+
const prev = node.previousFields;
|
|
169
|
+
let asset = (0, asset_1.default)(final.Asset);
|
|
170
|
+
if (node.diffType === "CreatedNode" && !asset) {
|
|
171
|
+
asset = { currency: (0, client_1.getNativeCurrency)() };
|
|
172
|
+
}
|
|
173
|
+
const summary = {
|
|
174
|
+
status: parseAmmStatus(node),
|
|
175
|
+
ammID: node.ledgerIndex,
|
|
176
|
+
account: final.Account,
|
|
177
|
+
asset: asset,
|
|
178
|
+
asset2: (0, asset_1.default)(final.Asset2),
|
|
179
|
+
auctionSlot: parseAuctionSlot(final.AuctionSlot),
|
|
180
|
+
lpTokenBalance: (0, amount_1.default)(final.LPTokenBalance),
|
|
181
|
+
tradingFee: final.TradingFee,
|
|
182
|
+
ownerNode: final.OwnerNode,
|
|
183
|
+
voteSlots: final.VoteSlots ? final.VoteSlots.map(parseVoteSlot) : undefined,
|
|
184
|
+
};
|
|
185
|
+
if (prev.LPTokenBalance) {
|
|
186
|
+
summary.lpTokenBalanceChange = {
|
|
187
|
+
currency: final.LPTokenBalance.currency,
|
|
188
|
+
issuer: final.LPTokenBalance.issuer,
|
|
189
|
+
value: new bignumber_js_1.default(final.LPTokenBalance.value).minus(new bignumber_js_1.default(prev.LPTokenBalance.value)).toString(10),
|
|
190
|
+
counterparty: final.LPTokenBalance.issuer,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (prev.VoteSlots) {
|
|
194
|
+
summary.voteSlotsChanges = summarizeVoteSlotsChanges(node);
|
|
195
|
+
}
|
|
196
|
+
if (prev.TradingFee) {
|
|
197
|
+
summary.tradingFeeChanges = final.TradingFee - (prev.TradingFee || 0);
|
|
198
|
+
}
|
|
199
|
+
if (prev.AuctionSlot) {
|
|
200
|
+
summary.auctionSlotChanges = summarizeActionSlotChanges(node);
|
|
201
|
+
}
|
|
202
|
+
return (0, common_1.removeUndefined)(summary);
|
|
203
|
+
}
|
|
204
|
+
function parseAmmChanges(metadata) {
|
|
205
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
206
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
207
|
+
return node.LedgerEntryType === "AMM";
|
|
208
|
+
});
|
|
209
|
+
if (affectedNodes.length !== 1) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
213
|
+
return summarizeAmm(normalizedNode);
|
|
214
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
interface BalanceChangeQuantity {
|
|
3
|
+
issuer?: string;
|
|
4
|
+
currency?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
counterparty?: string;
|
|
7
|
+
mpt_issuance_id?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AddressBalanceChangeQuantity {
|
|
10
|
+
address: string;
|
|
11
|
+
balance: BalanceChangeQuantity;
|
|
12
|
+
}
|
|
13
|
+
export interface BalanceChanges {
|
|
14
|
+
[key: string]: BalanceChangeQuantity[];
|
|
15
|
+
}
|
|
16
|
+
interface ParseBalanceChangesOptions {
|
|
17
|
+
adjustBalancesForNativeEscrow?: boolean;
|
|
18
|
+
adjustBalancesForPaymentChannel?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function parseBalanceChanges(metadata: TransactionMetadata, nativeCurrency?: string, tx?: any, options?: ParseBalanceChangesOptions): BalanceChanges;
|
|
21
|
+
declare function parseFinalBalances(metadata: TransactionMetadata, nativeCurrency?: string): {
|
|
22
|
+
[x: string]: BalanceChangeQuantity[];
|
|
23
|
+
};
|
|
24
|
+
export { parseBalanceChanges, parseFinalBalances };
|
|
@@ -0,0 +1,337 @@
|
|
|
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.parseBalanceChanges = parseBalanceChanges;
|
|
7
|
+
exports.parseFinalBalances = parseFinalBalances;
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
10
|
+
const common_1 = require("../../common");
|
|
11
|
+
const client_1 = require("../../client");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const mptoken_1 = require("../../models/mptoken");
|
|
14
|
+
const mptoken_normalize_1 = require("../mptoken_normalize");
|
|
15
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
16
|
+
const channel_changes_1 = require("./channel_changes");
|
|
17
|
+
const ESCROW_TYPES = ["EscrowFinish", "EscrowCreate", "EscrowCancel"];
|
|
18
|
+
const PAYMENT_CHANNEL_TYPES = ["PaymentChannelClaim", "PaymentChannelCreate", "PaymentChannelFund"];
|
|
19
|
+
function groupByAddress(balanceChanges) {
|
|
20
|
+
const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
21
|
+
return node.address;
|
|
22
|
+
});
|
|
23
|
+
return lodash_1.default.mapValues(grouped, function (group) {
|
|
24
|
+
return lodash_1.default.map(group, function (node) {
|
|
25
|
+
return node.balance;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function parseValue(value) {
|
|
30
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
31
|
+
return new bignumber_js_1.default(value);
|
|
32
|
+
}
|
|
33
|
+
return new bignumber_js_1.default(value.value ?? 0);
|
|
34
|
+
}
|
|
35
|
+
function computeBalanceChange(node) {
|
|
36
|
+
let value = null;
|
|
37
|
+
if (node.newFields.Balance) {
|
|
38
|
+
value = parseValue(node.newFields.Balance);
|
|
39
|
+
}
|
|
40
|
+
else if (node.newFields.MPTAmount) {
|
|
41
|
+
value = parseValue(node.newFields.MPTAmount);
|
|
42
|
+
}
|
|
43
|
+
else if (node.previousFields.Balance && node.finalFields.Balance) {
|
|
44
|
+
value = parseValue(node.finalFields.Balance).minus(parseValue(node.previousFields.Balance));
|
|
45
|
+
}
|
|
46
|
+
else if (node.entryType === "MPToken" && (node.previousFields.MPTAmount || node.previousFields.LockedAmount)) {
|
|
47
|
+
value = new bignumber_js_1.default(0);
|
|
48
|
+
if (node.previousFields.MPTAmount) {
|
|
49
|
+
value = value
|
|
50
|
+
.plus(parseValue(node.finalFields.MPTAmount ?? 0))
|
|
51
|
+
.minus(parseValue(node.previousFields.MPTAmount ?? 0));
|
|
52
|
+
}
|
|
53
|
+
if (node.previousFields.LockedAmount) {
|
|
54
|
+
value = value
|
|
55
|
+
.plus(parseValue(node.finalFields.LockedAmount ?? 0))
|
|
56
|
+
.minus(parseValue(node.previousFields.LockedAmount ?? 0));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (node.entryType === "MPTokenIssuance") {
|
|
60
|
+
if (node.newFields.MaximumAmount) {
|
|
61
|
+
value = parseValue(node.newFields.MaximumAmount);
|
|
62
|
+
}
|
|
63
|
+
else if (node.diffType === "DeletedNode" && node.finalFields.MaximumAmount) {
|
|
64
|
+
value = parseValue(node.finalFields.MaximumAmount).multipliedBy(-1);
|
|
65
|
+
}
|
|
66
|
+
else if (node.previousFields.OutstandingAmount) {
|
|
67
|
+
value = parseValue(node.previousFields.OutstandingAmount ?? 0).minus(parseValue(node.finalFields.OutstandingAmount ?? 0));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return value === null ? null : value.isZero() ? null : value;
|
|
71
|
+
}
|
|
72
|
+
function parseFinalBalance(node) {
|
|
73
|
+
if (node.newFields.Balance) {
|
|
74
|
+
return parseValue(node.newFields.Balance);
|
|
75
|
+
}
|
|
76
|
+
else if (node.finalFields.Balance) {
|
|
77
|
+
return parseValue(node.finalFields.Balance);
|
|
78
|
+
}
|
|
79
|
+
else if (node.entryType === "MPToken") {
|
|
80
|
+
if (node.finalFields.MPTAmount) {
|
|
81
|
+
return parseValue(node.finalFields.MPTAmount);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (node.entryType === "MPTokenIssuance") {
|
|
85
|
+
if (node.newFields.MaximumAmount) {
|
|
86
|
+
return parseValue(node.newFields.MaximumAmount);
|
|
87
|
+
}
|
|
88
|
+
else if (node.diffType === "DeletedNode" && node.finalFields.MaximumAmount) {
|
|
89
|
+
return new bignumber_js_1.default(0);
|
|
90
|
+
}
|
|
91
|
+
else if (node.finalFields.MaximumAmount) {
|
|
92
|
+
return parseValue(node.finalFields.MaximumAmount).minus(parseValue(node.finalFields.OutstandingAmount));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function parseXRPQuantity(node, valueParser, nativeCurrency) {
|
|
98
|
+
const value = valueParser(node);
|
|
99
|
+
if (value === null) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
address: (node.finalFields.Account || node.newFields.Account),
|
|
104
|
+
balance: {
|
|
105
|
+
currency: nativeCurrency || (0, client_1.getNativeCurrency)(),
|
|
106
|
+
value: (0, common_1.dropsToXrp)(value).toString(),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function flipTrustlinePerspective(quantity) {
|
|
111
|
+
const negatedBalance = new bignumber_js_1.default(quantity.balance.value).negated();
|
|
112
|
+
return {
|
|
113
|
+
address: quantity.balance.issuer,
|
|
114
|
+
balance: {
|
|
115
|
+
issuer: quantity.balance.issuer,
|
|
116
|
+
currency: quantity.balance.currency,
|
|
117
|
+
value: negatedBalance.toString(),
|
|
118
|
+
counterparty: quantity.address,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function parseTrustlineQuantity(node, valueParser) {
|
|
123
|
+
const value = valueParser(node);
|
|
124
|
+
if (value === null) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
128
|
+
const previousFields = node.previousFields;
|
|
129
|
+
let viewLowest = true;
|
|
130
|
+
if (previousFields && previousFields.Balance && previousFields.Balance.value !== "0") {
|
|
131
|
+
viewLowest = previousFields.Balance.value[0] !== "-";
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
viewLowest = fields.Balance.value[0] !== "-";
|
|
135
|
+
}
|
|
136
|
+
const sign = viewLowest ? 1 : -1;
|
|
137
|
+
const currency = fields.Balance.currency;
|
|
138
|
+
const issuer = viewLowest ? fields.HighLimit.issuer : fields.LowLimit.issuer;
|
|
139
|
+
const holder = viewLowest ? fields.LowLimit.issuer : fields.HighLimit.issuer;
|
|
140
|
+
const result = {
|
|
141
|
+
address: holder,
|
|
142
|
+
balance: {
|
|
143
|
+
issuer,
|
|
144
|
+
currency,
|
|
145
|
+
value: value.times(sign).toString(),
|
|
146
|
+
counterparty: issuer,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
return [result, flipTrustlinePerspective(result)];
|
|
150
|
+
}
|
|
151
|
+
function parseMPTQuantity(node, valueParser) {
|
|
152
|
+
const value = valueParser(node);
|
|
153
|
+
if (value === null) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
157
|
+
return {
|
|
158
|
+
address: fields.Account,
|
|
159
|
+
balance: {
|
|
160
|
+
value: value.toString(),
|
|
161
|
+
mpt_issuance_id: fields.MPTokenIssuanceID,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function parseMPTokenIssuanceQuantity(node, valueParser) {
|
|
166
|
+
const value = valueParser(node);
|
|
167
|
+
if (value === null) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
171
|
+
return {
|
|
172
|
+
address: fields.Issuer,
|
|
173
|
+
balance: {
|
|
174
|
+
value: value.toString(),
|
|
175
|
+
mpt_issuance_id: (0, mptoken_1.buildMPTokenIssuanceID)(fields.Sequence, fields.Issuer),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function parseQuantities(metadata, valueParser, nativeCurrency) {
|
|
180
|
+
const values = metadata.AffectedNodes.map(function (affectedNode) {
|
|
181
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
182
|
+
if (!["AccountRoot", "RippleState", "MPToken", "MPTokenIssuance"].includes(node.LedgerEntryType)) {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
186
|
+
if (node.LedgerEntryType === "AccountRoot") {
|
|
187
|
+
return [parseXRPQuantity(normalizedNode, valueParser, nativeCurrency)];
|
|
188
|
+
}
|
|
189
|
+
else if (node.LedgerEntryType === "RippleState") {
|
|
190
|
+
return parseTrustlineQuantity(normalizedNode, valueParser);
|
|
191
|
+
}
|
|
192
|
+
else if (node.LedgerEntryType === "MPToken") {
|
|
193
|
+
return [parseMPTQuantity(normalizedNode, valueParser)];
|
|
194
|
+
}
|
|
195
|
+
else if (node.LedgerEntryType === "MPTokenIssuance") {
|
|
196
|
+
return [parseMPTokenIssuanceQuantity(normalizedNode, valueParser)];
|
|
197
|
+
}
|
|
198
|
+
return [];
|
|
199
|
+
});
|
|
200
|
+
return groupByAddress(lodash_1.default.compact(lodash_1.default.flatten(values)));
|
|
201
|
+
}
|
|
202
|
+
function adjustBalancesForNativeEscrow(balanceChanges, metadata, nativeCurrency, tx) {
|
|
203
|
+
let escrow;
|
|
204
|
+
if (tx.TransactionType === "EscrowCreate") {
|
|
205
|
+
escrow = metadata.AffectedNodes.find((node) => node.CreatedNode?.LedgerEntryType === "Escrow");
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
escrow = metadata.AffectedNodes.find((node) => node.DeletedNode?.LedgerEntryType === "Escrow");
|
|
209
|
+
}
|
|
210
|
+
if (!escrow) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const fields = escrow.CreatedNode?.NewFields || escrow.DeletedNode?.FinalFields;
|
|
214
|
+
if (!fields || !fields.Amount) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const amount = (0, amount_1.default)(fields.Amount);
|
|
218
|
+
if (!amount || amount.currency !== (nativeCurrency || common_1.MAINNET_NATIVE_CURRENCY) || !amount.value) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const source = fields.Account;
|
|
222
|
+
if (tx.TransactionType === "EscrowCreate") {
|
|
223
|
+
adjustBalancesChanges(balanceChanges, source, [{ currency: amount.currency, value: amount.value }]);
|
|
224
|
+
}
|
|
225
|
+
else if (tx.TransactionType === "EscrowFinish" || tx.TransactionType === "EscrowCancel") {
|
|
226
|
+
adjustBalancesChanges(balanceChanges, source, [{ currency: amount.currency, value: `-${amount.value}` }]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function adjustBalancesForPaymentChannel(balanceChanges, metadata, nativeCurrency, tx) {
|
|
230
|
+
const channelChanges = (0, channel_changes_1.parseChannelChanges)(metadata);
|
|
231
|
+
if (!channelChanges) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (!channelChanges.source?.address) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (tx.TransactionType === "PaymentChannelCreate") {
|
|
238
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
239
|
+
{ currency: channelChanges.amount.currency, value: channelChanges.amount.value },
|
|
240
|
+
]);
|
|
241
|
+
}
|
|
242
|
+
else if (tx.TransactionType === "PaymentChannelFund") {
|
|
243
|
+
if (channelChanges.amountChange) {
|
|
244
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
245
|
+
{ currency: channelChanges.amountChange.currency, value: channelChanges.amountChange.value },
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
else if (channelChanges.status === "deleted") {
|
|
249
|
+
let unlockedAmount = new bignumber_js_1.default(0);
|
|
250
|
+
if (channelChanges?.balanceChange) {
|
|
251
|
+
unlockedAmount = new bignumber_js_1.default(channelChanges?.balanceChange?.value || "0").abs();
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
unlockedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(channelChanges?.balance?.value || "0");
|
|
255
|
+
}
|
|
256
|
+
if (!unlockedAmount.isZero()) {
|
|
257
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
258
|
+
{ currency: channelChanges.amount.currency, value: `-${unlockedAmount.toString()}` },
|
|
259
|
+
]);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else if (tx.TransactionType === "PaymentChannelClaim") {
|
|
264
|
+
if (tx.Account === channelChanges.source.address && channelChanges.amountChange) {
|
|
265
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
266
|
+
{ currency: channelChanges.amountChange.currency, value: channelChanges.amountChange.value },
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
else if (channelChanges.status === "deleted") {
|
|
270
|
+
let unlockedAmount = new bignumber_js_1.default(0);
|
|
271
|
+
if (channelChanges?.balanceChange) {
|
|
272
|
+
unlockedAmount = new bignumber_js_1.default(channelChanges?.balanceChange?.value || "0").abs();
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
unlockedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(channelChanges?.balance?.value || "0");
|
|
276
|
+
}
|
|
277
|
+
if (!unlockedAmount.isZero()) {
|
|
278
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
279
|
+
{ currency: channelChanges.amount.currency, value: `-${unlockedAmount.toString()}` },
|
|
280
|
+
]);
|
|
281
|
+
}
|
|
282
|
+
if (channelChanges.balanceChange) {
|
|
283
|
+
if (channelChanges.source.address !== tx.Account && channelChanges?.balance && channelChanges?.amount) {
|
|
284
|
+
const returnedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(new bignumber_js_1.default(channelChanges.balance.value));
|
|
285
|
+
if (!returnedAmount.isZero()) {
|
|
286
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
287
|
+
{ currency: channelChanges.amount.currency, value: `-${returnedAmount.toString()}` },
|
|
288
|
+
]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if (channelChanges.balanceChange) {
|
|
294
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
295
|
+
{ currency: channelChanges.balanceChange.currency, value: channelChanges.balanceChange.value },
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function adjustBalancesChanges(balanceChanges, address, changes) {
|
|
301
|
+
const existingChanges = balanceChanges[address] || [];
|
|
302
|
+
const change = existingChanges.find((c) => c.currency === changes[0].currency && c.issuer === changes[0].issuer);
|
|
303
|
+
if (change) {
|
|
304
|
+
const newValue = new bignumber_js_1.default(change.value).plus(new bignumber_js_1.default(changes[0].value));
|
|
305
|
+
if (newValue.isZero()) {
|
|
306
|
+
balanceChanges[address] = existingChanges.filter((c) => c !== change);
|
|
307
|
+
if (balanceChanges[address].length === 0) {
|
|
308
|
+
delete balanceChanges[address];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
change.value = newValue.toString();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
existingChanges.push(changes[0]);
|
|
317
|
+
balanceChanges[address] = existingChanges;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function parseBalanceChanges(metadata, nativeCurrency, tx, options) {
|
|
321
|
+
if (tx && nativeCurrency === common_1.MAINNET_NATIVE_CURRENCY && metadata.TransactionResult === "tesSUCCESS") {
|
|
322
|
+
(0, mptoken_normalize_1.normalizeMPTokensPreviousFields)(metadata, tx);
|
|
323
|
+
}
|
|
324
|
+
const balanceChanges = parseQuantities(metadata, computeBalanceChange, nativeCurrency);
|
|
325
|
+
if (tx && tx.TransactionType && options) {
|
|
326
|
+
if (options.adjustBalancesForNativeEscrow && ESCROW_TYPES.includes(tx.TransactionType)) {
|
|
327
|
+
adjustBalancesForNativeEscrow(balanceChanges, metadata, nativeCurrency, tx);
|
|
328
|
+
}
|
|
329
|
+
else if (options.adjustBalancesForPaymentChannel && PAYMENT_CHANNEL_TYPES.includes(tx.TransactionType)) {
|
|
330
|
+
adjustBalancesForPaymentChannel(balanceChanges, metadata, nativeCurrency, tx);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return balanceChanges;
|
|
334
|
+
}
|
|
335
|
+
function parseFinalBalances(metadata, nativeCurrency) {
|
|
336
|
+
return parseQuantities(metadata, parseFinalBalance, nativeCurrency);
|
|
337
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../types/account";
|
|
3
|
+
import { IssuedCurrencyAmount } from "../../types/amounts";
|
|
4
|
+
interface FormattedChannelSummaryInterface {
|
|
5
|
+
status?: "created" | "modified" | "deleted";
|
|
6
|
+
channelId: string;
|
|
7
|
+
source?: FormattedSourceAddress;
|
|
8
|
+
destination?: FormattedDestinationAddress;
|
|
9
|
+
channelAmountDrops: string;
|
|
10
|
+
amount: IssuedCurrencyAmount;
|
|
11
|
+
channelBalanceDrops?: string;
|
|
12
|
+
balance?: IssuedCurrencyAmount;
|
|
13
|
+
channelAmountChangeDrops?: string;
|
|
14
|
+
amountChange?: IssuedCurrencyAmount;
|
|
15
|
+
channelBalanceChangeDrops?: string;
|
|
16
|
+
balanceChange?: IssuedCurrencyAmount;
|
|
17
|
+
previousTxnID?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function parseChannelChanges(metadata: TransactionMetadata): FormattedChannelSummaryInterface | undefined;
|
|
20
|
+
export { parseChannelChanges };
|
|
@@ -0,0 +1,70 @@
|
|
|
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.parseChannelChanges = parseChannelChanges;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
9
|
+
const source_1 = require("../ledger/source");
|
|
10
|
+
const destination_1 = require("../ledger/destination");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
function parsePaymentChannelStatus(node) {
|
|
13
|
+
if (node.diffType === "CreatedNode") {
|
|
14
|
+
return "created";
|
|
15
|
+
}
|
|
16
|
+
if (node.diffType === "ModifiedNode") {
|
|
17
|
+
return "modified";
|
|
18
|
+
}
|
|
19
|
+
if (node.diffType === "DeletedNode") {
|
|
20
|
+
return "deleted";
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function summarizePaymentChannel(node) {
|
|
25
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
26
|
+
const prev = node.previousFields;
|
|
27
|
+
const summary = {
|
|
28
|
+
status: parsePaymentChannelStatus(node),
|
|
29
|
+
channelId: node.ledgerIndex,
|
|
30
|
+
source: (0, source_1.parseSource)(final),
|
|
31
|
+
destination: (0, destination_1.parseDestination)(final),
|
|
32
|
+
channelAmountDrops: new bignumber_js_1.default(final.Amount || 0).toString(10),
|
|
33
|
+
amount: (0, amount_1.default)(final.Amount),
|
|
34
|
+
};
|
|
35
|
+
if (final.Balance) {
|
|
36
|
+
summary.channelBalanceDrops = new bignumber_js_1.default(final.Balance || 0).toString(10);
|
|
37
|
+
summary.balance = (0, amount_1.default)(final.Balance);
|
|
38
|
+
}
|
|
39
|
+
if (prev.Amount) {
|
|
40
|
+
summary.channelAmountChangeDrops = new bignumber_js_1.default(final.Amount).minus(new bignumber_js_1.default(prev.Amount || 0)).toString(10);
|
|
41
|
+
summary.amountChange = (0, amount_1.default)(prev.Amount);
|
|
42
|
+
summary.amountChange.value = new bignumber_js_1.default(summary.amount.value)
|
|
43
|
+
.minus(new bignumber_js_1.default(summary.amountChange.value))
|
|
44
|
+
.toString(10);
|
|
45
|
+
}
|
|
46
|
+
if (prev.Balance) {
|
|
47
|
+
summary.channelBalanceChangeDrops = new bignumber_js_1.default(final.Balance)
|
|
48
|
+
.minus(new bignumber_js_1.default(prev.Balance || 0))
|
|
49
|
+
.toString(10);
|
|
50
|
+
summary.balanceChange = (0, amount_1.default)(prev.Balance);
|
|
51
|
+
summary.balanceChange.value = new bignumber_js_1.default(summary.balanceChange.value)
|
|
52
|
+
.minus(new bignumber_js_1.default(summary.balance?.value || 0))
|
|
53
|
+
.toString(10);
|
|
54
|
+
}
|
|
55
|
+
if (node.PreviousTxnID) {
|
|
56
|
+
summary.previousTxnID = node.PreviousTxnID;
|
|
57
|
+
}
|
|
58
|
+
return summary;
|
|
59
|
+
}
|
|
60
|
+
function parseChannelChanges(metadata) {
|
|
61
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
62
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
63
|
+
return node.LedgerEntryType === "PayChannel";
|
|
64
|
+
});
|
|
65
|
+
if (affectedNodes.length !== 1) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
69
|
+
return summarizePaymentChannel(normalizedNode);
|
|
70
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../types/account";
|
|
3
|
+
import { IssuedCurrencyAmount, FormattedIssuedMPTAmount } from "../../types/amounts";
|
|
4
|
+
interface FormattedCheckSummaryInterface {
|
|
5
|
+
status?: "created" | "modified" | "deleted";
|
|
6
|
+
checkID: string;
|
|
7
|
+
source?: FormattedSourceAddress;
|
|
8
|
+
destination?: FormattedDestinationAddress;
|
|
9
|
+
sendMax: IssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
10
|
+
expiration?: number;
|
|
11
|
+
invoiceID?: string;
|
|
12
|
+
sequence?: number;
|
|
13
|
+
sendMaxChange?: IssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
14
|
+
previousTxnID?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function parseCheckChanges(metadata: TransactionMetadata): FormattedCheckSummaryInterface | undefined;
|
|
17
|
+
export { parseCheckChanges };
|