@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,95 @@
|
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { getTokenOrCryptoCurrencyById } from "../../deposit/helper";
|
|
3
|
+
import { isTokenCurrency } from "../../currencies";
|
|
4
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
|
5
|
+
|
|
6
|
+
export type ProviderCoverageMap = Map<string, Set<string>>;
|
|
7
|
+
|
|
8
|
+
export const safeCurrencyLookup = async (id: string): Promise<CryptoOrTokenCurrency | null> => {
|
|
9
|
+
try {
|
|
10
|
+
return await getTokenOrCryptoCurrencyById(id);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const isProviderToken = (currency: CryptoOrTokenCurrency, providerId: string): boolean => {
|
|
17
|
+
return isTokenCurrency(currency) && currency.id.toLowerCase().includes(providerId.toLowerCase());
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getProviderCurrency = async (
|
|
21
|
+
provider: CurrenciesByProviderId,
|
|
22
|
+
): Promise<CryptoOrTokenCurrency | null> => {
|
|
23
|
+
const providerToken = provider.currenciesByNetwork.find(currency => {
|
|
24
|
+
return isProviderToken(currency, provider.providerId);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (providerToken) {
|
|
28
|
+
return providerToken;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lookupResult = await safeCurrencyLookup(provider.providerId);
|
|
32
|
+
return lookupResult ?? provider.currenciesByNetwork[0];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const buildProviderCoverageMap = (
|
|
36
|
+
providers: CurrenciesByProviderId[],
|
|
37
|
+
): ProviderCoverageMap => {
|
|
38
|
+
const providerIdToCoveringProviders = new Map<string, Set<string>>();
|
|
39
|
+
|
|
40
|
+
for (const { providerId, currenciesByNetwork } of providers) {
|
|
41
|
+
for (const { id } of currenciesByNetwork) {
|
|
42
|
+
if (!providerIdToCoveringProviders.has(id)) {
|
|
43
|
+
providerIdToCoveringProviders.set(id, new Set());
|
|
44
|
+
}
|
|
45
|
+
providerIdToCoveringProviders.get(id)!.add(providerId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return providerIdToCoveringProviders;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const filterProvidersByIds = (
|
|
53
|
+
providers: CurrenciesByProviderId[],
|
|
54
|
+
currencyIdsSet: Set<string>,
|
|
55
|
+
providerCoverageMap: ProviderCoverageMap,
|
|
56
|
+
): CurrenciesByProviderId[] => {
|
|
57
|
+
const filtered: CurrenciesByProviderId[] = [];
|
|
58
|
+
|
|
59
|
+
for (const provider of providers) {
|
|
60
|
+
const filteredCurrencies = provider.currenciesByNetwork.filter(currency =>
|
|
61
|
+
currencyIdsSet.has(currency.id),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (filteredCurrencies.length === 0) continue;
|
|
65
|
+
|
|
66
|
+
const providerHasOwnCurrency = provider.currenciesByNetwork.some(
|
|
67
|
+
currency => currency.id === provider.providerId,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (!providerHasOwnCurrency) {
|
|
71
|
+
const coveringProviders = providerCoverageMap.get(provider.providerId);
|
|
72
|
+
const isProviderIdCoveredElsewhere = coveringProviders && coveringProviders.size > 1;
|
|
73
|
+
|
|
74
|
+
if (isProviderIdCoveredElsewhere) continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (filteredCurrencies.length === provider.currenciesByNetwork.length) {
|
|
78
|
+
filtered.push(provider);
|
|
79
|
+
} else {
|
|
80
|
+
filtered.push({
|
|
81
|
+
...provider,
|
|
82
|
+
currenciesByNetwork: filteredCurrencies,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return filtered;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const extractProviderCurrencies = async (
|
|
91
|
+
providers: CurrenciesByProviderId[],
|
|
92
|
+
): Promise<CryptoOrTokenCurrency[]> => {
|
|
93
|
+
const currencies = await Promise.all(providers.map(provider => getProviderCurrency(provider)));
|
|
94
|
+
return currencies.filter((currency): currency is CryptoOrTokenCurrency => currency !== null);
|
|
95
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
import { AssetData } from "./type";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const groupCurrenciesByProvider = (assetsSorted: AssetData[]) => {
|
|
5
5
|
const assetMap = new Map<
|
|
6
6
|
string,
|
|
7
7
|
{ mainCurrency: CryptoOrTokenCurrency; currencies: CryptoOrTokenCurrency[] }
|
|
@@ -10,12 +10,12 @@ export const groupCurrenciesByAsset = (assetsSorted: AssetData[]) => {
|
|
|
10
10
|
if (assetsSorted) {
|
|
11
11
|
for (const item of assetsSorted) {
|
|
12
12
|
const {
|
|
13
|
-
asset: { id:
|
|
13
|
+
asset: { id: providerId },
|
|
14
14
|
networks = [],
|
|
15
15
|
} = item;
|
|
16
|
-
if (networks
|
|
17
|
-
const mainCurrency = networks.find(c => c.id ===
|
|
18
|
-
assetMap.set(
|
|
16
|
+
if (networks.length > 0) {
|
|
17
|
+
const mainCurrency = networks.find(c => c.id === providerId) ?? networks[0];
|
|
18
|
+
assetMap.set(providerId, {
|
|
19
19
|
mainCurrency,
|
|
20
20
|
currencies: networks,
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
export {
|
|
2
|
+
export { groupCurrenciesByProvider } from "./groupCurrenciesByProvider";
|
|
3
3
|
export { sortAccountsByFiatValue } from "./sortAccountsByFiatValue";
|
|
4
4
|
|
|
5
5
|
const getBaseId = (currency: CryptoOrTokenCurrency) =>
|
|
@@ -2,6 +2,8 @@ import { CounterValuesState } from "@ledgerhq/live-countervalues/lib/types";
|
|
|
2
2
|
import { CryptoOrTokenCurrency, Currency, Unit } from "@ledgerhq/types-cryptoassets";
|
|
3
3
|
import { AccountLike } from "@ledgerhq/types-live";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
|
+
import { Observable } from "rxjs";
|
|
6
|
+
import { WalletAPIAccount } from "../../wallet-api/types";
|
|
5
7
|
import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
|
|
6
8
|
import { InterestRate } from "../../dada-client/entities";
|
|
7
9
|
import { MarketItemResponse } from "../../market/utils/types";
|
|
@@ -69,6 +71,7 @@ export type AccountDataItem = {
|
|
|
69
71
|
|
|
70
72
|
export type AccountModuleParams = {
|
|
71
73
|
networks: CryptoOrTokenCurrency[];
|
|
74
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
export type CreateAccountsCount = (args: { label: string }) => ReactNode;
|
|
@@ -77,6 +80,7 @@ export type UseAccountData = (params: AccountModuleParams) => AccountDataItem[];
|
|
|
77
80
|
|
|
78
81
|
export type NetworkHookParams = {
|
|
79
82
|
networks: CryptoOrTokenCurrency[];
|
|
83
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
|
80
84
|
};
|
|
81
85
|
// Network hook type that returns additional properties to be merged with currencies
|
|
82
86
|
export type NetworkHook = (params: NetworkHookParams) => Array<{
|
|
@@ -107,6 +111,7 @@ export type Network = {
|
|
|
107
111
|
|
|
108
112
|
export type CreateNetworkConfigurationHookProps = {
|
|
109
113
|
networksConfig: EnhancedModularDrawerConfiguration["networks"];
|
|
114
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
|
110
115
|
};
|
|
111
116
|
|
|
112
117
|
type Props = {
|
package/src/platform/filters.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { makeRe } from "minimatch";
|
|
2
|
-
import { AppPlatform, PlatformAccount } from "./types";
|
|
2
|
+
import { AppPlatform, PlatformAccount, PlatformCurrency } from "./types";
|
|
3
|
+
import { isPlatformTokenCurrency } from "./helpers";
|
|
3
4
|
|
|
4
5
|
export type FilterParams = {
|
|
5
6
|
branches?: string[];
|
|
@@ -37,3 +38,24 @@ export type CurrencyFilters = {
|
|
|
37
38
|
includeTokens?: boolean;
|
|
38
39
|
currencies?: string[];
|
|
39
40
|
};
|
|
41
|
+
|
|
42
|
+
export function filterPlatformCurrencies(
|
|
43
|
+
currencies: PlatformCurrency[],
|
|
44
|
+
filters: CurrencyFilters,
|
|
45
|
+
): PlatformCurrency[] {
|
|
46
|
+
const filterCurrencyRegexes = filters.currencies
|
|
47
|
+
? filters.currencies.map(filter => makeRe(filter))
|
|
48
|
+
: null;
|
|
49
|
+
|
|
50
|
+
return currencies.filter(currency => {
|
|
51
|
+
if (!filters.includeTokens && isPlatformTokenCurrency(currency)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (filterCurrencyRegexes && !filterCurrencyRegexes.some(regex => currency.id.match(regex))) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return true;
|
|
60
|
+
});
|
|
61
|
+
}
|
package/src/platform/helpers.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { makeRe } from "minimatch";
|
|
2
|
+
import { isCryptoCurrency, isTokenCurrency, listCurrencies } from "../currencies";
|
|
3
|
+
import { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
|
|
3
4
|
import {
|
|
4
5
|
PlatformCurrency,
|
|
5
6
|
PlatformSupportedCurrency,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
PLATFORM_FAMILIES,
|
|
10
11
|
} from "./types";
|
|
11
12
|
import { includes } from "../helpers";
|
|
13
|
+
import { CurrencyFilters } from "./filters";
|
|
12
14
|
|
|
13
15
|
export function isPlatformSupportedCurrency(
|
|
14
16
|
currency: Currency,
|
|
@@ -28,8 +30,53 @@ export function isPlatformCryptoCurrency(
|
|
|
28
30
|
return currency.type === PlatformCurrencyType.CryptoCurrency;
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
export function isPlatformTokenCurrency(
|
|
34
|
+
currency: PlatformCurrency,
|
|
35
|
+
): currency is PlatformERC20TokenCurrency {
|
|
36
|
+
return currency.type === PlatformCurrencyType.TokenCurrency;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
export function isPlatformERC20TokenCurrency(
|
|
32
40
|
currency: PlatformCurrency,
|
|
33
41
|
): currency is PlatformERC20TokenCurrency {
|
|
34
42
|
return (currency as PlatformERC20TokenCurrency).standard === "ERC20";
|
|
35
43
|
}
|
|
44
|
+
|
|
45
|
+
export function filterCurrencies(
|
|
46
|
+
currencies: PlatformSupportedCurrency[],
|
|
47
|
+
filters: CurrencyFilters,
|
|
48
|
+
): CryptoOrTokenCurrency[] {
|
|
49
|
+
const filterCurrencyRegexes = filters.currencies
|
|
50
|
+
? filters.currencies.map(filter => makeRe(filter))
|
|
51
|
+
: null;
|
|
52
|
+
|
|
53
|
+
return currencies.filter(currency => {
|
|
54
|
+
if (!filters.includeTokens && isTokenCurrency(currency)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (
|
|
59
|
+
filterCurrencyRegexes &&
|
|
60
|
+
filterCurrencyRegexes.length &&
|
|
61
|
+
!filterCurrencyRegexes.some(regex => currency.id.match(regex))
|
|
62
|
+
) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return true;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function listAndFilterCurrencies({
|
|
71
|
+
includeTokens = false,
|
|
72
|
+
currencies,
|
|
73
|
+
}: CurrencyFilters): CryptoOrTokenCurrency[] {
|
|
74
|
+
// We removed the filtering with `isPlatformSupportedCurrency`
|
|
75
|
+
// As we want to show all the currencies in the requestAccount drawer
|
|
76
|
+
const allCurrencies = listCurrencies(includeTokens);
|
|
77
|
+
|
|
78
|
+
return filterCurrencies(allCurrencies, {
|
|
79
|
+
includeTokens,
|
|
80
|
+
currencies,
|
|
81
|
+
});
|
|
82
|
+
}
|
package/src/platform/react.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
|
-
import { ThunkDispatch, UnknownAction } from "@reduxjs/toolkit";
|
|
4
|
-
import { InfiniteData } from "@reduxjs/toolkit/query";
|
|
5
2
|
import { AccountLike } from "@ledgerhq/types-live";
|
|
6
|
-
import { makeRe } from "minimatch";
|
|
7
|
-
import type {
|
|
8
|
-
TokensDataWithPagination,
|
|
9
|
-
PageParam,
|
|
10
|
-
} from "@ledgerhq/cryptoassets/lib/cal-client/state-manager/types";
|
|
11
|
-
import { endpoints as calEndpoints } from "@ledgerhq/cryptoassets/cal-client/state-manager/api";
|
|
12
3
|
import { accountToPlatformAccount, currencyToPlatformCurrency } from "./converters";
|
|
13
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
filterPlatformAccounts,
|
|
6
|
+
filterPlatformCurrencies,
|
|
7
|
+
AccountFilters,
|
|
8
|
+
CurrencyFilters,
|
|
9
|
+
} from "./filters";
|
|
14
10
|
import { isPlatformSupportedCurrency } from "./helpers";
|
|
15
11
|
import {
|
|
16
12
|
ListPlatformAccount,
|
|
@@ -20,7 +16,7 @@ import {
|
|
|
20
16
|
PlatformAccount,
|
|
21
17
|
} from "./types";
|
|
22
18
|
import { getParentAccount } from "../account";
|
|
23
|
-
import {
|
|
19
|
+
import { listCurrencies } from "../currencies";
|
|
24
20
|
import { WalletState } from "@ledgerhq/live-wallet/store";
|
|
25
21
|
|
|
26
22
|
/**
|
|
@@ -79,84 +75,24 @@ export function useListPlatformAccounts(
|
|
|
79
75
|
);
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
export function
|
|
83
|
-
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return useCallback(
|
|
88
|
-
async (filters?: CurrencyFilters) => {
|
|
89
|
-
const filterCurrencyRegexes = filters?.currencies
|
|
90
|
-
? filters.currencies.map(filter => makeRe(filter))
|
|
91
|
-
: null;
|
|
92
|
-
|
|
93
|
-
// 1. Gather all supported parent currencies
|
|
94
|
-
const allCurrencies = listSupportedCurrencies().reduce<PlatformCurrency[]>((acc, c) => {
|
|
95
|
-
if (isPlatformSupportedCurrency(c) && !deactivatedCurrencyIds.has(c.id))
|
|
96
|
-
acc.push(currencyToPlatformCurrency(c));
|
|
97
|
-
return acc;
|
|
98
|
-
}, []);
|
|
99
|
-
|
|
100
|
-
// 2. Determine which currencies to include based on patterns
|
|
101
|
-
let includedCurrencies: PlatformCurrency[] = allCurrencies;
|
|
102
|
-
if (filterCurrencyRegexes) {
|
|
103
|
-
includedCurrencies = allCurrencies.filter(c => {
|
|
104
|
-
if (filterCurrencyRegexes && !filterCurrencyRegexes.some(regex => c.id.match(regex))) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (filters?.includeTokens === false) {
|
|
112
|
-
return includedCurrencies;
|
|
78
|
+
export function usePlatformCurrencies(): PlatformCurrency[] {
|
|
79
|
+
return useMemo(() => {
|
|
80
|
+
return listCurrencies(true).reduce<PlatformCurrency[]>((filtered, currency) => {
|
|
81
|
+
if (isPlatformSupportedCurrency(currency)) {
|
|
82
|
+
filtered.push(currencyToPlatformCurrency(currency));
|
|
113
83
|
}
|
|
84
|
+
return filtered;
|
|
85
|
+
}, []);
|
|
86
|
+
}, []);
|
|
87
|
+
}
|
|
114
88
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
includedCurrencies.forEach(c => {
|
|
118
|
-
if (c.type === "CryptoCurrency") familiesToFetch.add(c.family);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// 4. Fetch tokens for relevant families
|
|
122
|
-
const fetchAllPagesForFamily = async (family: string) => {
|
|
123
|
-
const args = { networkFamily: family, pageSize: 1000 };
|
|
124
|
-
let hasNextPage = true;
|
|
125
|
-
let data: InfiniteData<TokensDataWithPagination, PageParam> | undefined;
|
|
126
|
-
|
|
127
|
-
while (hasNextPage) {
|
|
128
|
-
const querySub = dispatch(
|
|
129
|
-
calEndpoints.getTokensData.initiate(args, data ? { direction: "forward" } : undefined),
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
const result = await querySub;
|
|
134
|
-
data = result.data;
|
|
135
|
-
hasNextPage = result.hasNextPage;
|
|
136
|
-
if (result.error) throw result.error;
|
|
137
|
-
} finally {
|
|
138
|
-
querySub.unsubscribe();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return (data?.pages ?? []).flatMap(p => p.tokens);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const tokensByFamily = await Promise.all(
|
|
146
|
-
[...familiesToFetch].map(f => fetchAllPagesForFamily(f)),
|
|
147
|
-
);
|
|
89
|
+
export function useListPlatformCurrencies(): ListPlatformCurrency {
|
|
90
|
+
const currencies = usePlatformCurrencies();
|
|
148
91
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const pc = currencyToPlatformCurrency(t);
|
|
153
|
-
if (!filterCurrencyRegexes || filterCurrencyRegexes.some(r => pc.id.match(r))) {
|
|
154
|
-
tAcc.push(pc);
|
|
155
|
-
}
|
|
156
|
-
return tAcc;
|
|
157
|
-
}, acc);
|
|
158
|
-
}, includedCurrencies);
|
|
92
|
+
return useCallback(
|
|
93
|
+
(filters?: CurrencyFilters) => {
|
|
94
|
+
return filterPlatformCurrencies(currencies, filters || {});
|
|
159
95
|
},
|
|
160
|
-
[
|
|
96
|
+
[currencies],
|
|
161
97
|
);
|
|
162
98
|
}
|
package/src/platform/types.ts
CHANGED
|
@@ -196,6 +196,6 @@ export type PlatformSignedTransaction = SignedOperation;
|
|
|
196
196
|
|
|
197
197
|
export type ListPlatformAccount = (filters?: AccountFilters) => PlatformAccount[];
|
|
198
198
|
|
|
199
|
-
export type ListPlatformCurrency = (filters?: CurrencyFilters) =>
|
|
199
|
+
export type ListPlatformCurrency = (filters?: CurrencyFilters) => PlatformCurrency[];
|
|
200
200
|
|
|
201
201
|
export type PlatformSupportedCurrency = CryptoCurrency | TokenCurrency;
|
|
@@ -54,6 +54,19 @@ describe("getAccountTuplesForCurrency", () => {
|
|
|
54
54
|
|
|
55
55
|
expect(results).toHaveLength(0);
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
test("filters based on the accountId map", () => {
|
|
59
|
+
const ethCurrency = getCryptoCurrencyById("ethereum");
|
|
60
|
+
const ethAccounts = [getEthAccount(), getEthAccount(), getEthAccount(), getEthAccount()];
|
|
61
|
+
|
|
62
|
+
const results = getAccountTuplesForCurrency(
|
|
63
|
+
ethCurrency,
|
|
64
|
+
ethAccounts,
|
|
65
|
+
new Map([[ethAccounts[0].id, true]]),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
expect(results).toHaveLength(1);
|
|
69
|
+
});
|
|
57
70
|
});
|
|
58
71
|
|
|
59
72
|
describe("TokenCurrency", () => {
|
|
@@ -117,5 +130,22 @@ describe("getAccountTuplesForCurrency", () => {
|
|
|
117
130
|
const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
|
|
118
131
|
expect(results).toHaveLength(0);
|
|
119
132
|
});
|
|
133
|
+
|
|
134
|
+
test("does not filter based on the accountId map", () => {
|
|
135
|
+
const aaveAccounts = [
|
|
136
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
|
137
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
|
138
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
|
139
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const results = getAccountTuplesForCurrency(
|
|
143
|
+
aaveToken,
|
|
144
|
+
aaveAccounts,
|
|
145
|
+
new Map([[aaveAccounts[0].id, true]]),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(results).toHaveLength(4);
|
|
149
|
+
});
|
|
120
150
|
});
|
|
121
151
|
});
|
|
@@ -10,12 +10,17 @@ export type AccountTuple = {
|
|
|
10
10
|
export function getAccountTuplesForCurrency(
|
|
11
11
|
currency: CryptoCurrency | TokenCurrency,
|
|
12
12
|
allAccounts: Account[],
|
|
13
|
+
accountIds?: Map<string, boolean>,
|
|
13
14
|
): AccountTuple[] {
|
|
14
15
|
const isToken = currency.type === "TokenCurrency";
|
|
15
16
|
const targetCurrencyId = isToken ? currency.parentCurrency.id : currency.id;
|
|
16
17
|
|
|
17
18
|
return allAccounts
|
|
18
|
-
.filter(
|
|
19
|
+
.filter(
|
|
20
|
+
account =>
|
|
21
|
+
account.currency.id === targetCurrencyId &&
|
|
22
|
+
(isToken ? true : accountIds ? accountIds.has(account.id) : true),
|
|
23
|
+
)
|
|
19
24
|
.map(account => {
|
|
20
25
|
const subAccount = isToken
|
|
21
26
|
? account.subAccounts?.find(
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ExchangeStartFundParams,
|
|
7
7
|
} from "@ledgerhq/wallet-api-exchange-module";
|
|
8
8
|
import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
|
|
9
|
+
import { of } from "rxjs";
|
|
9
10
|
import { genAccount } from "../../mock/account";
|
|
10
11
|
import { AppBranch, AppPlatform, Visibility } from "../types";
|
|
11
12
|
import { handlers } from "./server";
|
|
@@ -192,6 +193,8 @@ function prepareSwapRequest(params: ExchangeStartSwapParams): PreparedRequest {
|
|
|
192
193
|
};
|
|
193
194
|
|
|
194
195
|
const context = {
|
|
196
|
+
currencies$: of([]),
|
|
197
|
+
accounts$: of([]),
|
|
195
198
|
config: {
|
|
196
199
|
userId: "userId",
|
|
197
200
|
tracking: false,
|
|
@@ -219,6 +222,8 @@ function prepareSellRequest(params: ExchangeStartParams): PreparedRequest {
|
|
|
219
222
|
};
|
|
220
223
|
|
|
221
224
|
const context = {
|
|
225
|
+
currencies$: of([]),
|
|
226
|
+
accounts$: of([]),
|
|
222
227
|
config: {
|
|
223
228
|
userId: "userId",
|
|
224
229
|
tracking: false,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getParentAccount,
|
|
5
5
|
makeEmptyTokenAccount,
|
|
6
6
|
} from "@ledgerhq/coin-framework/account/index";
|
|
7
|
+
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets";
|
|
7
8
|
import { getCryptoAssetsStore } from "../../bridge/crypto-assets/index";
|
|
8
9
|
import { decodeSwapPayload } from "@ledgerhq/hw-app-exchange";
|
|
9
10
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
@@ -763,16 +764,14 @@ async function getToCurrency(
|
|
|
763
764
|
|
|
764
765
|
// In case of an SPL Token recipient and no TokenAccount exists.
|
|
765
766
|
if (
|
|
766
|
-
toAccount.type !== "TokenAccount" && // it must
|
|
767
|
+
toAccount.type !== "TokenAccount" && // it must no be a SPL Token
|
|
767
768
|
toAccount.currency.id === "solana" && // the target account must be a SOL Account
|
|
768
769
|
tokenAddress !== toAccount.freshAddress
|
|
769
770
|
) {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
);
|
|
775
|
-
if (splTokenCurrency && splTokenCurrency.ticker === currencyTo) return splTokenCurrency;
|
|
771
|
+
const splTokenCurrency = listTokensForCryptoCurrency(toAccount.currency).find(
|
|
772
|
+
tk => tk.tokenType === "spl" && tk.ticker === currencyTo,
|
|
773
|
+
)!;
|
|
774
|
+
return splTokenCurrency;
|
|
776
775
|
}
|
|
777
776
|
|
|
778
777
|
return newTokenAccount?.token ?? getCurrencyForAccount(toAccount);
|
|
@@ -22,17 +22,12 @@ export const getAccountIdFromWalletAccountId = (walletAccountId: string): string
|
|
|
22
22
|
|
|
23
23
|
export const getWalletApiIdFromAccountId = (id: string): string => uuidv5(id, NAMESPACE);
|
|
24
24
|
|
|
25
|
-
export const setWalletApiIdForAccountId = (accountId: string): void => {
|
|
26
|
-
const walletApiId = getWalletApiIdFromAccountId(accountId);
|
|
27
|
-
uuidToAccountId.set(walletApiId, accountId);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
25
|
export function accountToWalletAPIAccount(
|
|
31
26
|
walletState: WalletState,
|
|
32
27
|
account: AccountLike,
|
|
33
28
|
parentAccount?: Account | null,
|
|
34
29
|
): WalletAPIAccount {
|
|
35
|
-
const walletApiId =
|
|
30
|
+
const walletApiId = uuidv5(account.id, NAMESPACE);
|
|
36
31
|
uuidToAccountId.set(walletApiId, account.id);
|
|
37
32
|
|
|
38
33
|
if (isTokenAccount(account)) {
|