@ledgerhq/live-common 34.53.0-nightly.20251119110540 → 34.53.0
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.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +4 -0
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/__tests__/test-helpers/environment.js +0 -3
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +10 -12
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/currencies/helpers.d.ts +3 -1
- package/lib/currencies/helpers.d.ts.map +1 -1
- package/lib/currencies/helpers.js +27 -1
- package/lib/currencies/helpers.js.map +1 -1
- package/lib/dada-client/hooks/useAssetsData.d.ts +0 -1
- package/lib/dada-client/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/dada-client/hooks/useAssetsData.js +0 -1
- package/lib/dada-client/hooks/useAssetsData.js.map +1 -1
- package/lib/deposit/helper.d.ts +8 -0
- package/lib/deposit/helper.d.ts.map +1 -0
- package/lib/deposit/helper.js +125 -0
- package/lib/deposit/helper.js.map +1 -0
- package/lib/deposit/index.d.ts +3 -0
- package/lib/deposit/index.d.ts.map +1 -0
- package/lib/deposit/index.js +6 -0
- package/lib/deposit/index.js.map +1 -0
- package/lib/deposit/mock.d.ts +75 -0
- package/lib/deposit/mock.d.ts.map +1 -0
- package/lib/deposit/mock.js +15111 -0
- package/lib/deposit/mock.js.map +1 -0
- package/lib/deposit/type.d.ts +17 -0
- package/lib/deposit/type.d.ts.map +1 -1
- package/lib/deposit/type.js.map +1 -1
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts +3 -0
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +1 -0
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js +40 -0
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js.map +1 -0
- package/lib/deviceSDK/hooks/useBatteryStatuses.d.ts +1 -2
- package/lib/deviceSDK/hooks/useBatteryStatuses.d.ts.map +1 -1
- package/lib/deviceSDK/hooks/useBatteryStatuses.js +2 -4
- package/lib/deviceSDK/hooks/useBatteryStatuses.js.map +1 -1
- package/lib/deviceSDK/tasks/core.d.ts +1 -1
- package/lib/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/core.js +1 -1
- package/lib/deviceSDK/tasks/core.js.map +1 -1
- package/lib/deviceSDK/tasks/getDeviceInfo.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/getDeviceInfo.js +0 -2
- package/lib/deviceSDK/tasks/getDeviceInfo.js.map +1 -1
- package/lib/deviceSDK/tasks/getLatestFirmware.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/getLatestFirmware.js +2 -2
- package/lib/deviceSDK/tasks/getLatestFirmware.js.map +1 -1
- package/lib/deviceSDK/tasks/updateFirmware.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/updateFirmware.js +0 -1
- package/lib/deviceSDK/tasks/updateFirmware.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +1 -0
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +1 -0
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +1 -0
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +6 -2
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/index.d.ts +0 -9
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/exchange/providers/swap.d.ts +0 -1
- package/lib/exchange/providers/swap.d.ts.map +1 -1
- package/lib/exchange/providers/swap.js +1 -5
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js +3 -2
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js +10 -15
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib/families/evm/config.d.ts.map +1 -1
- package/lib/families/evm/config.js +0 -49
- package/lib/families/evm/config.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +0 -3
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +0 -4
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/market/hooks/useMarketDataProvider.js +0 -1
- package/lib/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib/market/utils/types.d.ts +0 -1
- package/lib/market/utils/types.d.ts.map +1 -1
- package/lib/market/utils/types.js.map +1 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +41 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -11
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib/modularDrawer/hooks/useNetworkAccountCounts.d.ts +5 -1
- package/lib/modularDrawer/hooks/useNetworkAccountCounts.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useNetworkAccountCounts.js +2 -2
- package/lib/modularDrawer/hooks/useNetworkAccountCounts.js.map +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.js +2 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
- package/lib/modularDrawer/utils/currencyUtils.d.ts +10 -0
- package/lib/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
- package/lib/modularDrawer/utils/currencyUtils.js +74 -0
- package/lib/modularDrawer/utils/currencyUtils.js.map +1 -0
- package/lib/modularDrawer/utils/{groupCurrenciesByAsset.d.ts → groupCurrenciesByProvider.d.ts} +2 -2
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +1 -0
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.js +21 -0
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.js.map +1 -0
- package/lib/modularDrawer/utils/index.d.ts +1 -1
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +3 -3
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/modularDrawer/utils/type.d.ts +5 -0
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/platform/filters.d.ts +2 -1
- package/lib/platform/filters.d.ts.map +1 -1
- package/lib/platform/filters.js +17 -1
- package/lib/platform/filters.js.map +1 -1
- package/lib/platform/helpers.d.ts +5 -1
- package/lib/platform/helpers.d.ts.map +1 -1
- package/lib/platform/helpers.js +33 -1
- package/lib/platform/helpers.js.map +1 -1
- package/lib/platform/react.d.ts +3 -2
- package/lib/platform/react.d.ts.map +1 -1
- package/lib/platform/react.js +16 -66
- package/lib/platform/react.js.map +1 -1
- package/lib/platform/types.d.ts +3 -3
- package/lib/platform/types.d.ts.map +1 -1
- package/lib/postOnboarding/reducer.d.ts +0 -2
- package/lib/postOnboarding/reducer.d.ts.map +1 -1
- package/lib/utils/getAccountTuplesForCurrency.d.ts +1 -1
- package/lib/utils/getAccountTuplesForCurrency.d.ts.map +1 -1
- package/lib/utils/getAccountTuplesForCurrency.js +3 -2
- package/lib/utils/getAccountTuplesForCurrency.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +4 -5
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/converters.d.ts +0 -1
- package/lib/wallet-api/converters.d.ts.map +1 -1
- package/lib/wallet-api/converters.js +2 -7
- package/lib/wallet-api/converters.js.map +1 -1
- package/lib/wallet-api/react.d.ts +11 -6
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +135 -291
- package/lib/wallet-api/react.js.map +1 -1
- package/lib/wallet-api/tracking.d.ts +0 -6
- package/lib/wallet-api/tracking.d.ts.map +1 -1
- package/lib/wallet-api/tracking.js +0 -20
- package/lib/wallet-api/tracking.js.map +1 -1
- package/lib/wallet-api/types.d.ts +0 -3
- package/lib/wallet-api/types.d.ts.map +1 -1
- package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib/wallet-api/useDappLogic.js +80 -65
- package/lib/wallet-api/useDappLogic.js.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts +0 -6
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js +3 -13
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +4 -0
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/__tests__/test-helpers/environment.js +0 -3
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +11 -13
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/currencies/helpers.d.ts +3 -1
- package/lib-es/currencies/helpers.d.ts.map +1 -1
- package/lib-es/currencies/helpers.js +24 -0
- package/lib-es/currencies/helpers.js.map +1 -1
- package/lib-es/dada-client/hooks/useAssetsData.d.ts +0 -1
- package/lib-es/dada-client/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/dada-client/hooks/useAssetsData.js +0 -1
- package/lib-es/dada-client/hooks/useAssetsData.js.map +1 -1
- package/lib-es/deposit/helper.d.ts +8 -0
- package/lib-es/deposit/helper.d.ts.map +1 -0
- package/lib-es/deposit/helper.js +117 -0
- package/lib-es/deposit/helper.js.map +1 -0
- package/lib-es/deposit/index.d.ts +3 -0
- package/lib-es/deposit/index.d.ts.map +1 -0
- package/lib-es/deposit/index.js +3 -0
- package/lib-es/deposit/index.js.map +1 -0
- package/lib-es/deposit/mock.d.ts +75 -0
- package/lib-es/deposit/mock.d.ts.map +1 -0
- package/lib-es/deposit/mock.js +15108 -0
- package/lib-es/deposit/mock.js.map +1 -0
- package/lib-es/deposit/type.d.ts +17 -0
- package/lib-es/deposit/type.d.ts.map +1 -1
- package/lib-es/deposit/type.js.map +1 -1
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts +3 -0
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +1 -0
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js +36 -0
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js.map +1 -0
- package/lib-es/deviceSDK/hooks/useBatteryStatuses.d.ts +1 -2
- package/lib-es/deviceSDK/hooks/useBatteryStatuses.d.ts.map +1 -1
- package/lib-es/deviceSDK/hooks/useBatteryStatuses.js +2 -4
- package/lib-es/deviceSDK/hooks/useBatteryStatuses.js.map +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/core.js +1 -1
- package/lib-es/deviceSDK/tasks/core.js.map +1 -1
- package/lib-es/deviceSDK/tasks/getDeviceInfo.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/getDeviceInfo.js +0 -2
- package/lib-es/deviceSDK/tasks/getDeviceInfo.js.map +1 -1
- package/lib-es/deviceSDK/tasks/getLatestFirmware.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/getLatestFirmware.js +2 -2
- package/lib-es/deviceSDK/tasks/getLatestFirmware.js.map +1 -1
- package/lib-es/deviceSDK/tasks/updateFirmware.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/updateFirmware.js +1 -2
- package/lib-es/deviceSDK/tasks/updateFirmware.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +1 -0
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +1 -0
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +1 -0
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +6 -2
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/index.d.ts +0 -9
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/exchange/providers/swap.d.ts +0 -1
- package/lib-es/exchange/providers/swap.d.ts.map +1 -1
- package/lib-es/exchange/providers/swap.js +0 -3
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js +3 -2
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js +12 -17
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib-es/families/evm/config.d.ts.map +1 -1
- package/lib-es/families/evm/config.js +0 -49
- package/lib-es/families/evm/config.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +0 -3
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +0 -4
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/market/hooks/useMarketDataProvider.js +0 -1
- package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib-es/market/utils/types.d.ts +0 -1
- package/lib-es/market/utils/types.d.ts.map +1 -1
- package/lib-es/market/utils/types.js.map +1 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +38 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -11
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.d.ts +5 -1
- package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.js +2 -2
- package/lib-es/modularDrawer/hooks/useNetworkAccountCounts.js.map +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +2 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts +10 -0
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/currencyUtils.js +65 -0
- package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -0
- package/lib-es/modularDrawer/utils/{groupCurrenciesByAsset.d.ts → groupCurrenciesByProvider.d.ts} +2 -2
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/{groupCurrenciesByAsset.js → groupCurrenciesByProvider.js} +6 -6
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.js.map +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts +1 -1
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +1 -1
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/utils/type.d.ts +5 -0
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/platform/filters.d.ts +2 -1
- package/lib-es/platform/filters.d.ts.map +1 -1
- package/lib-es/platform/filters.js +15 -0
- package/lib-es/platform/filters.js.map +1 -1
- package/lib-es/platform/helpers.d.ts +5 -1
- package/lib-es/platform/helpers.d.ts.map +1 -1
- package/lib-es/platform/helpers.js +30 -1
- package/lib-es/platform/helpers.js.map +1 -1
- package/lib-es/platform/react.d.ts +3 -2
- package/lib-es/platform/react.d.ts.map +1 -1
- package/lib-es/platform/react.js +16 -67
- package/lib-es/platform/react.js.map +1 -1
- package/lib-es/platform/types.d.ts +3 -3
- package/lib-es/platform/types.d.ts.map +1 -1
- package/lib-es/postOnboarding/reducer.d.ts +0 -2
- package/lib-es/postOnboarding/reducer.d.ts.map +1 -1
- package/lib-es/utils/getAccountTuplesForCurrency.d.ts +1 -1
- package/lib-es/utils/getAccountTuplesForCurrency.d.ts.map +1 -1
- package/lib-es/utils/getAccountTuplesForCurrency.js +3 -2
- package/lib-es/utils/getAccountTuplesForCurrency.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +4 -5
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/converters.d.ts +0 -1
- package/lib-es/wallet-api/converters.d.ts.map +1 -1
- package/lib-es/wallet-api/converters.js +1 -5
- package/lib-es/wallet-api/converters.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts +11 -6
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +131 -289
- package/lib-es/wallet-api/react.js.map +1 -1
- package/lib-es/wallet-api/tracking.d.ts +0 -6
- package/lib-es/wallet-api/tracking.d.ts.map +1 -1
- package/lib-es/wallet-api/tracking.js +0 -20
- package/lib-es/wallet-api/tracking.js.map +1 -1
- package/lib-es/wallet-api/types.d.ts +0 -3
- package/lib-es/wallet-api/types.d.ts.map +1 -1
- package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
- package/lib-es/wallet-api/useDappLogic.js +77 -62
- package/lib-es/wallet-api/useDappLogic.js.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts +0 -6
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js +2 -11
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/package.json +57 -57
- package/src/__tests__/migration/account-migration.ts +0 -3
- package/src/__tests__/test-helpers/bridge.ts +2 -0
- package/src/__tests__/test-helpers/environment.ts +0 -3
- package/src/bridge/generic-alpaca/getAccountShape.ts +12 -15
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +101 -142
- package/src/currencies/helpers.test.ts +20 -0
- package/src/currencies/helpers.ts +42 -1
- package/src/dada-client/hooks/useAssetsData.ts +0 -1
- package/src/deposit/deposit.integration.test.ts +88 -0
- package/src/deposit/deposit.test.ts +684 -0
- package/src/deposit/helper.ts +143 -0
- package/src/deposit/index.ts +3 -0
- package/src/deposit/mock.ts +15112 -0
- package/src/deposit/type.ts +21 -0
- package/src/deposit/useGroupedCurrenciesByProvider.hook.ts +46 -0
- package/src/deviceSDK/hooks/useBatteryStatuses.test.ts +1 -3
- package/src/deviceSDK/hooks/useBatteryStatuses.ts +1 -4
- package/src/deviceSDK/tasks/core.test.ts +0 -20
- package/src/deviceSDK/tasks/core.ts +1 -2
- package/src/deviceSDK/tasks/getDeviceInfo.ts +0 -2
- package/src/deviceSDK/tasks/getLatestFirmware.ts +4 -4
- package/src/deviceSDK/tasks/updateFirmware.ts +0 -2
- package/src/e2e/enum/Account.ts +6 -0
- package/src/e2e/enum/Currency.ts +6 -2
- package/src/exchange/providers/swap.ts +0 -4
- package/src/exchange/swap/hooks/v5/useFetchCurrencyAll.ts +3 -2
- package/src/exchange/swap/hooks/v5/useFilteredProviders.ts +12 -37
- package/src/families/evm/config.ts +0 -49
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +12 -84
- package/src/featureFlags/defaultFeatures.ts +0 -4
- package/src/market/hooks/useMarketDataProvider.ts +0 -1
- package/src/market/utils/types.ts +0 -1
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +49 -0
- package/src/modularDrawer/hooks/__test__/useAssetAccountCounts.test.ts +5 -0
- package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +0 -11
- package/src/modularDrawer/hooks/useNetworkAccountCounts.tsx +6 -1
- package/src/modularDrawer/modules/__test__/createAssetConfiguration.test.tsx +2 -2
- package/src/modularDrawer/modules/__test__/createNetworkConfiguration.test.ts +342 -0
- package/src/modularDrawer/modules/createNetworkConfiguration.ts +2 -1
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +126 -0
- package/src/modularDrawer/utils/currencyUtils.ts +95 -0
- package/src/modularDrawer/utils/{groupCurrenciesByAsset.ts → groupCurrenciesByProvider.ts} +5 -5
- package/src/modularDrawer/utils/index.ts +1 -1
- package/src/modularDrawer/utils/type.ts +5 -0
- package/src/platform/filters.ts +23 -1
- package/src/platform/helpers.ts +49 -2
- package/src/platform/react.ts +22 -86
- package/src/platform/types.ts +1 -1
- package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +30 -0
- package/src/utils/getAccountTuplesForCurrency.ts +6 -1
- package/src/wallet-api/Exchange/server.test.ts +5 -0
- package/src/wallet-api/Exchange/server.ts +6 -7
- package/src/wallet-api/converters.ts +1 -6
- package/src/wallet-api/react.ts +137 -310
- package/src/wallet-api/tracking.ts +0 -22
- package/src/wallet-api/types.ts +0 -5
- package/src/wallet-api/useDappLogic.ts +106 -91
- package/src/wallet-api/utils/deriveAccountIdForManifest.ts +2 -14
- package/lib/device/use-cases/getDeviceHasBattery.d.ts +0 -2
- package/lib/device/use-cases/getDeviceHasBattery.d.ts.map +0 -1
- package/lib/device/use-cases/getDeviceHasBattery.js +0 -6
- package/lib/device/use-cases/getDeviceHasBattery.js.map +0 -1
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts +0 -6
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts.map +0 -1
- package/lib/e2e/enum/ReceiveFundsOptions.js +0 -8
- package/lib/e2e/enum/ReceiveFundsOptions.js.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.js +0 -21
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.js.map +0 -1
- package/lib-es/device/use-cases/getDeviceHasBattery.d.ts +0 -2
- package/lib-es/device/use-cases/getDeviceHasBattery.d.ts.map +0 -1
- package/lib-es/device/use-cases/getDeviceHasBattery.js +0 -2
- package/lib-es/device/use-cases/getDeviceHasBattery.js.map +0 -1
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts +0 -6
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts.map +0 -1
- package/lib-es/e2e/enum/ReceiveFundsOptions.js +0 -5
- package/lib-es/e2e/enum/ReceiveFundsOptions.js.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.js.map +0 -1
- package/src/device/use-cases/getDeviceHasBattery.ts +0 -1
- package/src/e2e/enum/ReceiveFundsOptions.ts +0 -7
- package/src/modularDrawer/utils/__tests__/groupCurrenciesByAsset.test.ts +0 -88
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LoadingStatus } from "../../deposit/type";
|
|
2
|
+
import {
|
|
3
|
+
arbitrumToken,
|
|
4
|
+
mockArbitrumCryptoCurrency,
|
|
5
|
+
mockBaseCryptoCurrency,
|
|
6
|
+
mockBtcCryptoCurrency,
|
|
7
|
+
mockEthCryptoCurrency,
|
|
8
|
+
mockInjectiveCryptoCurrency,
|
|
9
|
+
mockScrollCryptoCurrency,
|
|
10
|
+
usdcToken,
|
|
11
|
+
} from "./currencies.mock";
|
|
12
|
+
|
|
13
|
+
export const providers = [
|
|
14
|
+
{
|
|
15
|
+
providerId: "bitcoin",
|
|
16
|
+
currenciesByNetwork: [mockBtcCryptoCurrency],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
providerId: "ethereum",
|
|
20
|
+
currenciesByNetwork: [
|
|
21
|
+
mockEthCryptoCurrency,
|
|
22
|
+
mockArbitrumCryptoCurrency,
|
|
23
|
+
mockBaseCryptoCurrency,
|
|
24
|
+
mockScrollCryptoCurrency,
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{ providerId: "arbitrum", currenciesByNetwork: [arbitrumToken] },
|
|
28
|
+
{ providerId: "usd-coin", currenciesByNetwork: [usdcToken] },
|
|
29
|
+
{ providerId: "injective-protocol", currenciesByNetwork: [mockInjectiveCryptoCurrency] },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const res = {
|
|
33
|
+
result: {
|
|
34
|
+
currenciesByProvider: providers,
|
|
35
|
+
sortedCryptoCurrencies: [
|
|
36
|
+
mockBtcCryptoCurrency,
|
|
37
|
+
mockEthCryptoCurrency,
|
|
38
|
+
mockArbitrumCryptoCurrency,
|
|
39
|
+
mockBaseCryptoCurrency,
|
|
40
|
+
mockScrollCryptoCurrency,
|
|
41
|
+
mockInjectiveCryptoCurrency,
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const useGroupedCurrenciesByProvider: jest.Mock = jest.fn(() => ({
|
|
47
|
+
...res,
|
|
48
|
+
loadingStatus: LoadingStatus.Success,
|
|
49
|
+
}));
|
|
@@ -12,6 +12,7 @@ describe("useNetworkAccountCounts", () => {
|
|
|
12
12
|
const assetAccountCounts = useNetworkAccountCounts({
|
|
13
13
|
networks: [ethereumCurrency],
|
|
14
14
|
nestedAccounts: [ethereumAccountHigh],
|
|
15
|
+
accountIds: new Map([[ethereumAccountHigh.id, true]]),
|
|
15
16
|
formatLabel: (count: number) => `${count}`,
|
|
16
17
|
});
|
|
17
18
|
|
|
@@ -26,6 +27,10 @@ describe("useNetworkAccountCounts", () => {
|
|
|
26
27
|
const assetAccountCounts = useNetworkAccountCounts({
|
|
27
28
|
networks: [ethereumCurrency],
|
|
28
29
|
nestedAccounts: [ethereumAccountHigh, ethereumAccountLow],
|
|
30
|
+
accountIds: new Map([
|
|
31
|
+
[ethereumAccountHigh.id, true],
|
|
32
|
+
[ethereumAccountLow.id, true],
|
|
33
|
+
]),
|
|
29
34
|
formatLabel: (count: number) => `${count}`,
|
|
30
35
|
});
|
|
31
36
|
|
|
@@ -80,9 +80,6 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
80
80
|
const assetHubPolkadot = useFeature("currencyAssetHubPolkadot");
|
|
81
81
|
const polkadot = useFeature("currencyPolkadot");
|
|
82
82
|
const monad = useFeature("currencyMonad");
|
|
83
|
-
const monadTestnet = useFeature("currencyMonadTestnet");
|
|
84
|
-
const somnia = useFeature("currencySomnia");
|
|
85
|
-
const zeroGravity = useFeature("currencyZeroGravity");
|
|
86
83
|
|
|
87
84
|
const featureFlaggedCurrencies = useMemo(
|
|
88
85
|
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
|
|
@@ -159,9 +156,6 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
159
156
|
assethub_polkadot: assetHubPolkadot,
|
|
160
157
|
polkadot,
|
|
161
158
|
monad,
|
|
162
|
-
monad_testnet: monadTestnet,
|
|
163
|
-
somnia,
|
|
164
|
-
zero_gravity: zeroGravity,
|
|
165
159
|
}),
|
|
166
160
|
[
|
|
167
161
|
aptos,
|
|
@@ -227,8 +221,6 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
227
221
|
mina,
|
|
228
222
|
babylon,
|
|
229
223
|
canton,
|
|
230
|
-
cantonDevnet,
|
|
231
|
-
cantonTestnet,
|
|
232
224
|
kaspa,
|
|
233
225
|
core,
|
|
234
226
|
ethereumHoodi,
|
|
@@ -237,9 +229,6 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
237
229
|
assetHubPolkadot,
|
|
238
230
|
polkadot,
|
|
239
231
|
monad,
|
|
240
|
-
monadTestnet,
|
|
241
|
-
somnia,
|
|
242
|
-
zeroGravity,
|
|
243
232
|
],
|
|
244
233
|
);
|
|
245
234
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
1
2
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
3
|
import { getAccountTuplesForCurrency } from "../../utils/getAccountTuplesForCurrency";
|
|
3
4
|
import type { Account } from "@ledgerhq/types-live";
|
|
5
|
+
import { WalletAPIAccount } from "../../wallet-api/types";
|
|
4
6
|
|
|
5
7
|
type AccountModuleParams = {
|
|
6
8
|
networks: CryptoOrTokenCurrency[];
|
|
7
9
|
nestedAccounts: Account[];
|
|
10
|
+
accountIds: Map<string, boolean> | undefined;
|
|
8
11
|
formatLabel: (count: number) => string;
|
|
12
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export type NetworkCountItem = {
|
|
@@ -17,11 +21,12 @@ export type NetworkCountItem = {
|
|
|
17
21
|
export const useNetworkAccountCounts = ({
|
|
18
22
|
networks,
|
|
19
23
|
nestedAccounts,
|
|
24
|
+
accountIds,
|
|
20
25
|
formatLabel,
|
|
21
26
|
}: AccountModuleParams): NetworkCountItem[] =>
|
|
22
27
|
networks.map(network => {
|
|
23
28
|
const asset = network.type === "TokenCurrency" ? network.parentCurrency : network;
|
|
24
|
-
const { length } = getAccountTuplesForCurrency(asset, nestedAccounts);
|
|
29
|
+
const { length } = getAccountTuplesForCurrency(asset, nestedAccounts, accountIds);
|
|
25
30
|
return {
|
|
26
31
|
asset,
|
|
27
32
|
label: formatLabel(length),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { renderHook } from "@testing-library/react";
|
|
7
7
|
import { mockEthCryptoCurrency } from "../../__mocks__/currencies.mock";
|
|
8
|
-
import {
|
|
8
|
+
import { groupCurrenciesByProvider } from "../../utils";
|
|
9
9
|
import createAssetConfigurationHook from "../createAssetConfiguration";
|
|
10
10
|
import { BigNumber } from "bignumber.js";
|
|
11
11
|
import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
|
|
@@ -114,7 +114,7 @@ const assetConfigurationDeps = {
|
|
|
114
114
|
ApyIndicator,
|
|
115
115
|
MarketPercentIndicator,
|
|
116
116
|
MarketPriceIndicator,
|
|
117
|
-
assetsMap:
|
|
117
|
+
assetsMap: groupCurrenciesByProvider([
|
|
118
118
|
{
|
|
119
119
|
asset: {
|
|
120
120
|
id: "ethereum",
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { BigNumber } from "bignumber.js";
|
|
6
|
+
import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
|
|
7
|
+
import { createFixtureCryptoCurrency } from "../../../mock/fixtures/cryptoCurrencies";
|
|
8
|
+
import { createNetworkConfigurationHook } from "../createNetworkConfiguration";
|
|
9
|
+
import { renderHook } from "@testing-library/react";
|
|
10
|
+
import { CounterValuesState } from "@ledgerhq/live-countervalues/lib/types";
|
|
11
|
+
import { FiatCurrency, TokenCurrency, CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
12
|
+
import { makeUsdcToken } from "./createAssetConfiguration.test";
|
|
13
|
+
|
|
14
|
+
const bscCurrency = createFixtureCryptoCurrency("bsc");
|
|
15
|
+
const bscAccount = genAccount("bsc-account", { currency: bscCurrency });
|
|
16
|
+
const bscUsdcToken: TokenCurrency = makeUsdcToken(
|
|
17
|
+
bscCurrency,
|
|
18
|
+
"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
|
19
|
+
"bep20",
|
|
20
|
+
"USD Coin",
|
|
21
|
+
"bsc/erc20/usdc",
|
|
22
|
+
);
|
|
23
|
+
const bscUsdcTokenAccount = genTokenAccount(0, bscAccount, bscUsdcToken);
|
|
24
|
+
bscAccount.subAccounts = [bscUsdcTokenAccount];
|
|
25
|
+
|
|
26
|
+
const baseCurrency = createFixtureCryptoCurrency("base");
|
|
27
|
+
const baseAccount = genAccount("base-account", { currency: baseCurrency });
|
|
28
|
+
const baseUsdcToken: TokenCurrency = makeUsdcToken(
|
|
29
|
+
baseCurrency,
|
|
30
|
+
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
31
|
+
"erc20",
|
|
32
|
+
"USD Coin",
|
|
33
|
+
"base/erc20/usd_coin",
|
|
34
|
+
);
|
|
35
|
+
const baseUsdcTokenAccount = genTokenAccount(0, baseAccount, baseUsdcToken);
|
|
36
|
+
baseAccount.subAccounts = [baseUsdcTokenAccount];
|
|
37
|
+
|
|
38
|
+
const ethereumCurrency = createFixtureCryptoCurrency("ethereum");
|
|
39
|
+
const ethereumAccountHigh = genAccount("ethereum-account-high", {
|
|
40
|
+
currency: ethereumCurrency,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
ethereumAccountHigh.balance = new BigNumber("1000000000000000000000");
|
|
44
|
+
ethereumAccountHigh.spendableBalance = ethereumAccountHigh.balance;
|
|
45
|
+
|
|
46
|
+
const ethereumUsdcToken: TokenCurrency = makeUsdcToken(
|
|
47
|
+
ethereumCurrency,
|
|
48
|
+
"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
49
|
+
"erc20",
|
|
50
|
+
|
|
51
|
+
"USD Coin",
|
|
52
|
+
);
|
|
53
|
+
const ethereumUsdcTokenAccount = genTokenAccount(0, ethereumAccountHigh, ethereumUsdcToken);
|
|
54
|
+
ethereumAccountHigh.subAccounts = [ethereumUsdcTokenAccount];
|
|
55
|
+
|
|
56
|
+
const ethereumAccountLow = genAccount("ethereum-account-low", {
|
|
57
|
+
currency: ethereumCurrency,
|
|
58
|
+
});
|
|
59
|
+
ethereumAccountLow.balance = new BigNumber("100000000000000000");
|
|
60
|
+
ethereumAccountLow.spendableBalance = ethereumAccountLow.balance;
|
|
61
|
+
|
|
62
|
+
const ethereumAccountZero = genAccount("ethereum-account-zero", {
|
|
63
|
+
currency: ethereumCurrency,
|
|
64
|
+
});
|
|
65
|
+
ethereumAccountZero.balance = new BigNumber("0");
|
|
66
|
+
ethereumAccountZero.spendableBalance = ethereumAccountZero.balance;
|
|
67
|
+
|
|
68
|
+
const polygonCurrency = createFixtureCryptoCurrency("polygon");
|
|
69
|
+
const polygonAccountMedium = genAccount("polygon-account-medium", {
|
|
70
|
+
currency: polygonCurrency,
|
|
71
|
+
});
|
|
72
|
+
polygonAccountMedium.balance = new BigNumber("500000000000000000000");
|
|
73
|
+
polygonAccountMedium.spendableBalance = polygonAccountMedium.balance;
|
|
74
|
+
|
|
75
|
+
const polygonUsdcToken: TokenCurrency = makeUsdcToken(
|
|
76
|
+
polygonCurrency,
|
|
77
|
+
"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
78
|
+
"erc20",
|
|
79
|
+
"USD Coin",
|
|
80
|
+
);
|
|
81
|
+
const polygonUsdcTokenAccount = genTokenAccount(0, polygonAccountMedium, polygonUsdcToken);
|
|
82
|
+
polygonAccountMedium.subAccounts = [polygonUsdcTokenAccount];
|
|
83
|
+
|
|
84
|
+
const makeAccountData = (asset, count) => ({
|
|
85
|
+
asset,
|
|
86
|
+
label: `${count} account`,
|
|
87
|
+
count,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const useAccountData = () => {
|
|
91
|
+
return [
|
|
92
|
+
makeAccountData(createFixtureCryptoCurrency("ethereum"), 3),
|
|
93
|
+
makeAccountData(createFixtureCryptoCurrency("polygon"), 1),
|
|
94
|
+
makeAccountData(createFixtureCryptoCurrency("bsc"), 2),
|
|
95
|
+
makeAccountData(createFixtureCryptoCurrency("base"), 1),
|
|
96
|
+
makeAccountData(createFixtureCryptoCurrency("avalanche_c_chain"), 0),
|
|
97
|
+
];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const mockFiatCurrency: FiatCurrency = {
|
|
101
|
+
type: "FiatCurrency",
|
|
102
|
+
ticker: "USD",
|
|
103
|
+
name: "US Dollar",
|
|
104
|
+
symbol: "$",
|
|
105
|
+
units: [
|
|
106
|
+
{
|
|
107
|
+
code: "$",
|
|
108
|
+
name: "US Dollar",
|
|
109
|
+
magnitude: 2,
|
|
110
|
+
showAllDigits: true,
|
|
111
|
+
prefixCode: true,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const accountsCount = jest.fn(() => null);
|
|
117
|
+
const accountsCountAndApy = () => null;
|
|
118
|
+
const useBalanceDeps = () => {
|
|
119
|
+
const mockCounterValuesState: CounterValuesState = {
|
|
120
|
+
cache: {
|
|
121
|
+
"USD testCoinId": {
|
|
122
|
+
fallback: 2354.213,
|
|
123
|
+
map: new Map(),
|
|
124
|
+
stats: {
|
|
125
|
+
oldest: "2024-09-12",
|
|
126
|
+
earliest: "2025-10-02T13",
|
|
127
|
+
oldestDate: new Date(),
|
|
128
|
+
earliestDate: new Date(),
|
|
129
|
+
earliestStableDate: new Date(),
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
data: {},
|
|
134
|
+
status: {},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
counterValueCurrency: mockFiatCurrency,
|
|
139
|
+
flattenedAccounts: [
|
|
140
|
+
bscAccount,
|
|
141
|
+
bscUsdcTokenAccount,
|
|
142
|
+
baseAccount,
|
|
143
|
+
baseUsdcTokenAccount,
|
|
144
|
+
ethereumAccountHigh,
|
|
145
|
+
ethereumUsdcTokenAccount,
|
|
146
|
+
ethereumAccountLow,
|
|
147
|
+
ethereumAccountZero,
|
|
148
|
+
polygonAccountMedium,
|
|
149
|
+
polygonUsdcTokenAccount,
|
|
150
|
+
],
|
|
151
|
+
state: mockCounterValuesState,
|
|
152
|
+
locale: "en-US",
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const balanceItem = jest.fn(() => null);
|
|
156
|
+
|
|
157
|
+
const networkConfigurationDeps = {
|
|
158
|
+
useAccountData,
|
|
159
|
+
accountsCount,
|
|
160
|
+
accountsCountAndApy,
|
|
161
|
+
useBalanceDeps,
|
|
162
|
+
balanceItem,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
describe("createNetworkConfiguration", () => {
|
|
166
|
+
beforeEach(() => {
|
|
167
|
+
jest.clearAllMocks();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("should call balanceItem with correct BalanceUI objects for each network", () => {
|
|
171
|
+
const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
|
|
172
|
+
const res = result.current({ networksConfig: { rightElement: "balance" } });
|
|
173
|
+
res([baseUsdcToken, bscUsdcToken]);
|
|
174
|
+
|
|
175
|
+
expect(balanceItem).toHaveBeenCalledTimes(2);
|
|
176
|
+
expect(balanceItem).toHaveBeenNthCalledWith(
|
|
177
|
+
1,
|
|
178
|
+
expect.objectContaining({ balance: baseUsdcTokenAccount.balance }),
|
|
179
|
+
);
|
|
180
|
+
expect(balanceItem).toHaveBeenNthCalledWith(
|
|
181
|
+
2,
|
|
182
|
+
expect.objectContaining({ balance: bscUsdcTokenAccount.balance }),
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("account count", () => {
|
|
187
|
+
const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
|
|
188
|
+
const res = result.current({ networksConfig: { leftElement: "numberOfAccounts" } });
|
|
189
|
+
res([baseUsdcToken, bscUsdcToken]);
|
|
190
|
+
|
|
191
|
+
expect(accountsCount).toHaveBeenCalledTimes(4);
|
|
192
|
+
expect(accountsCount).toHaveBeenNthCalledWith(1, { label: "3 account" });
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("should order by balance (highest first) when only balance element is present", () => {
|
|
196
|
+
const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
|
|
197
|
+
const res = result.current({
|
|
198
|
+
networksConfig: { rightElement: "balance" },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const orderedResult = res([ethereumUsdcToken, polygonUsdcToken, bscUsdcToken]);
|
|
202
|
+
|
|
203
|
+
expect(orderedResult).toHaveLength(3);
|
|
204
|
+
|
|
205
|
+
// Should be ordered by balance amount (highest first)
|
|
206
|
+
expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 1000 ETH
|
|
207
|
+
expect(orderedResult[1].id).toBe(polygonCurrency.id); // 500 MATIC
|
|
208
|
+
expect(orderedResult[2].id).toBe(bscCurrency.id); // Lower balance
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("should order by account count (highest first) when only account count element is present", () => {
|
|
212
|
+
const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
|
|
213
|
+
const res = result.current({
|
|
214
|
+
networksConfig: { leftElement: "numberOfAccounts" },
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const orderedResult = res([ethereumUsdcToken, polygonUsdcToken, bscUsdcToken]);
|
|
218
|
+
|
|
219
|
+
expect(orderedResult).toHaveLength(3);
|
|
220
|
+
|
|
221
|
+
// Should be ordered by account count (highest first)
|
|
222
|
+
expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 3 accounts
|
|
223
|
+
expect(orderedResult[1].id).toBe(bscCurrency.id); // 2 accounts
|
|
224
|
+
expect(orderedResult[2].id).toBe(polygonCurrency.id); // 1 account
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("should handle networks with zero balances by ordering them by account count", () => {
|
|
228
|
+
const zeroBalanceEth = { ...ethereumAccountZero };
|
|
229
|
+
const zeroBalancePoly = {
|
|
230
|
+
...polygonAccountMedium,
|
|
231
|
+
balance: new BigNumber("0"),
|
|
232
|
+
spendableBalance: new BigNumber("0"),
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const mockUseBalanceDepsZero = () => ({
|
|
236
|
+
counterValueCurrency: {
|
|
237
|
+
type: "FiatCurrency" as const,
|
|
238
|
+
ticker: "USD",
|
|
239
|
+
name: "US Dollar",
|
|
240
|
+
symbol: "$",
|
|
241
|
+
units: [
|
|
242
|
+
{ code: "$", name: "US Dollar", magnitude: 2, showAllDigits: true, prefixCode: true },
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
flattenedAccounts: [zeroBalanceEth, zeroBalancePoly],
|
|
246
|
+
state: { cache: {}, data: {}, status: {} },
|
|
247
|
+
locale: "en-US",
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const { result } = renderHook(() =>
|
|
251
|
+
createNetworkConfigurationHook({
|
|
252
|
+
...networkConfigurationDeps,
|
|
253
|
+
useBalanceDeps: mockUseBalanceDepsZero,
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
const res = result.current({
|
|
257
|
+
networksConfig: { leftElement: "numberOfAccounts", rightElement: "balance" },
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const orderedResult = res([ethereumUsdcToken, polygonUsdcToken]);
|
|
261
|
+
|
|
262
|
+
expect(orderedResult).toHaveLength(2);
|
|
263
|
+
|
|
264
|
+
// When both have zero balance, should order by account count
|
|
265
|
+
expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 3 accounts
|
|
266
|
+
expect(orderedResult[1].id).toBe(polygonCurrency.id); // 1 account
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("should prioritise non-zero balances over account count", () => {
|
|
270
|
+
const testEthereumCurrency: CryptoCurrency = createFixtureCryptoCurrency("ethereum");
|
|
271
|
+
const testPolygonCurrency: CryptoCurrency = createFixtureCryptoCurrency("polygon");
|
|
272
|
+
const testAvalancheCurrency: CryptoCurrency = createFixtureCryptoCurrency("avalanche_c_chain");
|
|
273
|
+
const testArbitrumCurrency: CryptoCurrency = createFixtureCryptoCurrency("arbitrum");
|
|
274
|
+
|
|
275
|
+
const testEthereumAccount = genAccount("test-ethereum-account", {
|
|
276
|
+
currency: testEthereumCurrency,
|
|
277
|
+
});
|
|
278
|
+
testEthereumAccount.balance = new BigNumber("1000000000000000000000");
|
|
279
|
+
testEthereumAccount.spendableBalance = testEthereumAccount.balance;
|
|
280
|
+
|
|
281
|
+
const testPolygonAccount = genAccount("test-polygon-account", {
|
|
282
|
+
currency: testPolygonCurrency,
|
|
283
|
+
});
|
|
284
|
+
testPolygonAccount.balance = new BigNumber("500000000000000000000");
|
|
285
|
+
testPolygonAccount.spendableBalance = testPolygonAccount.balance;
|
|
286
|
+
|
|
287
|
+
const testEthereumUsdcToken = makeUsdcToken(
|
|
288
|
+
testEthereumCurrency,
|
|
289
|
+
"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
290
|
+
);
|
|
291
|
+
const testPolygonUsdcToken = makeUsdcToken(
|
|
292
|
+
testPolygonCurrency,
|
|
293
|
+
"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
294
|
+
);
|
|
295
|
+
const testAvalancheUsdcToken = makeUsdcToken(
|
|
296
|
+
testAvalancheCurrency,
|
|
297
|
+
"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
298
|
+
);
|
|
299
|
+
const testArbitrumUsdcToken = makeUsdcToken(
|
|
300
|
+
testArbitrumCurrency,
|
|
301
|
+
"0xFF970A61A04b1cA14834A43f5de4533eBDDB5CC8",
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const testUseBalanceDeps = () => ({
|
|
305
|
+
counterValueCurrency: mockFiatCurrency,
|
|
306
|
+
flattenedAccounts: [testEthereumAccount, testPolygonAccount],
|
|
307
|
+
state: { cache: {}, data: {}, status: {} },
|
|
308
|
+
locale: "en-US",
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const testUseAccountData = () => [
|
|
312
|
+
makeAccountData(testEthereumCurrency, 3),
|
|
313
|
+
makeAccountData(testPolygonCurrency, 1),
|
|
314
|
+
makeAccountData(testAvalancheCurrency, 1),
|
|
315
|
+
makeAccountData(testArbitrumCurrency, 2),
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
const { result } = renderHook(() =>
|
|
319
|
+
createNetworkConfigurationHook({
|
|
320
|
+
...networkConfigurationDeps,
|
|
321
|
+
useAccountData: testUseAccountData,
|
|
322
|
+
useBalanceDeps: testUseBalanceDeps,
|
|
323
|
+
}),
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
const res = result.current({
|
|
327
|
+
networksConfig: { leftElement: "numberOfAccounts", rightElement: "balance" },
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const orderedResult = res([
|
|
331
|
+
testEthereumUsdcToken,
|
|
332
|
+
testPolygonUsdcToken,
|
|
333
|
+
testAvalancheUsdcToken,
|
|
334
|
+
testArbitrumUsdcToken,
|
|
335
|
+
]);
|
|
336
|
+
|
|
337
|
+
expect(orderedResult[0].id).toBe(testEthereumCurrency.id); // 1000 ETH balance, 3 accounts
|
|
338
|
+
expect(orderedResult[1].id).toBe(testPolygonCurrency.id); // 500 MATIC balance, 1 account
|
|
339
|
+
expect(orderedResult[2].id).toBe(testArbitrumCurrency.id); // (0 balance, 2 accounts)
|
|
340
|
+
expect(orderedResult[3].id).toBe(testAvalancheCurrency.id); // (0 balance, 1 account)
|
|
341
|
+
});
|
|
342
|
+
});
|
|
@@ -78,7 +78,7 @@ const sortNetworks = (
|
|
|
78
78
|
|
|
79
79
|
export const createNetworkConfigurationHook =
|
|
80
80
|
(NetworkConfigurationDeps: NetworkConfigurationDeps) =>
|
|
81
|
-
({ networksConfig }: CreateNetworkConfigurationHookProps) => {
|
|
81
|
+
({ networksConfig, accounts$ }: CreateNetworkConfigurationHookProps) => {
|
|
82
82
|
const { leftElement, rightElement } = networksConfig ?? {};
|
|
83
83
|
const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
|
|
84
84
|
const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
|
|
@@ -90,6 +90,7 @@ export const createNetworkConfigurationHook =
|
|
|
90
90
|
): Array<CryptoOrTokenCurrency & Network & { balanceData?: BalanceUI; count?: number }> => {
|
|
91
91
|
const hookResults = hooks.map(hook =>
|
|
92
92
|
hook({
|
|
93
|
+
accounts$,
|
|
93
94
|
networks,
|
|
94
95
|
}),
|
|
95
96
|
);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useGroupedCurrenciesByProvider } from "../../__mocks__/useGroupedCurrenciesByProvider.mock";
|
|
2
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
buildProviderCoverageMap,
|
|
6
|
+
extractProviderCurrencies,
|
|
7
|
+
filterProvidersByIds,
|
|
8
|
+
getProviderCurrency,
|
|
9
|
+
isProviderToken,
|
|
10
|
+
safeCurrencyLookup,
|
|
11
|
+
} from "../currencyUtils";
|
|
12
|
+
import {
|
|
13
|
+
mockBaseCryptoCurrency,
|
|
14
|
+
mockBtcCryptoCurrency,
|
|
15
|
+
mockEthCryptoCurrency,
|
|
16
|
+
usdcToken,
|
|
17
|
+
} from "../../__mocks__/currencies.mock";
|
|
18
|
+
|
|
19
|
+
describe("safeCurrencyLookup", () => {
|
|
20
|
+
it("should return the currency if it is found", async () => {
|
|
21
|
+
const currency = await safeCurrencyLookup("ethereum");
|
|
22
|
+
expect(currency).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
it("should return null if the currency is not found", async () => {
|
|
25
|
+
const currency = await safeCurrencyLookup("not-a-currency");
|
|
26
|
+
expect(currency).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("isProviderToken", () => {
|
|
31
|
+
it("should return true if the currency is a provider token", () => {
|
|
32
|
+
const baseToken: TokenCurrency = {
|
|
33
|
+
type: "TokenCurrency",
|
|
34
|
+
id: "base/erc20/base",
|
|
35
|
+
contractAddress: "0x0000000000000000000000000000000000000000",
|
|
36
|
+
parentCurrency: mockBaseCryptoCurrency,
|
|
37
|
+
tokenType: "erc20",
|
|
38
|
+
name: "Base",
|
|
39
|
+
ticker: "BASE",
|
|
40
|
+
units: [
|
|
41
|
+
{
|
|
42
|
+
name: "Base",
|
|
43
|
+
code: "BASE",
|
|
44
|
+
magnitude: 18,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
const currency = isProviderToken(baseToken, "base");
|
|
49
|
+
expect(currency).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it("should return false if the currency is not a provider token", () => {
|
|
52
|
+
const currency = isProviderToken(mockEthCryptoCurrency, "ethereum");
|
|
53
|
+
expect(currency).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("getProviderCurrency", () => {
|
|
58
|
+
it("should return the currency if it is a provider currency", async () => {
|
|
59
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
60
|
+
const currency = await getProviderCurrency(result.currenciesByProvider[0]);
|
|
61
|
+
expect(currency).toEqual(mockBtcCryptoCurrency);
|
|
62
|
+
});
|
|
63
|
+
it("should return the currency if it is a provider token", async () => {
|
|
64
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
65
|
+
const currency = await getProviderCurrency(result.currenciesByProvider[3]);
|
|
66
|
+
expect(currency).toEqual(usdcToken);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("buildProviderCoverageMap", () => {
|
|
71
|
+
it("should build a map of provider coverage correctly", () => {
|
|
72
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
73
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
|
74
|
+
|
|
75
|
+
expect(coverageMap).toBeInstanceOf(Map);
|
|
76
|
+
expect(coverageMap.get("bitcoin")).toEqual(new Set(["bitcoin"]));
|
|
77
|
+
expect(coverageMap.get("ethereum")).toEqual(new Set(["ethereum"]));
|
|
78
|
+
expect(coverageMap.get("arbitrum")).toEqual(new Set(["ethereum"]));
|
|
79
|
+
expect(coverageMap.get("base")).toEqual(new Set(["ethereum"]));
|
|
80
|
+
expect(coverageMap.get("scroll")).toEqual(new Set(["ethereum"]));
|
|
81
|
+
expect(coverageMap.get("arbitrum/erc20/arbitrum")).toEqual(new Set(["arbitrum"]));
|
|
82
|
+
expect(coverageMap.get("ethereum/erc20/usd__coin")).toEqual(new Set(["usd-coin"]));
|
|
83
|
+
expect(coverageMap.get("injective")).toEqual(new Set(["injective-protocol"]));
|
|
84
|
+
});
|
|
85
|
+
it("should handle empty input", () => {
|
|
86
|
+
const coverageMap = buildProviderCoverageMap([]);
|
|
87
|
+
expect(coverageMap).toBeInstanceOf(Map);
|
|
88
|
+
expect(coverageMap.size).toBe(0);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("filterProvidersByIds", () => {
|
|
93
|
+
it("should filter providers by ids correctly #evm", () => {
|
|
94
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
95
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
|
96
|
+
const filteredProviders = filterProvidersByIds(
|
|
97
|
+
result.currenciesByProvider,
|
|
98
|
+
new Set(["base"]),
|
|
99
|
+
coverageMap,
|
|
100
|
+
);
|
|
101
|
+
expect(filteredProviders).toHaveLength(1);
|
|
102
|
+
expect(filteredProviders[0].providerId).toBe("ethereum");
|
|
103
|
+
});
|
|
104
|
+
it("should filter providers by ids correctly #bitcoin", () => {
|
|
105
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
106
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
|
107
|
+
const filteredProviders = filterProvidersByIds(
|
|
108
|
+
result.currenciesByProvider,
|
|
109
|
+
new Set(["bitcoin"]),
|
|
110
|
+
coverageMap,
|
|
111
|
+
);
|
|
112
|
+
expect(filteredProviders).toHaveLength(1);
|
|
113
|
+
expect(filteredProviders[0].providerId).toBe("bitcoin");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("extractProviderCurrencies", () => {
|
|
118
|
+
it("should extract provider currencies correctly", async () => {
|
|
119
|
+
const { result } = useGroupedCurrenciesByProvider();
|
|
120
|
+
const providerCurrencies = await extractProviderCurrencies(result.currenciesByProvider);
|
|
121
|
+
expect(providerCurrencies).toHaveLength(5);
|
|
122
|
+
expect(providerCurrencies[0]).toEqual(mockBtcCryptoCurrency);
|
|
123
|
+
expect(providerCurrencies[1].id).toBe("ethereum");
|
|
124
|
+
expect(providerCurrencies[2].id).toBe("arbitrum/erc20/arbitrum");
|
|
125
|
+
});
|
|
126
|
+
});
|