@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
package/src/wallet-api/react.ts
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
import { useMemo, useState, useEffect, useRef, useCallback, RefObject } from "react";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
2
|
import semver from "semver";
|
|
4
3
|
import { intervalToDuration } from "date-fns";
|
|
4
|
+
|
|
5
5
|
import { Account, AccountLike, AnyMessage, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
WalletAPIServer,
|
|
10
|
-
useWalletAPIServer as useWalletAPIServerRaw,
|
|
11
|
-
} from "@ledgerhq/wallet-api-server";
|
|
6
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
7
|
+
import { WalletHandlers, ServerConfig, WalletAPIServer } from "@ledgerhq/wallet-api-server";
|
|
8
|
+
import { useWalletAPIServer as useWalletAPIServerRaw } from "@ledgerhq/wallet-api-server/lib/react";
|
|
12
9
|
import { Transport, Permission } from "@ledgerhq/wallet-api-core";
|
|
13
|
-
import { first } from "rxjs/operators";
|
|
14
|
-
import { getEnv } from "@ledgerhq/live-env";
|
|
15
|
-
import { UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
16
|
-
import { WalletState } from "@ledgerhq/live-wallet/store";
|
|
17
|
-
import { endpoints as calEndpoints } from "@ledgerhq/cryptoassets/cal-client/state-manager/api";
|
|
18
|
-
import { ThunkDispatch, UnknownAction } from "@reduxjs/toolkit";
|
|
19
|
-
import { InfiniteData } from "@reduxjs/toolkit/query";
|
|
20
|
-
import type {
|
|
21
|
-
TokensDataWithPagination,
|
|
22
|
-
PageParam,
|
|
23
|
-
} from "@ledgerhq/cryptoassets/lib/cal-client/state-manager/types";
|
|
24
|
-
import { Subject } from "rxjs";
|
|
25
10
|
import { StateDB } from "../hooks/useDBRaw";
|
|
11
|
+
import { Observable, firstValueFrom, Subject } from "rxjs";
|
|
12
|
+
import { first } from "rxjs/operators";
|
|
26
13
|
import {
|
|
27
14
|
accountToWalletAPIAccount,
|
|
28
15
|
currencyToWalletAPICurrency,
|
|
29
|
-
|
|
16
|
+
getAccountIdFromWalletAccountId,
|
|
30
17
|
} from "./converters";
|
|
31
18
|
import { isWalletAPISupportedCurrency } from "./helpers";
|
|
32
19
|
import { WalletAPICurrency, AppManifest, WalletAPIAccount, WalletAPICustomHandlers } from "./types";
|
|
20
|
+
|
|
33
21
|
import { getMainAccount, getParentAccount } from "../account";
|
|
34
|
-
import {
|
|
35
|
-
import { getCryptoAssetsStore } from "../bridge/crypto-assets";
|
|
22
|
+
import { listCurrencies, findCryptoCurrencyById, getCryptoCurrencyById } from "../currencies";
|
|
23
|
+
import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
|
|
36
24
|
import { TrackingAPI } from "./tracking";
|
|
37
25
|
import {
|
|
38
26
|
bitcoinFamilyAccountGetXPubLogic,
|
|
@@ -49,8 +37,10 @@ import {
|
|
|
49
37
|
signRawTransactionLogic,
|
|
50
38
|
} from "./logic";
|
|
51
39
|
import { getAccountBridge } from "../bridge";
|
|
40
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
52
41
|
import openTransportAsSubject, { BidirectionalEvent } from "../hw/openTransportAsSubject";
|
|
53
42
|
import { AppResult } from "../hw/actions/app";
|
|
43
|
+
import { UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
54
44
|
import { Transaction } from "../generated/types";
|
|
55
45
|
import {
|
|
56
46
|
DISCOVER_INITIAL_CATEGORY,
|
|
@@ -59,8 +49,8 @@ import {
|
|
|
59
49
|
} from "./constants";
|
|
60
50
|
import { DiscoverDB } from "./types";
|
|
61
51
|
import { LiveAppManifest } from "../platform/types";
|
|
52
|
+
import { WalletState } from "@ledgerhq/live-wallet/store";
|
|
62
53
|
import { ModularDrawerConfiguration } from "./ModularDrawer/types";
|
|
63
|
-
import { useCurrenciesUnderFeatureFlag } from "../modularDrawer/hooks/useCurrenciesUnderFeatureFlag";
|
|
64
54
|
|
|
65
55
|
export function safeGetRefValue<T>(ref: RefObject<T>): NonNullable<T> {
|
|
66
56
|
if (!ref.current) {
|
|
@@ -69,27 +59,75 @@ export function safeGetRefValue<T>(ref: RefObject<T>): NonNullable<T> {
|
|
|
69
59
|
return ref.current;
|
|
70
60
|
}
|
|
71
61
|
|
|
72
|
-
export function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
export function useWalletAPIAccounts(
|
|
63
|
+
walletState: WalletState,
|
|
64
|
+
accounts: AccountLike[],
|
|
65
|
+
): WalletAPIAccount[] {
|
|
66
|
+
return useMemo(() => {
|
|
67
|
+
return accounts.map(account => {
|
|
68
|
+
const parentAccount = getParentAccount(account, accounts);
|
|
69
|
+
|
|
70
|
+
return accountToWalletAPIAccount(walletState, account, parentAccount);
|
|
76
71
|
});
|
|
77
|
-
}, [accounts]);
|
|
72
|
+
}, [walletState, accounts]);
|
|
78
73
|
}
|
|
79
74
|
|
|
80
|
-
export function
|
|
75
|
+
export function useWalletAPICurrencies(): WalletAPICurrency[] {
|
|
76
|
+
return useMemo(() => {
|
|
77
|
+
return listCurrencies(true).reduce<WalletAPICurrency[]>((filtered, currency) => {
|
|
78
|
+
if (isWalletAPISupportedCurrency(currency)) {
|
|
79
|
+
filtered.push(currencyToWalletAPICurrency(currency));
|
|
80
|
+
}
|
|
81
|
+
return filtered;
|
|
82
|
+
}, []);
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function useManifestCurrencies(manifest: AppManifest) {
|
|
81
87
|
return useMemo(() => {
|
|
82
88
|
return (
|
|
83
89
|
manifest.dapp?.networks.map(network => {
|
|
84
|
-
return network.currency;
|
|
90
|
+
return getCryptoCurrencyById(network.currency);
|
|
85
91
|
}) ?? []
|
|
86
92
|
);
|
|
87
93
|
}, [manifest.dapp?.networks]);
|
|
88
94
|
}
|
|
89
95
|
|
|
96
|
+
export function useGetAccountIds(
|
|
97
|
+
accounts$: Observable<WalletAPIAccount[]> | undefined,
|
|
98
|
+
): Map<string, boolean> | undefined {
|
|
99
|
+
const [accounts, setAccounts] = useState<WalletAPIAccount[]>([]);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!accounts$) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const subscription = accounts$.subscribe(walletAccounts => {
|
|
107
|
+
setAccounts(walletAccounts);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
subscription.unsubscribe();
|
|
112
|
+
};
|
|
113
|
+
}, [accounts$]);
|
|
114
|
+
|
|
115
|
+
return useMemo(() => {
|
|
116
|
+
if (!accounts$) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return accounts.reduce((accountIds, account) => {
|
|
121
|
+
accountIds.set(getAccountIdFromWalletAccountId(account.id), true);
|
|
122
|
+
return accountIds;
|
|
123
|
+
}, new Map());
|
|
124
|
+
}, [accounts, accounts$]);
|
|
125
|
+
}
|
|
126
|
+
|
|
90
127
|
export interface UiHook {
|
|
91
128
|
"account.request": (params: {
|
|
92
|
-
|
|
129
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
|
130
|
+
currencies: CryptoOrTokenCurrency[];
|
|
93
131
|
areCurrenciesFiltered?: boolean;
|
|
94
132
|
useCase?: string;
|
|
95
133
|
drawerConfiguration?: ModularDrawerConfiguration;
|
|
@@ -162,10 +200,11 @@ export interface UiHook {
|
|
|
162
200
|
}) => void;
|
|
163
201
|
}
|
|
164
202
|
|
|
165
|
-
export function usePermission(manifest: AppManifest):
|
|
203
|
+
export function usePermission(manifest: AppManifest): Permission {
|
|
166
204
|
return useMemo(
|
|
167
205
|
() => ({
|
|
168
|
-
|
|
206
|
+
currencyIds: manifest.currencies === "*" ? ["**"] : manifest.currencies,
|
|
207
|
+
methodIds: manifest.permissions as unknown as string[], // TODO remove when using the correct manifest type
|
|
169
208
|
}),
|
|
170
209
|
[manifest],
|
|
171
210
|
);
|
|
@@ -195,7 +234,7 @@ export function useConfig({
|
|
|
195
234
|
wallet,
|
|
196
235
|
mevProtected,
|
|
197
236
|
}),
|
|
198
|
-
[appId,
|
|
237
|
+
[appId, tracking, userId, wallet],
|
|
199
238
|
);
|
|
200
239
|
}
|
|
201
240
|
|
|
@@ -303,19 +342,18 @@ export function useWalletAPIServer({
|
|
|
303
342
|
onLoadError: () => void;
|
|
304
343
|
widgetLoaded: boolean;
|
|
305
344
|
} {
|
|
306
|
-
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>();
|
|
307
|
-
const { deactivatedCurrencyIds } = useCurrenciesUnderFeatureFlag();
|
|
308
345
|
const permission = usePermission(manifest);
|
|
309
346
|
const transport = useTransport(webviewHook.postMessage);
|
|
310
347
|
const [widgetLoaded, setWidgetLoaded] = useState(false);
|
|
311
348
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
useSetWalletAPIAccounts(accounts);
|
|
349
|
+
const walletAPIAccounts = useWalletAPIAccounts(walletState, accounts);
|
|
350
|
+
const walletAPICurrencies = useWalletAPICurrencies();
|
|
315
351
|
|
|
316
352
|
const { server, onMessage } = useWalletAPIServerRaw({
|
|
317
353
|
transport,
|
|
318
354
|
config,
|
|
355
|
+
accounts: walletAPIAccounts,
|
|
356
|
+
currencies: walletAPICurrencies,
|
|
319
357
|
permission,
|
|
320
358
|
customHandlers,
|
|
321
359
|
});
|
|
@@ -324,257 +362,52 @@ export function useWalletAPIServer({
|
|
|
324
362
|
tracking.load(manifest);
|
|
325
363
|
}, [tracking, manifest]);
|
|
326
364
|
|
|
327
|
-
// TODO: refactor each handler into its own logic function for clarity
|
|
328
|
-
useEffect(() => {
|
|
329
|
-
server.setHandler("currency.list", async ({ currencyIds }) => {
|
|
330
|
-
tracking.currencyListRequested(manifest);
|
|
331
|
-
|
|
332
|
-
try {
|
|
333
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
334
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
335
|
-
|
|
336
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
337
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
338
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
339
|
-
|
|
340
|
-
if (queryCurrencyIdsSet) {
|
|
341
|
-
// If we have a query filter, narrow down what we need to fetch
|
|
342
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
343
|
-
if (manifestId === "**") {
|
|
344
|
-
// Query can ask for anything, so use the query list
|
|
345
|
-
return [...queryCurrencyIdsSet];
|
|
346
|
-
} else if (manifestId.endsWith("/**")) {
|
|
347
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
348
|
-
const family = manifestId.slice(0, -3);
|
|
349
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
350
|
-
} else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
351
|
-
// Specific currency/token that's in the query
|
|
352
|
-
return [manifestId];
|
|
353
|
-
}
|
|
354
|
-
// Not in query, skip it
|
|
355
|
-
return [];
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// 3. Parse effective currency IDs to determine what to fetch
|
|
360
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
361
|
-
const specificCurrencies = new Set<string>();
|
|
362
|
-
const tokenFamilies = new Set<string>();
|
|
363
|
-
const specificTokenIds = new Set<string>();
|
|
364
|
-
|
|
365
|
-
for (const id of effectiveCurrencyIds) {
|
|
366
|
-
if (id === "**") {
|
|
367
|
-
// Already handled above
|
|
368
|
-
continue;
|
|
369
|
-
} else if (id.endsWith("/**")) {
|
|
370
|
-
// Pattern like "ethereum/**" or "solana/**" - include tokens for this family
|
|
371
|
-
const family = id.slice(0, -3);
|
|
372
|
-
tokenFamilies.add(family);
|
|
373
|
-
} else if (id.includes("/")) {
|
|
374
|
-
// Specific token ID like "ethereum/erc20/usd__coin"
|
|
375
|
-
specificTokenIds.add(id);
|
|
376
|
-
} else {
|
|
377
|
-
// Specific currency like "bitcoin" or "ethereum"
|
|
378
|
-
specificCurrencies.add(id);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// 4. Gather all supported parent currencies
|
|
383
|
-
const allCurrencies = listSupportedCurrencies().reduce<WalletAPICurrency[]>((acc, c) => {
|
|
384
|
-
if (isWalletAPISupportedCurrency(c) && !deactivatedCurrencyIds.has(c.id))
|
|
385
|
-
acc.push(currencyToWalletAPICurrency(c));
|
|
386
|
-
return acc;
|
|
387
|
-
}, []);
|
|
388
|
-
|
|
389
|
-
// 5. Determine which currencies to include based on patterns
|
|
390
|
-
let includedCurrencies: WalletAPICurrency[] = [];
|
|
391
|
-
if (includeAllCurrencies) {
|
|
392
|
-
includedCurrencies = allCurrencies;
|
|
393
|
-
} else {
|
|
394
|
-
includedCurrencies = allCurrencies.filter(c => specificCurrencies.has(c.id));
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// 6. Fetch specific tokens by ID if any
|
|
398
|
-
const specificTokens: WalletAPICurrency[] = [];
|
|
399
|
-
if (specificTokenIds.size > 0) {
|
|
400
|
-
const tokenPromises = [...specificTokenIds].map(async tokenId => {
|
|
401
|
-
const token = await getCryptoAssetsStore().findTokenById(tokenId);
|
|
402
|
-
return token ? currencyToWalletAPICurrency(token) : null;
|
|
403
|
-
});
|
|
404
|
-
const resolvedTokens = await Promise.all(tokenPromises);
|
|
405
|
-
specificTokens.push(...resolvedTokens.filter((t): t is WalletAPICurrency => t !== null));
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// 7. Determine which token families to fetch (only if not already fetched as specific tokens)
|
|
409
|
-
const familiesToFetch = new Set<string>();
|
|
410
|
-
if (includeAllCurrencies) {
|
|
411
|
-
// Fetch tokens for all currency families
|
|
412
|
-
allCurrencies.forEach(c => {
|
|
413
|
-
if (c.type === "CryptoCurrency") familiesToFetch.add(c.family);
|
|
414
|
-
});
|
|
415
|
-
} else if (tokenFamilies.size > 0) {
|
|
416
|
-
// Only fetch tokens for families explicitly marked with /**
|
|
417
|
-
tokenFamilies.forEach(family => familiesToFetch.add(family));
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// 8. Fetch tokens for relevant families
|
|
421
|
-
const fetchAllPagesForFamily = async (family: string) => {
|
|
422
|
-
const args = { networkFamily: family, pageSize: 1000 };
|
|
423
|
-
let hasNextPage = true;
|
|
424
|
-
let data: InfiniteData<TokensDataWithPagination, PageParam> | undefined;
|
|
425
|
-
|
|
426
|
-
while (hasNextPage) {
|
|
427
|
-
const querySub = dispatch(
|
|
428
|
-
calEndpoints.getTokensData.initiate(
|
|
429
|
-
args,
|
|
430
|
-
data ? { direction: "forward" } : undefined,
|
|
431
|
-
),
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
try {
|
|
435
|
-
const result = await querySub;
|
|
436
|
-
data = result.data;
|
|
437
|
-
hasNextPage = result.hasNextPage;
|
|
438
|
-
if (result.error) throw result.error;
|
|
439
|
-
} finally {
|
|
440
|
-
querySub.unsubscribe();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return (data?.pages ?? []).flatMap(p => p.tokens);
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
const tokensByFamily = await Promise.all(
|
|
448
|
-
[...familiesToFetch].map(f => fetchAllPagesForFamily(f)),
|
|
449
|
-
);
|
|
450
|
-
|
|
451
|
-
// 9. Combine all results (no additional filter needed since we pre-filtered)
|
|
452
|
-
const result = tokensByFamily.reduce<WalletAPICurrency[]>(
|
|
453
|
-
(acc, tokens) => [...acc, ...tokens.map(t => currencyToWalletAPICurrency(t))],
|
|
454
|
-
[...includedCurrencies, ...specificTokens],
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
tracking.currencyListSuccess(manifest);
|
|
458
|
-
return result;
|
|
459
|
-
} catch (err) {
|
|
460
|
-
tracking.currencyListFail(manifest);
|
|
461
|
-
throw err;
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}, [walletState, manifest, server, tracking, dispatch, deactivatedCurrencyIds]);
|
|
465
|
-
|
|
466
|
-
useEffect(() => {
|
|
467
|
-
server.setHandler("account.list", ({ currencyIds }) => {
|
|
468
|
-
tracking.accountListRequested(manifest);
|
|
469
|
-
|
|
470
|
-
try {
|
|
471
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
472
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
473
|
-
|
|
474
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
475
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
476
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
477
|
-
|
|
478
|
-
if (queryCurrencyIdsSet) {
|
|
479
|
-
// If we have a query filter, narrow down what we need to check
|
|
480
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
481
|
-
if (manifestId === "**") {
|
|
482
|
-
// Query can ask for anything, so use the query list
|
|
483
|
-
return [...queryCurrencyIdsSet];
|
|
484
|
-
} else if (manifestId.endsWith("/**")) {
|
|
485
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
486
|
-
const family = manifestId.slice(0, -3);
|
|
487
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
488
|
-
} else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
489
|
-
// Specific currency/token that's in the query
|
|
490
|
-
return [manifestId];
|
|
491
|
-
}
|
|
492
|
-
// Not in query, skip it
|
|
493
|
-
return [];
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// 3. Build a set of allowed currency IDs based on effective patterns
|
|
498
|
-
const allowedCurrencyIds = new Set<string>();
|
|
499
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
500
|
-
const tokenFamilyPrefixes = new Set<string>();
|
|
501
|
-
|
|
502
|
-
for (const id of effectiveCurrencyIds) {
|
|
503
|
-
if (id === "**") {
|
|
504
|
-
// Will match all currencies
|
|
505
|
-
continue;
|
|
506
|
-
} else if (id.endsWith("/**")) {
|
|
507
|
-
// Pattern like "ethereum/**" - store prefix for matching
|
|
508
|
-
const family = id.slice(0, -3);
|
|
509
|
-
tokenFamilyPrefixes.add(family);
|
|
510
|
-
} else {
|
|
511
|
-
// Specific currency/token ID
|
|
512
|
-
allowedCurrencyIds.add(id);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// 4. Filter accounts based on effective currency IDs
|
|
517
|
-
const wapiAccounts = accounts.reduce<WalletAPIAccount[]>((acc, account) => {
|
|
518
|
-
const parentAccount = getParentAccount(account, accounts);
|
|
519
|
-
const accountCurrencyId =
|
|
520
|
-
account.type === "TokenAccount" ? account.token.id : account.currency.id;
|
|
521
|
-
const parentCurrencyId =
|
|
522
|
-
account.type === "TokenAccount" ? account.token.parentCurrency.id : account.currency.id;
|
|
523
|
-
|
|
524
|
-
// Check if account currency ID matches the effective patterns
|
|
525
|
-
const isAllowed =
|
|
526
|
-
includeAllCurrencies ||
|
|
527
|
-
allowedCurrencyIds.has(accountCurrencyId) ||
|
|
528
|
-
tokenFamilyPrefixes.has(parentCurrencyId);
|
|
529
|
-
|
|
530
|
-
if (isAllowed) {
|
|
531
|
-
acc.push(accountToWalletAPIAccount(walletState, account, parentAccount));
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
return acc;
|
|
535
|
-
}, []);
|
|
536
|
-
|
|
537
|
-
tracking.accountListSuccess(manifest);
|
|
538
|
-
return wapiAccounts;
|
|
539
|
-
} catch (err) {
|
|
540
|
-
tracking.accountListFail(manifest);
|
|
541
|
-
throw err;
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}, [walletState, manifest, server, tracking, uiAccountRequest, accounts]);
|
|
545
|
-
|
|
546
365
|
useEffect(() => {
|
|
547
366
|
if (!uiAccountRequest) return;
|
|
548
367
|
|
|
549
368
|
server.setHandler(
|
|
550
369
|
"account.request",
|
|
551
|
-
async ({
|
|
370
|
+
async ({ accounts$, currencies$, drawerConfiguration, areCurrenciesFiltered, useCase }) => {
|
|
552
371
|
tracking.requestAccountRequested(manifest);
|
|
372
|
+
const currencies = await firstValueFrom(currencies$);
|
|
373
|
+
|
|
553
374
|
return new Promise((resolve, reject) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
375
|
+
(async () => {
|
|
376
|
+
try {
|
|
377
|
+
// handle no curencies selected case
|
|
378
|
+
const currencyList: CryptoOrTokenCurrency[] = [];
|
|
379
|
+
for (const { id } of currencies) {
|
|
380
|
+
const currency =
|
|
381
|
+
findCryptoCurrencyById(id) || (await getCryptoAssetsStore().findTokenById(id));
|
|
382
|
+
if (currency) {
|
|
383
|
+
currencyList.push(currency);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
let done = false;
|
|
388
|
+
uiAccountRequest({
|
|
389
|
+
accounts$,
|
|
390
|
+
currencies: currencyList,
|
|
391
|
+
drawerConfiguration,
|
|
392
|
+
areCurrenciesFiltered,
|
|
393
|
+
useCase,
|
|
394
|
+
onSuccess: (account: AccountLike, parentAccount: Account | undefined) => {
|
|
395
|
+
if (done) return;
|
|
396
|
+
done = true;
|
|
397
|
+
tracking.requestAccountSuccess(manifest);
|
|
398
|
+
resolve(accountToWalletAPIAccount(walletState, account, parentAccount));
|
|
399
|
+
},
|
|
400
|
+
onCancel: () => {
|
|
401
|
+
if (done) return;
|
|
402
|
+
done = true;
|
|
403
|
+
tracking.requestAccountFail(manifest);
|
|
404
|
+
reject(new Error("Canceled by user"));
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
} catch (error) {
|
|
408
|
+
reject(error);
|
|
409
|
+
}
|
|
410
|
+
})();
|
|
578
411
|
});
|
|
579
412
|
},
|
|
580
413
|
);
|
|
@@ -583,11 +416,11 @@ export function useWalletAPIServer({
|
|
|
583
416
|
useEffect(() => {
|
|
584
417
|
if (!uiAccountReceive) return;
|
|
585
418
|
|
|
586
|
-
server.setHandler("account.receive", ({
|
|
419
|
+
server.setHandler("account.receive", ({ account, tokenCurrency }) =>
|
|
587
420
|
receiveOnAccountLogic(
|
|
588
421
|
walletState,
|
|
589
422
|
{ manifest, accounts, tracking },
|
|
590
|
-
|
|
423
|
+
account.id,
|
|
591
424
|
(account, parentAccount, accountAddress) =>
|
|
592
425
|
new Promise((resolve, reject) => {
|
|
593
426
|
let done = false;
|
|
@@ -623,10 +456,10 @@ export function useWalletAPIServer({
|
|
|
623
456
|
useEffect(() => {
|
|
624
457
|
if (!uiMessageSign) return;
|
|
625
458
|
|
|
626
|
-
server.setHandler("message.sign", ({
|
|
459
|
+
server.setHandler("message.sign", ({ account, message, options }) =>
|
|
627
460
|
signMessageLogic(
|
|
628
461
|
{ manifest, accounts, tracking },
|
|
629
|
-
|
|
462
|
+
account.id,
|
|
630
463
|
message.toString("hex"),
|
|
631
464
|
(account: AccountLike, message: AnyMessage) =>
|
|
632
465
|
new Promise((resolve, reject) => {
|
|
@@ -680,18 +513,13 @@ export function useWalletAPIServer({
|
|
|
680
513
|
|
|
681
514
|
server.setHandler(
|
|
682
515
|
"transaction.sign",
|
|
683
|
-
async ({
|
|
684
|
-
let currency: string | undefined;
|
|
516
|
+
async ({ account, tokenCurrency, transaction, options }) => {
|
|
685
517
|
const signedOperation = await signTransactionLogic(
|
|
686
518
|
{ manifest, accounts, tracking },
|
|
687
|
-
|
|
519
|
+
account.id,
|
|
688
520
|
transaction,
|
|
689
|
-
(account, parentAccount, signFlowInfos) =>
|
|
690
|
-
|
|
691
|
-
account.type === "TokenAccount"
|
|
692
|
-
? account.token.parentCurrency.id
|
|
693
|
-
: account.currency.id;
|
|
694
|
-
return new Promise((resolve, reject) => {
|
|
521
|
+
(account, parentAccount, signFlowInfos) =>
|
|
522
|
+
new Promise((resolve, reject) => {
|
|
695
523
|
let done = false;
|
|
696
524
|
return uiTxSign({
|
|
697
525
|
account,
|
|
@@ -711,12 +539,11 @@ export function useWalletAPIServer({
|
|
|
711
539
|
reject(error);
|
|
712
540
|
},
|
|
713
541
|
});
|
|
714
|
-
})
|
|
715
|
-
},
|
|
542
|
+
}),
|
|
716
543
|
tokenCurrency,
|
|
717
544
|
);
|
|
718
545
|
|
|
719
|
-
return currency === "solana"
|
|
546
|
+
return account.currency === "solana"
|
|
720
547
|
? Buffer.from(signedOperation.signature, "hex")
|
|
721
548
|
: Buffer.from(signedOperation.signature);
|
|
722
549
|
},
|
|
@@ -728,10 +555,10 @@ export function useWalletAPIServer({
|
|
|
728
555
|
|
|
729
556
|
server.setHandler(
|
|
730
557
|
"transaction.signRaw",
|
|
731
|
-
async ({
|
|
558
|
+
async ({ account, transaction, broadcast, options }) => {
|
|
732
559
|
const signedOperation = await signRawTransactionLogic(
|
|
733
560
|
{ manifest, accounts, tracking },
|
|
734
|
-
|
|
561
|
+
account.id,
|
|
735
562
|
transaction,
|
|
736
563
|
(account, parentAccount, tx) =>
|
|
737
564
|
new Promise((resolve, reject) => {
|
|
@@ -761,7 +588,7 @@ export function useWalletAPIServer({
|
|
|
761
588
|
if (broadcast) {
|
|
762
589
|
hash = await broadcastTransactionLogic(
|
|
763
590
|
{ manifest, accounts, tracking },
|
|
764
|
-
|
|
591
|
+
account.id,
|
|
765
592
|
signedOperation,
|
|
766
593
|
async (account, parentAccount, signedOperation) => {
|
|
767
594
|
const bridge = getAccountBridge(account, parentAccount);
|
|
@@ -804,12 +631,12 @@ export function useWalletAPIServer({
|
|
|
804
631
|
|
|
805
632
|
server.setHandler(
|
|
806
633
|
"transaction.signAndBroadcast",
|
|
807
|
-
async ({
|
|
634
|
+
async ({ account, tokenCurrency, transaction, options }) => {
|
|
808
635
|
const sponsored = transaction.family === "ethereum" && transaction.sponsored;
|
|
809
636
|
|
|
810
637
|
const signedTransaction = await signTransactionLogic(
|
|
811
638
|
{ manifest, accounts, tracking },
|
|
812
|
-
|
|
639
|
+
account.id,
|
|
813
640
|
transaction,
|
|
814
641
|
(account, parentAccount, signFlowInfos) =>
|
|
815
642
|
new Promise((resolve, reject) => {
|
|
@@ -838,7 +665,7 @@ export function useWalletAPIServer({
|
|
|
838
665
|
|
|
839
666
|
return broadcastTransactionLogic(
|
|
840
667
|
{ manifest, accounts, tracking },
|
|
841
|
-
|
|
668
|
+
account.id,
|
|
842
669
|
signedTransaction,
|
|
843
670
|
async (account, parentAccount, signedOperation) => {
|
|
844
671
|
const bridge = getAccountBridge(account, parentAccount);
|
|
@@ -1102,8 +929,8 @@ export function useWalletAPIServer({
|
|
|
1102
929
|
// retrofit of the exchange params to fit the old platform spec
|
|
1103
930
|
const request: CompleteExchangeRequest = {
|
|
1104
931
|
provider: params.provider,
|
|
1105
|
-
fromAccountId: params.
|
|
1106
|
-
toAccountId: params.exchangeType === "SWAP" ? params.
|
|
932
|
+
fromAccountId: params.fromAccount.id,
|
|
933
|
+
toAccountId: params.exchangeType === "SWAP" ? params.toAccount.id : undefined,
|
|
1107
934
|
transaction: params.transaction,
|
|
1108
935
|
binaryPayload: params.binaryPayload.toString("hex"),
|
|
1109
936
|
signature: params.signature.toString("hex"),
|
|
@@ -1141,7 +968,7 @@ export function useWalletAPIServer({
|
|
|
1141
968
|
}, [uiExchangeComplete, accounts, manifest, server, tracking]);
|
|
1142
969
|
|
|
1143
970
|
return {
|
|
1144
|
-
widgetLoaded
|
|
971
|
+
widgetLoaded,
|
|
1145
972
|
onMessage,
|
|
1146
973
|
onLoad,
|
|
1147
974
|
onReload,
|
|
@@ -1344,9 +1171,9 @@ export function useRecentlyUsed(
|
|
|
1344
1171
|
...res,
|
|
1345
1172
|
usedAt: calculateTimeDiff(recentlyUsed.usedAt),
|
|
1346
1173
|
}
|
|
1347
|
-
:
|
|
1174
|
+
: res;
|
|
1348
1175
|
})
|
|
1349
|
-
.filter(
|
|
1176
|
+
.filter(manifest => manifest !== undefined) as RecentlyUsedManifest[],
|
|
1350
1177
|
[recentlyUsedManifestsDb, manifests],
|
|
1351
1178
|
);
|
|
1352
1179
|
const append = useCallback(
|
|
@@ -241,28 +241,6 @@ export default function trackingWrapper(trackCall: TrackWalletAPI) {
|
|
|
241
241
|
track("WalletAPI bitcoin family account xpub success", getEventData(manifest));
|
|
242
242
|
},
|
|
243
243
|
|
|
244
|
-
// currency.list handler tracking
|
|
245
|
-
currencyListRequested: (manifest: AppManifest) => {
|
|
246
|
-
track("WalletAPI CurrencyList requested", getEventData(manifest));
|
|
247
|
-
},
|
|
248
|
-
currencyListSuccess: (manifest: AppManifest) => {
|
|
249
|
-
track("WalletAPI CurrencyList success", getEventData(manifest));
|
|
250
|
-
},
|
|
251
|
-
currencyListFail: (manifest: AppManifest) => {
|
|
252
|
-
track("WalletAPI CurrencyList fail", getEventData(manifest));
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
// account.list handler tracking
|
|
256
|
-
accountListRequested: (manifest: AppManifest) => {
|
|
257
|
-
track("WalletAPI AccountList requested", getEventData(manifest));
|
|
258
|
-
},
|
|
259
|
-
accountListSuccess: (manifest: AppManifest) => {
|
|
260
|
-
track("WalletAPI AccountList success", getEventData(manifest));
|
|
261
|
-
},
|
|
262
|
-
accountListFail: (manifest: AppManifest) => {
|
|
263
|
-
track("WalletAPI AccountList fail", getEventData(manifest));
|
|
264
|
-
},
|
|
265
|
-
|
|
266
244
|
dappSendTransactionRequested: (manifest: AppManifest, trackingData: DAppTrackingData) => {
|
|
267
245
|
track("dApp SendTransaction requested", { ...getEventData(manifest), ...trackingData });
|
|
268
246
|
},
|
package/src/wallet-api/types.ts
CHANGED
|
@@ -83,8 +83,3 @@ export type DAppTrackingData = {
|
|
|
83
83
|
currency: string;
|
|
84
84
|
network: CryptoCurrency["id"];
|
|
85
85
|
};
|
|
86
|
-
|
|
87
|
-
export type AccountIdFormat = "uuid" | "encoded";
|
|
88
|
-
|
|
89
|
-
/** @developer note uuid = wallet API id format, encoded = ledger wallet default format */
|
|
90
|
-
export type AccountIdFormatsResponse = Record<string, AccountIdFormat>;
|