@ledgerhq/live-common 34.54.0 → 34.55.0-nightly.20251210100832
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/__tests__/test-helpers/bridge.js +1 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/__tests__/test-helpers/environment.js +3 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/account/index.d.ts +1 -0
- package/lib/account/index.d.ts.map +1 -1
- package/lib/account/index.js +4 -1
- package/lib/account/index.js.map +1 -1
- package/lib/account/recentAddresses.d.ts +10 -0
- package/lib/account/recentAddresses.d.ts.map +1 -0
- package/lib/account/recentAddresses.js +60 -0
- package/lib/account/recentAddresses.js.map +1 -0
- package/lib/account/serialization.js +1 -1
- package/lib/account/serialization.js.map +1 -1
- package/lib/account/support.js +1 -1
- package/lib/account/support.js.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.js +2 -1
- package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.js +3 -3
- package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.js +3 -3
- package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +24 -8
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +16 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/postSync.d.ts +16 -0
- package/lib/bridge/generic-alpaca/postSync.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/postSync.js +44 -0
- package/lib/bridge/generic-alpaca/postSync.js.map +1 -0
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +45 -4
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +18 -2
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
- package/lib/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/Eth.js +8 -1
- package/lib/bridge/generic-alpaca/signer/Eth.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.js +7 -0
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/types.d.ts +4 -0
- package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +12 -3
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +14 -3
- package/lib/bridge/impl.js.map +1 -1
- package/lib/currencies/helpers.d.ts +1 -0
- package/lib/currencies/helpers.d.ts.map +1 -1
- package/lib/currencies/helpers.js +7 -1
- package/lib/currencies/helpers.js.map +1 -1
- package/lib/domain/getTokensWithFunds.d.ts +7 -1
- package/lib/domain/getTokensWithFunds.d.ts.map +1 -1
- package/lib/domain/getTokensWithFunds.js +15 -4
- package/lib/domain/getTokensWithFunds.js.map +1 -1
- package/lib/domain/getTotalStakeableAssets.d.ts +10 -0
- package/lib/domain/getTotalStakeableAssets.d.ts.map +1 -0
- package/lib/domain/getTotalStakeableAssets.js +35 -0
- package/lib/domain/getTotalStakeableAssets.js.map +1 -0
- package/lib/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib/e2e/data/deviceLabelsData.js +1 -0
- package/lib/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib/e2e/data/regexes.d.ts +2 -0
- package/lib/e2e/data/regexes.d.ts.map +1 -0
- package/lib/e2e/data/regexes.js +5 -0
- package/lib/e2e/data/regexes.js.map +1 -0
- package/lib/e2e/enum/Device.d.ts +1 -0
- package/lib/e2e/enum/Device.d.ts.map +1 -1
- package/lib/e2e/enum/Device.js +1 -0
- package/lib/e2e/enum/Device.js.map +1 -1
- package/lib/e2e/families/cardano.d.ts.map +1 -1
- package/lib/e2e/families/cardano.js +29 -14
- package/lib/e2e/families/cardano.js.map +1 -1
- package/lib/e2e/index.d.ts +35 -3
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/index.js +21 -1
- package/lib/e2e/index.js.map +1 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +31 -4
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosAppVersion.d.ts.map +1 -1
- package/lib/e2e/speculosAppVersion.js +6 -2
- package/lib/e2e/speculosAppVersion.js.map +1 -1
- package/lib/e2e/swap.d.ts.map +1 -1
- package/lib/e2e/swap.js +7 -6
- package/lib/e2e/swap.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js +1 -1
- package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib/exchange/swap/postSwapState.js +10 -6
- package/lib/exchange/swap/postSwapState.js.map +1 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +3 -2
- package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib/exchange/swap/transactionStrategies.js +26 -7
- package/lib/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +3 -1
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
- package/lib/families/bitcoin/walletApiAdapter.js +3 -0
- package/lib/families/bitcoin/walletApiAdapter.js.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +4 -4
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/canton/react.d.ts +2 -0
- package/lib/families/canton/react.d.ts.map +1 -1
- package/lib/families/canton/react.js +40 -1
- package/lib/families/canton/react.js.map +1 -1
- package/lib/families/celo/setup.d.ts.map +1 -1
- package/lib/families/celo/setup.js +11 -0
- package/lib/families/celo/setup.js.map +1 -1
- package/lib/families/evm/bridge/mock.d.ts +1 -0
- package/lib/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib/families/evm/bridge/mock.js +12 -0
- package/lib/families/evm/bridge/mock.js.map +1 -1
- package/lib/families/evm/setup.d.ts +1 -4
- package/lib/families/evm/setup.d.ts.map +1 -1
- package/lib/families/evm/setup.js +1 -8
- package/lib/families/evm/setup.js.map +1 -1
- package/lib/families/evm/walletApiAdapter.d.ts +7 -0
- package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib/families/evm/walletApiAdapter.js +36 -2
- package/lib/families/evm/walletApiAdapter.js.map +1 -1
- package/lib/families/hedera/react.d.ts +6 -0
- package/lib/families/hedera/react.d.ts.map +1 -0
- package/lib/families/hedera/react.js +50 -0
- package/lib/families/hedera/react.js.map +1 -0
- package/lib/families/polkadot/config.js +1 -1
- package/lib/families/polkadot/config.js.map +1 -1
- package/lib/families/stacks/constants.d.ts +1 -1
- package/lib/families/stacks/constants.d.ts.map +1 -1
- package/lib/families/stacks/constants.js +1 -1
- package/lib/families/stacks/constants.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +2 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +22 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/firebaseFeatureFlags.js +1 -1
- package/lib/featureFlags/firebaseFeatureFlags.js.map +1 -1
- package/lib/featureFlags/stakePrograms/index.js +4 -4
- package/lib/featureFlags/stakePrograms/index.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/featureFlags/useHasOverriddenFeatureFlags.js +1 -1
- package/lib/featureFlags/useHasOverriddenFeatureFlags.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +0 -1
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +30 -32
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/bridge/mock.d.ts +1 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/helpers/cryptoIconSize.d.ts +3 -0
- package/lib/helpers/cryptoIconSize.d.ts.map +1 -0
- package/lib/helpers/cryptoIconSize.js +40 -0
- package/lib/helpers/cryptoIconSize.js.map +1 -0
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.d.ts.map +1 -1
- package/lib/helpers.js +15 -0
- package/lib/helpers.js.map +1 -1
- package/lib/hooks/useHtmlLinkSegments.d.ts +19 -0
- package/lib/hooks/useHtmlLinkSegments.d.ts.map +1 -0
- package/lib/hooks/useHtmlLinkSegments.js +128 -0
- package/lib/hooks/useHtmlLinkSegments.js.map +1 -0
- package/lib/hw/getAppAndVersion.d.ts +3 -1
- package/lib/hw/getAppAndVersion.d.ts.map +1 -1
- package/lib/hw/getAppAndVersion.js +2 -2
- package/lib/hw/getAppAndVersion.js.map +1 -1
- package/lib/hw/getBitcoinLikeInfo.js +1 -1
- package/lib/hw/getBitcoinLikeInfo.js.map +1 -1
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +1 -0
- package/lib/load/speculos.js.map +1 -1
- package/lib/mock/account.js +1 -1
- package/lib/mock/account.js.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +6 -0
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +7 -2
- package/lib/operation.js.map +1 -1
- package/lib/postOnboarding/reducer.d.ts +2 -0
- package/lib/postOnboarding/reducer.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/SwapError.d.ts +93 -0
- package/lib/wallet-api/Exchange/SwapError.d.ts.map +1 -0
- package/lib/wallet-api/Exchange/SwapError.js +142 -0
- package/lib/wallet-api/Exchange/SwapError.js.map +1 -0
- package/lib/wallet-api/Exchange/handleSwapErrors.d.ts +40 -0
- package/lib/wallet-api/Exchange/handleSwapErrors.d.ts.map +1 -0
- package/lib/wallet-api/Exchange/handleSwapErrors.js +112 -0
- package/lib/wallet-api/Exchange/handleSwapErrors.js.map +1 -0
- package/lib/wallet-api/Exchange/index.d.ts +4 -0
- package/lib/wallet-api/Exchange/index.d.ts.map +1 -0
- package/lib/wallet-api/Exchange/index.js +27 -0
- package/lib/wallet-api/Exchange/index.js.map +1 -0
- package/lib/wallet-api/Exchange/parser.d.ts +46 -0
- package/lib/wallet-api/Exchange/parser.d.ts.map +1 -0
- package/lib/wallet-api/Exchange/parser.js +97 -0
- package/lib/wallet-api/Exchange/parser.js.map +1 -0
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +227 -174
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/Exchange/tracking.d.ts +7 -6
- package/lib/wallet-api/Exchange/tracking.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/tracking.js +52 -13
- package/lib/wallet-api/Exchange/tracking.js.map +1 -1
- package/lib/wallet-api/constants.d.ts +1 -1
- package/lib/wallet-api/logic.d.ts +1 -1
- package/lib/wallet-api/logic.d.ts.map +1 -1
- package/lib/wallet-api/logic.js +5 -5
- package/lib/wallet-api/logic.js.map +1 -1
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +9 -6
- package/lib/wallet-api/react.js.map +1 -1
- package/lib/wallet-api/tracking.d.ts +5 -5
- package/lib/wallet-api/tracking.d.ts.map +1 -1
- package/lib/wallet-api/tracking.js +30 -10
- package/lib/wallet-api/tracking.js.map +1 -1
- package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib/wallet-api/useDappLogic.js +31 -20
- package/lib/wallet-api/useDappLogic.js.map +1 -1
- package/lib/wallet-api/utils/extractDappURLFromManifest.js +3 -3
- package/lib/wallet-api/utils/extractDappURLFromManifest.js.map +1 -1
- package/lib/wallet-api/utils/extractURLFromManifest.js +1 -1
- package/lib/wallet-api/utils/extractURLFromManifest.js.map +1 -1
- package/lib/walletSync/getEnvironmentParams.js +6 -6
- package/lib/walletSync/getEnvironmentParams.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/__tests__/test-helpers/environment.js +3 -0
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/account/index.d.ts +1 -0
- package/lib-es/account/index.d.ts.map +1 -1
- package/lib-es/account/index.js +1 -0
- package/lib-es/account/index.js.map +1 -1
- package/lib-es/account/recentAddresses.d.ts +10 -0
- package/lib-es/account/recentAddresses.d.ts.map +1 -0
- package/lib-es/account/recentAddresses.js +55 -0
- package/lib-es/account/recentAddresses.js.map +1 -0
- package/lib-es/account/serialization.js +1 -1
- package/lib-es/account/serialization.js.map +1 -1
- package/lib-es/account/support.js +1 -1
- package/lib-es/account/support.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.js +2 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.js +3 -3
- package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.js +3 -3
- package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +24 -8
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +16 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/postSync.d.ts +16 -0
- package/lib-es/bridge/generic-alpaca/postSync.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/postSync.js +37 -0
- package/lib-es/bridge/generic-alpaca/postSync.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +45 -4
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +18 -2
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/Eth.js +4 -0
- package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.js +7 -0
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/types.d.ts +4 -0
- package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +12 -3
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +14 -3
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/currencies/helpers.d.ts +1 -0
- package/lib-es/currencies/helpers.d.ts.map +1 -1
- package/lib-es/currencies/helpers.js +5 -0
- package/lib-es/currencies/helpers.js.map +1 -1
- package/lib-es/domain/getTokensWithFunds.d.ts +7 -1
- package/lib-es/domain/getTokensWithFunds.d.ts.map +1 -1
- package/lib-es/domain/getTokensWithFunds.js +13 -3
- package/lib-es/domain/getTokensWithFunds.js.map +1 -1
- package/lib-es/domain/getTotalStakeableAssets.d.ts +10 -0
- package/lib-es/domain/getTotalStakeableAssets.d.ts.map +1 -0
- package/lib-es/domain/getTotalStakeableAssets.js +31 -0
- package/lib-es/domain/getTotalStakeableAssets.js.map +1 -0
- package/lib-es/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.js +1 -0
- package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib-es/e2e/data/regexes.d.ts +2 -0
- package/lib-es/e2e/data/regexes.d.ts.map +1 -0
- package/lib-es/e2e/data/regexes.js +2 -0
- package/lib-es/e2e/data/regexes.js.map +1 -0
- package/lib-es/e2e/enum/Device.d.ts +1 -0
- package/lib-es/e2e/enum/Device.d.ts.map +1 -1
- package/lib-es/e2e/enum/Device.js +1 -0
- package/lib-es/e2e/enum/Device.js.map +1 -1
- package/lib-es/e2e/families/cardano.d.ts.map +1 -1
- package/lib-es/e2e/families/cardano.js +29 -14
- package/lib-es/e2e/families/cardano.js.map +1 -1
- package/lib-es/e2e/index.d.ts +35 -3
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/index.js +16 -0
- package/lib-es/e2e/index.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +31 -4
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosAppVersion.d.ts.map +1 -1
- package/lib-es/e2e/speculosAppVersion.js +6 -2
- package/lib-es/e2e/speculosAppVersion.js.map +1 -1
- package/lib-es/e2e/swap.d.ts.map +1 -1
- package/lib-es/e2e/swap.js +7 -6
- package/lib-es/e2e/swap.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js +1 -1
- package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib-es/exchange/swap/postSwapState.js +10 -6
- package/lib-es/exchange/swap/postSwapState.js.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts +3 -2
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.js +26 -7
- package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +3 -1
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
- package/lib-es/families/bitcoin/walletApiAdapter.js +3 -0
- package/lib-es/families/bitcoin/walletApiAdapter.js.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +4 -4
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/canton/react.d.ts +2 -0
- package/lib-es/families/canton/react.d.ts.map +1 -1
- package/lib-es/families/canton/react.js +38 -1
- package/lib-es/families/canton/react.js.map +1 -1
- package/lib-es/families/celo/setup.d.ts.map +1 -1
- package/lib-es/families/celo/setup.js +11 -0
- package/lib-es/families/celo/setup.js.map +1 -1
- package/lib-es/families/evm/bridge/mock.d.ts +1 -0
- package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/evm/bridge/mock.js +12 -0
- package/lib-es/families/evm/bridge/mock.js.map +1 -1
- package/lib-es/families/evm/setup.d.ts +1 -4
- package/lib-es/families/evm/setup.d.ts.map +1 -1
- package/lib-es/families/evm/setup.js +2 -8
- package/lib-es/families/evm/setup.js.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.d.ts +7 -0
- package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.js +30 -1
- package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
- package/lib-es/families/hedera/react.d.ts +6 -0
- package/lib-es/families/hedera/react.d.ts.map +1 -0
- package/lib-es/families/hedera/react.js +41 -0
- package/lib-es/families/hedera/react.js.map +1 -0
- package/lib-es/families/polkadot/config.js +1 -1
- package/lib-es/families/polkadot/config.js.map +1 -1
- package/lib-es/families/stacks/constants.d.ts +1 -1
- package/lib-es/families/stacks/constants.d.ts.map +1 -1
- package/lib-es/families/stacks/constants.js +1 -1
- package/lib-es/families/stacks/constants.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +2 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +22 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/firebaseFeatureFlags.js +1 -1
- package/lib-es/featureFlags/firebaseFeatureFlags.js.map +1 -1
- package/lib-es/featureFlags/stakePrograms/index.js +4 -4
- package/lib-es/featureFlags/stakePrograms/index.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/featureFlags/useHasOverriddenFeatureFlags.js +1 -1
- package/lib-es/featureFlags/useHasOverriddenFeatureFlags.js.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +0 -1
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +0 -2
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/generated/bridge/mock.d.ts +1 -0
- package/lib-es/generated/bridge/mock.d.ts.map +1 -1
- package/lib-es/helpers/cryptoIconSize.d.ts +3 -0
- package/lib-es/helpers/cryptoIconSize.d.ts.map +1 -0
- package/lib-es/helpers/cryptoIconSize.js +35 -0
- package/lib-es/helpers/cryptoIconSize.js.map +1 -0
- package/lib-es/helpers.d.ts +1 -0
- package/lib-es/helpers.d.ts.map +1 -1
- package/lib-es/helpers.js +1 -0
- package/lib-es/helpers.js.map +1 -1
- package/lib-es/hooks/useHtmlLinkSegments.d.ts +19 -0
- package/lib-es/hooks/useHtmlLinkSegments.d.ts.map +1 -0
- package/lib-es/hooks/useHtmlLinkSegments.js +121 -0
- package/lib-es/hooks/useHtmlLinkSegments.js.map +1 -0
- package/lib-es/hw/getAppAndVersion.d.ts +3 -1
- package/lib-es/hw/getAppAndVersion.d.ts.map +1 -1
- package/lib-es/hw/getAppAndVersion.js +2 -2
- package/lib-es/hw/getAppAndVersion.js.map +1 -1
- package/lib-es/hw/getBitcoinLikeInfo.js +1 -1
- package/lib-es/hw/getBitcoinLikeInfo.js.map +1 -1
- package/lib-es/load/speculos.d.ts.map +1 -1
- package/lib-es/load/speculos.js +1 -0
- package/lib-es/load/speculos.js.map +1 -1
- package/lib-es/mock/account.js +1 -1
- package/lib-es/mock/account.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +6 -0
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib-es/operation.d.ts.map +1 -1
- package/lib-es/operation.js +7 -2
- package/lib-es/operation.js.map +1 -1
- package/lib-es/postOnboarding/reducer.d.ts +2 -0
- package/lib-es/postOnboarding/reducer.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/SwapError.d.ts +93 -0
- package/lib-es/wallet-api/Exchange/SwapError.d.ts.map +1 -0
- package/lib-es/wallet-api/Exchange/SwapError.js +128 -0
- package/lib-es/wallet-api/Exchange/SwapError.js.map +1 -0
- package/lib-es/wallet-api/Exchange/handleSwapErrors.d.ts +40 -0
- package/lib-es/wallet-api/Exchange/handleSwapErrors.d.ts.map +1 -0
- package/lib-es/wallet-api/Exchange/handleSwapErrors.js +106 -0
- package/lib-es/wallet-api/Exchange/handleSwapErrors.js.map +1 -0
- package/lib-es/wallet-api/Exchange/index.d.ts +4 -0
- package/lib-es/wallet-api/Exchange/index.d.ts.map +1 -0
- package/lib-es/wallet-api/Exchange/index.js +7 -0
- package/lib-es/wallet-api/Exchange/index.js.map +1 -0
- package/lib-es/wallet-api/Exchange/parser.d.ts +46 -0
- package/lib-es/wallet-api/Exchange/parser.d.ts.map +1 -0
- package/lib-es/wallet-api/Exchange/parser.js +90 -0
- package/lib-es/wallet-api/Exchange/parser.js.map +1 -0
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +224 -174
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/Exchange/tracking.d.ts +7 -6
- package/lib-es/wallet-api/Exchange/tracking.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/tracking.js +52 -13
- package/lib-es/wallet-api/Exchange/tracking.js.map +1 -1
- package/lib-es/wallet-api/constants.d.ts +1 -1
- package/lib-es/wallet-api/logic.d.ts +1 -1
- package/lib-es/wallet-api/logic.d.ts.map +1 -1
- package/lib-es/wallet-api/logic.js +5 -5
- package/lib-es/wallet-api/logic.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +9 -6
- package/lib-es/wallet-api/react.js.map +1 -1
- package/lib-es/wallet-api/tracking.d.ts +5 -5
- package/lib-es/wallet-api/tracking.d.ts.map +1 -1
- package/lib-es/wallet-api/tracking.js +30 -10
- package/lib-es/wallet-api/tracking.js.map +1 -1
- package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib-es/wallet-api/useDappLogic.js +31 -20
- package/lib-es/wallet-api/useDappLogic.js.map +1 -1
- package/lib-es/wallet-api/utils/extractDappURLFromManifest.js +3 -3
- package/lib-es/wallet-api/utils/extractDappURLFromManifest.js.map +1 -1
- package/lib-es/wallet-api/utils/extractURLFromManifest.js +1 -1
- package/lib-es/wallet-api/utils/extractURLFromManifest.js.map +1 -1
- package/lib-es/walletSync/getEnvironmentParams.js +6 -6
- package/lib-es/walletSync/getEnvironmentParams.js.map +1 -1
- package/package.json +82 -90
- package/src/__tests__/test-helpers/bridge.ts +1 -1
- package/src/__tests__/test-helpers/environment.ts +3 -0
- package/src/account/index.ts +6 -0
- package/src/account/recentAddresses.test.ts +104 -0
- package/src/account/recentAddresses.ts +84 -0
- package/src/account/serialization.ts +1 -1
- package/src/account/support.ts +1 -1
- package/src/bridge/generic-alpaca/accountBridge.ts +3 -2
- package/src/bridge/generic-alpaca/broadcast.ts +6 -3
- package/src/bridge/generic-alpaca/currencyBridge.ts +3 -3
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +2 -1
- package/src/bridge/generic-alpaca/getAccountShape.ts +36 -13
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +16 -1
- package/src/bridge/generic-alpaca/postSync.test.ts +97 -0
- package/src/bridge/generic-alpaca/postSync.ts +42 -0
- package/src/bridge/generic-alpaca/prepareTransaction.ts +51 -10
- package/src/bridge/generic-alpaca/signOperation.ts +18 -2
- package/src/bridge/generic-alpaca/signer/Eth.ts +5 -1
- package/src/bridge/generic-alpaca/signer/index.ts +7 -0
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +43 -10
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +74 -0
- package/src/bridge/generic-alpaca/types.ts +4 -0
- package/src/bridge/generic-alpaca/utils.test.ts +4 -0
- package/src/bridge/generic-alpaca/utils.ts +15 -3
- package/src/bridge/impl.ts +16 -3
- package/src/currencies/helpers.test.ts +10 -1
- package/src/currencies/helpers.ts +6 -0
- package/src/domain/getTokensWithFunds.ts +18 -5
- package/src/domain/getTotalStakeableAssets.test.ts +267 -0
- package/src/domain/getTotalStakeableAssets.ts +47 -0
- package/src/e2e/data/deviceLabelsData.ts +1 -0
- package/src/e2e/data/regexes.ts +1 -0
- package/src/e2e/enum/Device.ts +1 -0
- package/src/e2e/families/cardano.ts +32 -14
- package/src/e2e/index.ts +20 -0
- package/src/e2e/speculos.ts +35 -4
- package/src/e2e/speculosAppVersion.ts +8 -2
- package/src/e2e/swap.ts +8 -7
- package/src/exchange/swap/api/v5/fetchCurrencyFrom.ts +1 -1
- package/src/exchange/swap/getIncompatibleCurrencyKeys.ts +4 -0
- package/src/exchange/swap/postSwapState.ts +10 -5
- package/src/exchange/swap/transactionStrategies.ts +30 -7
- package/src/exchange/swap/types.ts +3 -1
- package/src/families/bitcoin/walletApiAdapter.test.ts +36 -0
- package/src/families/bitcoin/walletApiAdapter.ts +4 -0
- package/src/families/canton/config.ts +5 -4
- package/src/families/canton/react.test.ts +147 -0
- package/src/families/canton/react.ts +45 -1
- package/src/families/celo/setup.ts +12 -0
- package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +73 -4
- package/src/families/cosmos/datasets/__snapshots__/cryptoOrg.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/injective.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/osmosis.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/persistence.integration.test.ts.snap +4 -4
- package/src/families/cosmos/datasets/__snapshots__/stargaze.integration.test.ts.snap +2 -2
- package/src/families/evm/bridge/mock.ts +14 -0
- package/src/families/evm/setup.ts +3 -22
- package/src/families/evm/walletApiAdapter.ts +33 -1
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +278 -17
- package/src/families/hedera/react.test.ts +272 -0
- package/src/families/hedera/react.ts +63 -0
- package/src/families/polkadot/__snapshots__/bridge.integration.test.ts.snap +6 -3653
- package/src/families/polkadot/config.ts +1 -1
- package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +1537 -18
- package/src/families/stacks/__tests__/sync.integration.test.ts +2 -2
- package/src/families/stacks/constants.ts +1 -1
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +9 -9
- package/src/featureFlags/defaultFeatures.ts +22 -1
- package/src/featureFlags/firebaseFeatureFlags.ts +1 -1
- package/src/featureFlags/stakePrograms/index.ts +4 -4
- package/src/featureFlags/useHasOverriddenFeatureFlags.ts +1 -1
- package/src/generated/bridge/js.ts +0 -2
- package/src/helpers/cryptoIconSize.ts +25 -0
- package/src/helpers.ts +2 -0
- package/src/hooks/__tests__/useHtmlLinkSegments.test.ts +105 -0
- package/src/hooks/useHtmlLinkSegments.ts +158 -0
- package/src/hw/getAppAndVersion.ts +2 -1
- package/src/hw/getBitcoinLikeInfo.ts +1 -1
- package/src/load/speculos.ts +1 -0
- package/src/mock/account.ts +1 -1
- package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +6 -0
- package/src/operation.ts +10 -2
- package/src/wallet-api/Exchange/SwapError.test.ts +126 -0
- package/src/wallet-api/Exchange/SwapError.ts +159 -0
- package/src/wallet-api/Exchange/handleSwapErrors.test.ts +46 -0
- package/src/wallet-api/Exchange/handleSwapErrors.ts +161 -0
- package/src/wallet-api/Exchange/index.ts +26 -0
- package/src/wallet-api/Exchange/parser.test.ts +86 -0
- package/src/wallet-api/Exchange/parser.ts +119 -0
- package/src/wallet-api/Exchange/server.ts +289 -232
- package/src/wallet-api/Exchange/tracking.ts +56 -13
- package/src/wallet-api/logic.ts +5 -4
- package/src/wallet-api/react.ts +10 -5
- package/src/wallet-api/tracking.ts +30 -10
- package/src/wallet-api/useDappLogic.ts +32 -20
- package/src/wallet-api/utils/extractDappURLFromManifest.ts +3 -3
- package/src/wallet-api/utils/extractURLFromManifest.ts +1 -1
- package/src/walletSync/getEnvironmentParams.ts +6 -6
- package/lib/currencies/cryptoIcons.d.ts +0 -3
- package/lib/currencies/cryptoIcons.d.ts.map +0 -1
- package/lib/currencies/cryptoIcons.js +0 -24
- package/lib/currencies/cryptoIcons.js.map +0 -1
- package/lib/react.d.ts +0 -16
- package/lib/react.d.ts.map +0 -1
- package/lib/react.js +0 -64
- package/lib/react.js.map +0 -1
- package/lib/reactNative.d.ts +0 -16
- package/lib/reactNative.d.ts.map +0 -1
- package/lib/reactNative.js +0 -43
- package/lib/reactNative.js.map +0 -1
- package/lib-es/currencies/cryptoIcons.d.ts +0 -3
- package/lib-es/currencies/cryptoIcons.d.ts.map +0 -1
- package/lib-es/currencies/cryptoIcons.js +0 -20
- package/lib-es/currencies/cryptoIcons.js.map +0 -1
- package/lib-es/react.d.ts +0 -16
- package/lib-es/react.d.ts.map +0 -1
- package/lib-es/react.js +0 -33
- package/lib-es/react.js.map +0 -1
- package/lib-es/reactNative.d.ts +0 -16
- package/lib-es/reactNative.d.ts.map +0 -1
- package/lib-es/reactNative.js +0 -15
- package/lib-es/reactNative.js.map +0 -1
- package/react.js +0 -1
- package/reactNative.js +0 -1
- package/src/currencies/cryptoIcons.test.ts +0 -54
- package/src/currencies/cryptoIcons.ts +0 -21
- package/src/react.tsx +0 -43
- package/src/reactNative.ts +0 -23
- package/src/reactNativeSvg.d.ts +0 -19
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { RecentAddressesStore, setupRecentAddressesStore, getRecentAddressesStore } from ".";
|
|
2
|
+
import { RECENT_ADDRESSES_COUNT_LIMIT } from "./recentAddresses";
|
|
3
|
+
|
|
4
|
+
describe("RecentAddressesStore", () => {
|
|
5
|
+
const onAddAddressCompleteMock = jest.fn();
|
|
6
|
+
let store: RecentAddressesStore;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
onAddAddressCompleteMock.mockClear();
|
|
10
|
+
setupRecentAddressesStore({}, onAddAddressCompleteMock);
|
|
11
|
+
store = getRecentAddressesStore();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should add one address and return this only address", async () => {
|
|
15
|
+
const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
|
|
16
|
+
await store.addAddress("ethereum", newAddress);
|
|
17
|
+
const addresses = store.getAddresses("ethereum");
|
|
18
|
+
expect(addresses).toEqual([newAddress]);
|
|
19
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
|
|
20
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should add a second address and return addresses sorted by insertion", async () => {
|
|
24
|
+
const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
|
|
25
|
+
await store.addAddress("ethereum", newAddress);
|
|
26
|
+
let addresses = store.getAddresses("ethereum");
|
|
27
|
+
expect(addresses).toEqual([newAddress]);
|
|
28
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
|
|
29
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
|
|
30
|
+
|
|
31
|
+
const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
|
|
32
|
+
await store.addAddress("ethereum", newAddress2);
|
|
33
|
+
addresses = store.getAddresses("ethereum");
|
|
34
|
+
expect(addresses).toEqual([newAddress2, newAddress]);
|
|
35
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
|
|
36
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress2, newAddress] });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should replace at first place when an address is already saved", async () => {
|
|
40
|
+
const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
|
|
41
|
+
await store.addAddress("ethereum", newAddress);
|
|
42
|
+
let addresses = store.getAddresses("ethereum");
|
|
43
|
+
expect(addresses).toEqual([newAddress]);
|
|
44
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
|
|
45
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
|
|
46
|
+
|
|
47
|
+
const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
|
|
48
|
+
await store.addAddress("ethereum", newAddress2);
|
|
49
|
+
addresses = store.getAddresses("ethereum");
|
|
50
|
+
expect(addresses).toEqual([newAddress2, newAddress]);
|
|
51
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
|
|
52
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress2, newAddress] });
|
|
53
|
+
|
|
54
|
+
await store.addAddress("ethereum", newAddress);
|
|
55
|
+
addresses = store.getAddresses("ethereum");
|
|
56
|
+
expect(addresses).toEqual([newAddress, newAddress2]);
|
|
57
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(3);
|
|
58
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress, newAddress2] });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should replace at first place and remove last element when addresses exceed count limit", async () => {
|
|
62
|
+
let expectedAddresses: string[] = [];
|
|
63
|
+
for (let index = 0; index < RECENT_ADDRESSES_COUNT_LIMIT; index++) {
|
|
64
|
+
await store.addAddress("ethereum", `0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3${index}`);
|
|
65
|
+
expectedAddresses.unshift(`0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3${index}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let addresses = store.getAddresses("ethereum");
|
|
69
|
+
expect(addresses).toEqual(expectedAddresses);
|
|
70
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(RECENT_ADDRESSES_COUNT_LIMIT);
|
|
71
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: expectedAddresses });
|
|
72
|
+
|
|
73
|
+
const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
|
|
74
|
+
expectedAddresses.splice(expectedAddresses.length - 1, 1);
|
|
75
|
+
expectedAddresses = [newAddress2, ...expectedAddresses];
|
|
76
|
+
|
|
77
|
+
await store.addAddress("ethereum", newAddress2);
|
|
78
|
+
addresses = store.getAddresses("ethereum");
|
|
79
|
+
expect(addresses).toEqual(expectedAddresses);
|
|
80
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(RECENT_ADDRESSES_COUNT_LIMIT + 1);
|
|
81
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: expectedAddresses });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should add an address of a different currency", async () => {
|
|
85
|
+
const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
|
|
86
|
+
await store.addAddress("ethereum", newAddress);
|
|
87
|
+
|
|
88
|
+
let addresses = store.getAddresses("ethereum");
|
|
89
|
+
expect(addresses).toEqual([newAddress]);
|
|
90
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
|
|
92
|
+
|
|
93
|
+
const newAddress2 = "bc1pxlmrudqyq8qd8pfsc4mpmlaw56x6vtcr9m8nvp8kj3gckefc4kmqhkg4l7";
|
|
94
|
+
await store.addAddress("bitcoin", newAddress2);
|
|
95
|
+
|
|
96
|
+
addresses = store.getAddresses("bitcoin");
|
|
97
|
+
expect(addresses).toEqual([newAddress2]);
|
|
98
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
|
|
99
|
+
expect(onAddAddressCompleteMock).toHaveBeenCalledWith({
|
|
100
|
+
ethereum: [newAddress],
|
|
101
|
+
bitcoin: [newAddress2],
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const RECENT_ADDRESSES_COUNT_LIMIT = 12;
|
|
2
|
+
|
|
3
|
+
export type RecentAddressesCache = Record<string, string[]>;
|
|
4
|
+
|
|
5
|
+
export interface RecentAddressesStore {
|
|
6
|
+
addAddress(currency: string, address: string): void;
|
|
7
|
+
syncAddresses(cache: RecentAddressesCache): void;
|
|
8
|
+
getAddresses(currency: string): string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type CallbackMode = "triggerCallback" | "skipCallback";
|
|
12
|
+
|
|
13
|
+
let recentAddressesStore: RecentAddressesStore | null = null;
|
|
14
|
+
|
|
15
|
+
export function getRecentAddressesStore(): RecentAddressesStore {
|
|
16
|
+
if (recentAddressesStore === null) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Recent addresses store instance is null, please call function setupRecentAddressesStore in application initialization",
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return recentAddressesStore;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function setupRecentAddressesStore(
|
|
25
|
+
addressesByCurrency: RecentAddressesCache,
|
|
26
|
+
onAddAddressComplete: (addressesByCurrency: RecentAddressesCache) => void,
|
|
27
|
+
): void {
|
|
28
|
+
recentAddressesStore = new RecentAddressesStoreImpl(addressesByCurrency, onAddAddressComplete);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class RecentAddressesStoreImpl implements RecentAddressesStore {
|
|
32
|
+
private addressesByCurrency: RecentAddressesCache = {};
|
|
33
|
+
private readonly onAddAddressComplete: (addressesByCurrency: Record<string, string[]>) => void;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
addressesByCurrency: RecentAddressesCache,
|
|
37
|
+
onAddAddressComplete: (addressesByCurrency: RecentAddressesCache) => void,
|
|
38
|
+
) {
|
|
39
|
+
this.addressesByCurrency = { ...addressesByCurrency };
|
|
40
|
+
this.onAddAddressComplete = onAddAddressComplete;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
addAddress(currency: string, address: string): void {
|
|
44
|
+
this.addAddressToCache(currency, address, "triggerCallback");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
syncAddresses(cache: RecentAddressesCache): void {
|
|
48
|
+
const previousAddresses = { ...this.addressesByCurrency };
|
|
49
|
+
this.addressesByCurrency = { ...cache };
|
|
50
|
+
for (const currency in previousAddresses) {
|
|
51
|
+
for (const address of previousAddresses[currency]) {
|
|
52
|
+
this.addAddressToCache(currency, address, "skipCallback");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.onAddAddressComplete(this.addressesByCurrency);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getAddresses(currency: string): string[] {
|
|
60
|
+
const addresses = this.addressesByCurrency[currency];
|
|
61
|
+
return addresses ?? [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private addAddressToCache(currency: string, address: string, callbackMode: CallbackMode): void {
|
|
65
|
+
if (!this.addressesByCurrency[currency]) {
|
|
66
|
+
this.addressesByCurrency[currency] = [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const addresses = this.addressesByCurrency[currency];
|
|
70
|
+
const addressIndex = addresses.indexOf(address);
|
|
71
|
+
if (addressIndex !== -1) {
|
|
72
|
+
addresses.splice(addressIndex, 1);
|
|
73
|
+
} else if (addresses.length >= RECENT_ADDRESSES_COUNT_LIMIT) {
|
|
74
|
+
addresses.pop();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
addresses.unshift(address);
|
|
78
|
+
this.addressesByCurrency[currency] = [...addresses];
|
|
79
|
+
|
|
80
|
+
if (callbackMode === "triggerCallback") {
|
|
81
|
+
this.onAddAddressComplete(this.addressesByCurrency);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -99,7 +99,7 @@ const inferFamilyFromAccountId: (accountId: string) => string | null | undefined
|
|
|
99
99
|
try {
|
|
100
100
|
const { currencyId } = decodeAccountId(accountId);
|
|
101
101
|
return getCryptoCurrencyById(currencyId).family;
|
|
102
|
-
} catch
|
|
102
|
+
} catch {
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
},
|
package/src/account/support.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountBridge } from "@ledgerhq/types-live";
|
|
1
|
+
import type { AccountBridge } from "@ledgerhq/types-live";
|
|
2
2
|
import { makeSync } from "../jsHelpers";
|
|
3
3
|
import { genericGetAccountShape } from "./getAccountShape";
|
|
4
4
|
import {
|
|
@@ -16,6 +16,7 @@ import { genericBroadcast } from "./broadcast";
|
|
|
16
16
|
import { genericSignOperation } from "./signOperation";
|
|
17
17
|
import { genericSignRawOperation } from "./signRawOperation";
|
|
18
18
|
import type { AlpacaSigner } from "./signer/types";
|
|
19
|
+
import { postSync } from "./postSync";
|
|
19
20
|
|
|
20
21
|
export function getAlpacaAccountBridge(
|
|
21
22
|
network: string,
|
|
@@ -24,7 +25,7 @@ export function getAlpacaAccountBridge(
|
|
|
24
25
|
): AccountBridge<any> {
|
|
25
26
|
const signer = customSigner ?? getSigner(network);
|
|
26
27
|
return {
|
|
27
|
-
sync: makeSync({ getAccountShape: genericGetAccountShape(network, kind) }),
|
|
28
|
+
sync: makeSync({ getAccountShape: genericGetAccountShape(network, kind), postSync }),
|
|
28
29
|
receive: makeAccountBridgeReceive(getAddressWrapper(signer.getAddress)),
|
|
29
30
|
createTransaction: createTransaction,
|
|
30
31
|
updateTransaction: updateTransaction<any>,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AccountBridge, TransactionCommon } from "@ledgerhq/types-live";
|
|
2
|
-
import { patchOperationWithHash } from "
|
|
2
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
3
|
import { getAlpacaApi } from "./alpaca";
|
|
4
4
|
|
|
5
5
|
export const genericBroadcast: (network, kind) => AccountBridge<TransactionCommon>["broadcast"] =
|
|
6
6
|
(network, kind) =>
|
|
7
|
-
async ({ signedOperation: { signature, operation }, account }) => {
|
|
8
|
-
const hash = await getAlpacaApi(account.currency.id, kind).broadcast(
|
|
7
|
+
async ({ signedOperation: { signature, operation }, account, broadcastConfig }) => {
|
|
8
|
+
const hash = await getAlpacaApi(account.currency.id, kind).broadcast(
|
|
9
|
+
signature,
|
|
10
|
+
broadcastConfig,
|
|
11
|
+
);
|
|
9
12
|
|
|
10
13
|
return patchOperationWithHash(operation, hash);
|
|
11
14
|
};
|
|
@@ -3,6 +3,7 @@ import { CurrencyBridge } from "@ledgerhq/types-live";
|
|
|
3
3
|
import { genericGetAccountShape } from "./getAccountShape";
|
|
4
4
|
import { getSigner } from "./signer";
|
|
5
5
|
import type { AlpacaSigner } from "./signer/types";
|
|
6
|
+
import { postSync } from "./postSync";
|
|
6
7
|
|
|
7
8
|
export function getAlpacaCurrencyBridge(
|
|
8
9
|
network: string,
|
|
@@ -12,12 +13,11 @@ export function getAlpacaCurrencyBridge(
|
|
|
12
13
|
const signer = customSigner ?? getSigner(network);
|
|
13
14
|
return {
|
|
14
15
|
preload: () => Promise.resolve({}),
|
|
15
|
-
hydrate: () =>
|
|
16
|
-
return;
|
|
17
|
-
},
|
|
16
|
+
hydrate: () => undefined,
|
|
18
17
|
scanAccounts: makeScanAccounts({
|
|
19
18
|
getAccountShape: genericGetAccountShape(network, kind),
|
|
20
19
|
getAddressFn: signer.getAddress.bind(signer),
|
|
20
|
+
postSync,
|
|
21
21
|
}),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -30,11 +30,12 @@ export function genericEstimateMaxSpendable(
|
|
|
30
30
|
)
|
|
31
31
|
).value;
|
|
32
32
|
}
|
|
33
|
+
// TODO Remove the call to `validateIntent` https://ledgerhq.atlassian.net/browse/LIVE-22229
|
|
33
34
|
const { amount } = await alpacaApi.validateIntent(
|
|
34
35
|
transactionToIntent(account, { ...draftTransaction }, alpacaApi.computeIntentType),
|
|
35
36
|
{ value: transaction?.fees ? BigInt(transaction.fees.toString()) : 0n },
|
|
36
37
|
);
|
|
37
|
-
if (["stellar", "tezos"].includes(network)) {
|
|
38
|
+
if (["stellar", "tezos", "evm"].includes(network)) {
|
|
38
39
|
return amount > 0 ? new BigNumber(amount.toString()) : new BigNumber(0);
|
|
39
40
|
}
|
|
40
41
|
const bnFee = BigNumber(fees.toString());
|
|
@@ -17,6 +17,19 @@ function isNftCoreOp(operation: Operation): boolean {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function isIncomingCoreOp(operation: Operation): boolean {
|
|
21
|
+
const type =
|
|
22
|
+
typeof operation.details?.ledgerOpType === "string"
|
|
23
|
+
? operation.details.ledgerOpType
|
|
24
|
+
: operation.type;
|
|
25
|
+
|
|
26
|
+
return type === "IN";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isInternalLiveOp(operation: OperationCommon): boolean {
|
|
30
|
+
return !!operation.extra?.internal;
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
export function genericGetAccountShape(network: string, kind: string): GetAccountShape {
|
|
21
34
|
return async (info, syncConfig) => {
|
|
22
35
|
const { address, initialAccount, currency, derivationMode } = info;
|
|
@@ -58,14 +71,14 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
|
58
71
|
|
|
59
72
|
// Calculate minHeight for pagination
|
|
60
73
|
const minHeight = syncFromScratch ? 0 : (oldOps[0]?.blockHeight ?? 0) + 1;
|
|
61
|
-
const paginationParams: Pagination = { minHeight, order: "
|
|
74
|
+
const paginationParams: Pagination = { minHeight, order: "desc" };
|
|
62
75
|
if (lastPagingToken && !syncFromScratch) {
|
|
63
76
|
paginationParams.lastPagingToken = lastPagingToken;
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
const [newCoreOps] = await alpacaApi.listOperations(address, paginationParams);
|
|
67
80
|
const newOps = newCoreOps
|
|
68
|
-
.filter(op => !isNftCoreOp(op))
|
|
81
|
+
.filter(op => !isNftCoreOp(op) && (!isIncomingCoreOp(op) || !op.tx.failed))
|
|
69
82
|
.map(op => adaptCoreOperationToLiveOperation(accountId, op)) as OperationCommon[];
|
|
70
83
|
|
|
71
84
|
const newAssetOperations = newOps.filter(
|
|
@@ -74,6 +87,7 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
|
74
87
|
operation?.extra?.assetOwner &&
|
|
75
88
|
!["OPT_IN", "OPT_OUT"].includes(operation.type),
|
|
76
89
|
);
|
|
90
|
+
const newInternalOperations = newOps.filter(isInternalLiveOp);
|
|
77
91
|
const newSubAccounts = await buildSubAccounts({
|
|
78
92
|
accountId,
|
|
79
93
|
allTokenAssetsBalances,
|
|
@@ -85,22 +99,31 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
|
85
99
|
? newSubAccounts
|
|
86
100
|
: mergeSubAccounts(initialAccount?.subAccounts ?? [], newSubAccounts);
|
|
87
101
|
|
|
88
|
-
const newOpsWithSubs = newOps
|
|
89
|
-
|
|
102
|
+
const newOpsWithSubs = newOps
|
|
103
|
+
.filter(operation => !isInternalLiveOp(operation))
|
|
104
|
+
.map(op => {
|
|
105
|
+
const subOperations = inferSubOperations(op.hash, newSubAccounts);
|
|
106
|
+
const internalOperations = newInternalOperations.filter(it => it.hash === op.hash);
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
return cleanedOperation({
|
|
109
|
+
...op,
|
|
110
|
+
subOperations,
|
|
111
|
+
internalOperations,
|
|
112
|
+
});
|
|
94
113
|
});
|
|
95
|
-
|
|
114
|
+
// Try to refresh known pending and broadcasted operations (if not already updated)
|
|
115
|
+
// Useful for integrations without explorers
|
|
116
|
+
const operationsToRefresh = initialAccount?.pendingOperations.filter(
|
|
117
|
+
pendingOp =>
|
|
118
|
+
pendingOp.hash && // operation has been broadcasted
|
|
119
|
+
!newOpsWithSubs.some(newOp => pendingOp.hash === newOp.hash), // operation is not confirmed yet
|
|
120
|
+
);
|
|
96
121
|
const confirmedOperations =
|
|
97
|
-
alpacaApi.refreshOperations &&
|
|
98
|
-
? await alpacaApi.refreshOperations(
|
|
122
|
+
alpacaApi.refreshOperations && operationsToRefresh?.length
|
|
123
|
+
? await alpacaApi.refreshOperations(operationsToRefresh)
|
|
99
124
|
: [];
|
|
100
125
|
const newOperations = [...confirmedOperations, ...newOpsWithSubs];
|
|
101
|
-
const operations = syncFromScratch
|
|
102
|
-
? newOperations
|
|
103
|
-
: (mergeOps(oldOps, newOperations) as OperationCommon[]);
|
|
126
|
+
const operations = mergeOps(syncFromScratch ? [] : oldOps, newOperations) as OperationCommon[];
|
|
104
127
|
|
|
105
128
|
const res: Partial<Account> = {
|
|
106
129
|
id: accountId,
|
|
@@ -26,6 +26,7 @@ export function genericGetTransactionStatus(
|
|
|
26
26
|
feesStrategy: transaction.feesStrategy,
|
|
27
27
|
data: transaction.data,
|
|
28
28
|
type: transaction.type,
|
|
29
|
+
sponsored: transaction.sponsored,
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
if (alpacaApi.getChainSpecificRules) {
|
|
@@ -37,10 +38,24 @@ export function genericGetTransactionStatus(
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
const fees = BigInt(transaction.fees?.toString() || "0");
|
|
42
|
+
const feesParameters = {
|
|
43
|
+
...(transaction.gasLimit ? { gasLimit: BigInt(transaction.gasLimit.toFixed()) } : {}),
|
|
44
|
+
...(transaction.gasPrice ? { gasPrice: BigInt(transaction.gasPrice.toFixed()) } : {}),
|
|
45
|
+
...(transaction.maxFeePerGas
|
|
46
|
+
? { maxFeePerGas: BigInt(transaction.maxFeePerGas.toFixed()) }
|
|
47
|
+
: {}),
|
|
48
|
+
...(transaction.maxPriorityFeePerGas
|
|
49
|
+
? { maxPriorityFeePerGas: BigInt(transaction.maxPriorityFeePerGas.toFixed()) }
|
|
50
|
+
: {}),
|
|
51
|
+
...(transaction.additionalFees
|
|
52
|
+
? { additionalFees: BigInt(transaction.additionalFees.toFixed()) }
|
|
53
|
+
: {}),
|
|
54
|
+
};
|
|
40
55
|
const { errors, warnings, estimatedFees, amount, totalSpent, totalFees } =
|
|
41
56
|
await alpacaApi.validateIntent(
|
|
42
57
|
transactionToIntent(account, draftTransaction, alpacaApi.computeIntentType),
|
|
43
|
-
{ value:
|
|
58
|
+
{ value: fees, parameters: feesParameters },
|
|
44
59
|
);
|
|
45
60
|
|
|
46
61
|
return {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import { postSync } from "./postSync";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
|
|
5
|
+
describe("postSync", () => {
|
|
6
|
+
it("removes confirmed and outdated native operations from the pending pool", () => {
|
|
7
|
+
const initialAccount = {
|
|
8
|
+
operations: [{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" }],
|
|
9
|
+
pendingOperations: [
|
|
10
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
|
|
11
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
|
|
12
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
13
|
+
],
|
|
14
|
+
} as Account;
|
|
15
|
+
const synced = {
|
|
16
|
+
operations: [
|
|
17
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
|
|
18
|
+
{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
|
|
19
|
+
],
|
|
20
|
+
pendingOperations: [
|
|
21
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
|
|
22
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
|
|
23
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
24
|
+
],
|
|
25
|
+
} as Account;
|
|
26
|
+
|
|
27
|
+
expect(postSync(initialAccount, synced)).toMatchObject({
|
|
28
|
+
operations: [
|
|
29
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
|
|
30
|
+
{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
|
|
31
|
+
],
|
|
32
|
+
pendingOperations: [
|
|
33
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("removes confirmed and outdated token operations from the pending pool", () => {
|
|
39
|
+
const initialAccount = {
|
|
40
|
+
operations: [{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" }],
|
|
41
|
+
pendingOperations: [
|
|
42
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "NONE" },
|
|
43
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
|
|
44
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
45
|
+
],
|
|
46
|
+
subAccounts: [
|
|
47
|
+
{
|
|
48
|
+
pendingOperations: [
|
|
49
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
|
|
50
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
} as Account;
|
|
55
|
+
const synced = {
|
|
56
|
+
operations: [
|
|
57
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
|
|
58
|
+
{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
|
|
59
|
+
],
|
|
60
|
+
pendingOperations: [
|
|
61
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "NONE" },
|
|
62
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
|
|
63
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
64
|
+
],
|
|
65
|
+
subAccounts: [
|
|
66
|
+
{
|
|
67
|
+
operations: [{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" }],
|
|
68
|
+
pendingOperations: [
|
|
69
|
+
{ hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
} as Account;
|
|
74
|
+
|
|
75
|
+
expect(postSync(initialAccount, synced)).toMatchObject({
|
|
76
|
+
operations: [
|
|
77
|
+
{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
|
|
78
|
+
{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
|
|
79
|
+
],
|
|
80
|
+
pendingOperations: [
|
|
81
|
+
{ hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
|
|
82
|
+
],
|
|
83
|
+
subAccounts: [
|
|
84
|
+
{
|
|
85
|
+
operations: [
|
|
86
|
+
{
|
|
87
|
+
hash: "hash1",
|
|
88
|
+
transactionSequenceNumber: new BigNumber(5),
|
|
89
|
+
type: "OUT",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
pendingOperations: [],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Account, AccountLike, Operation } from "@ledgerhq/types-live";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* After each sync or scan, remove operations from the pending pools if necessary
|
|
6
|
+
* Operations stay pending if and only if
|
|
7
|
+
* - they are confirmed, i.e. their hash appear in the operation list
|
|
8
|
+
* - they are not outdated, i.e. their sequence number is at least greater than the
|
|
9
|
+
* sequence number of the latest transaction
|
|
10
|
+
* NOTE Compared to the default behaviour
|
|
11
|
+
* - pending operations of token accounts are cleaned up, so we don't see both pending and completed
|
|
12
|
+
* sub operations in the operation details drawer
|
|
13
|
+
* - pending operations are cleaned if their hash already belong to the completed operations, preventing
|
|
14
|
+
* undesired replacement (ex: optimistic operation for self token sending on EVM is incomplete, since
|
|
15
|
+
* it only contains the OUT sub operation)
|
|
16
|
+
*/
|
|
17
|
+
export function postSync(initial: Account, synced: Account): Account {
|
|
18
|
+
const lastOperation = synced.operations.find(op => ["OUT", "FEES"].includes(op.type));
|
|
19
|
+
const latestSequence = lastOperation?.transactionSequenceNumber || new BigNumber(-1);
|
|
20
|
+
|
|
21
|
+
function isPending(account: AccountLike, op: Operation): boolean {
|
|
22
|
+
return (
|
|
23
|
+
// Operation is not confirmed
|
|
24
|
+
!account.operations.some(o => o.hash === op.hash) &&
|
|
25
|
+
// Operation is not outdated
|
|
26
|
+
op.transactionSequenceNumber !== undefined &&
|
|
27
|
+
op.transactionSequenceNumber.gt(latestSequence)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const pendingOperations = initial.pendingOperations.length
|
|
32
|
+
? initial.pendingOperations.filter(op => isPending(synced, op))
|
|
33
|
+
: [];
|
|
34
|
+
const subAccounts = synced.subAccounts?.length
|
|
35
|
+
? synced.subAccounts.map(subAccount => ({
|
|
36
|
+
...subAccount,
|
|
37
|
+
pendingOperations: subAccount.pendingOperations.filter(op => isPending(subAccount, op)),
|
|
38
|
+
}))
|
|
39
|
+
: [];
|
|
40
|
+
|
|
41
|
+
return { ...synced, pendingOperations, subAccounts };
|
|
42
|
+
}
|
|
@@ -31,6 +31,11 @@ function propagateField(estimation: FeeEstimation, field: string, dest: GenericT
|
|
|
31
31
|
dest[field] = Number(value.toString());
|
|
32
32
|
return;
|
|
33
33
|
case "storageLimit":
|
|
34
|
+
case "gasLimit":
|
|
35
|
+
case "gasPrice":
|
|
36
|
+
case "maxFeePerGas":
|
|
37
|
+
case "maxPriorityFeePerGas":
|
|
38
|
+
case "additionalFees":
|
|
34
39
|
dest[field] = new BigNumber(value.toString());
|
|
35
40
|
return;
|
|
36
41
|
default:
|
|
@@ -51,17 +56,42 @@ export function genericPrepareTransaction(
|
|
|
51
56
|
? await getAssetInfos(transaction, account.freshAddress, getAssetFromToken)
|
|
52
57
|
: assetInfosFallback(transaction);
|
|
53
58
|
const customParametersFees = transaction.customFees?.parameters?.fees;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Ticking `useAllAmount` constantly resets the amount to 0. This is problematic
|
|
62
|
+
* because some Blockchain need the actual transaction amount to compute the fees
|
|
63
|
+
* (Example with EVM and ERC20 transactions)
|
|
64
|
+
* In case of `useAllAmount` and token transaction, we read the token account spendable
|
|
65
|
+
* balance instead.
|
|
66
|
+
*/
|
|
67
|
+
let amount = transaction.amount;
|
|
68
|
+
if (transaction.useAllAmount && transaction.subAccountId) {
|
|
69
|
+
const subAccount = account.subAccounts?.find(acc => acc.id === transaction.subAccountId);
|
|
70
|
+
amount = subAccount?.spendableBalance ?? amount;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Pass any parameters that help estimating fees
|
|
74
|
+
// This includes `assetOwner` and `assetReference` that are not used by some apps that only rely on `subAccountId`
|
|
75
|
+
// TODO Remove `assetOwner` and `assetReference` in order to maintain one unique way of identifying the type of asset
|
|
76
|
+
// https://ledgerhq.atlassian.net/browse/LIVE-24044
|
|
77
|
+
const intent = transactionToIntent(
|
|
78
|
+
account,
|
|
79
|
+
{
|
|
80
|
+
...transaction,
|
|
81
|
+
assetOwner,
|
|
82
|
+
assetReference,
|
|
83
|
+
amount,
|
|
84
|
+
},
|
|
85
|
+
computeIntentType,
|
|
86
|
+
);
|
|
54
87
|
const estimation: FeeEstimation = customParametersFees
|
|
55
88
|
? { value: BigInt(customParametersFees.toFixed()) }
|
|
56
|
-
: await estimateFees(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
computeIntentType,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
89
|
+
: await estimateFees(intent, {
|
|
90
|
+
gasPrice: transaction.gasPrice,
|
|
91
|
+
maxFeePerGas: transaction.maxFeePerGas,
|
|
92
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
|
|
93
|
+
gasOptions: transaction.gasOptions,
|
|
94
|
+
});
|
|
65
95
|
const fees = new BigNumber(estimation.value.toString());
|
|
66
96
|
|
|
67
97
|
if (!bnEq(transaction.fees, fees)) {
|
|
@@ -78,7 +108,15 @@ export function genericPrepareTransaction(
|
|
|
78
108
|
};
|
|
79
109
|
|
|
80
110
|
// Propagate needed fields
|
|
81
|
-
const fieldsToPropagate = [
|
|
111
|
+
const fieldsToPropagate = [
|
|
112
|
+
"type",
|
|
113
|
+
"storageLimit",
|
|
114
|
+
"gasLimit",
|
|
115
|
+
"gasPrice",
|
|
116
|
+
"maxFeePerGas",
|
|
117
|
+
"maxPriorityFeePerGas",
|
|
118
|
+
"additionalFees",
|
|
119
|
+
];
|
|
82
120
|
|
|
83
121
|
for (const field of fieldsToPropagate) {
|
|
84
122
|
propagateField(estimation, field, next);
|
|
@@ -86,11 +124,14 @@ export function genericPrepareTransaction(
|
|
|
86
124
|
|
|
87
125
|
// align with stellar/xrp: when send max (or staking intents), reflect validated amount in UI
|
|
88
126
|
if (transaction.useAllAmount || ["stake", "unstake"].includes(transaction.mode ?? "")) {
|
|
127
|
+
// TODO Remove the call to `validateIntent` https://ledgerhq.atlassian.net/browse/LIVE-22228
|
|
89
128
|
const { amount } = await validateIntent(
|
|
90
129
|
transactionToIntent(
|
|
91
130
|
account,
|
|
92
131
|
{
|
|
93
132
|
...transaction,
|
|
133
|
+
assetOwner,
|
|
134
|
+
assetReference,
|
|
94
135
|
},
|
|
95
136
|
computeIntentType,
|
|
96
137
|
),
|