@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
|
@@ -1,45 +1,78 @@
|
|
|
1
1
|
import { useMemo, useState, useEffect, useRef, useCallback } from "react";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
2
|
import semver from "semver";
|
|
4
3
|
import { intervalToDuration } from "date-fns";
|
|
5
|
-
import { useWalletAPIServer as useWalletAPIServerRaw
|
|
4
|
+
import { useWalletAPIServer as useWalletAPIServerRaw } from "@ledgerhq/wallet-api-server/lib/react";
|
|
5
|
+
import { firstValueFrom } from "rxjs";
|
|
6
6
|
import { first } from "rxjs/operators";
|
|
7
|
-
import {
|
|
8
|
-
import { UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
9
|
-
import { endpoints as calEndpoints } from "@ledgerhq/cryptoassets/cal-client/state-manager/api";
|
|
10
|
-
import { accountToWalletAPIAccount, currencyToWalletAPICurrency, setWalletApiIdForAccountId, } from "./converters";
|
|
7
|
+
import { accountToWalletAPIAccount, currencyToWalletAPICurrency, getAccountIdFromWalletAccountId, } from "./converters";
|
|
11
8
|
import { isWalletAPISupportedCurrency } from "./helpers";
|
|
12
9
|
import { getMainAccount, getParentAccount } from "../account";
|
|
13
|
-
import {
|
|
14
|
-
import { getCryptoAssetsStore } from "../bridge/crypto-assets";
|
|
10
|
+
import { listCurrencies, findCryptoCurrencyById, getCryptoCurrencyById } from "../currencies";
|
|
11
|
+
import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
|
|
15
12
|
import { bitcoinFamilyAccountGetXPubLogic, broadcastTransactionLogic, startExchangeLogic, completeExchangeLogic, receiveOnAccountLogic, signMessageLogic, signTransactionLogic, bitcoinFamilyAccountGetAddressLogic, bitcoinFamilyAccountGetPublicKeyLogic, signRawTransactionLogic, } from "./logic";
|
|
16
13
|
import { getAccountBridge } from "../bridge";
|
|
14
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
17
15
|
import openTransportAsSubject from "../hw/openTransportAsSubject";
|
|
16
|
+
import { UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
18
17
|
import { DISCOVER_INITIAL_CATEGORY, INITIAL_PLATFORM_STATE, MAX_RECENTLY_USED_LENGTH, } from "./constants";
|
|
19
|
-
import { useCurrenciesUnderFeatureFlag } from "../modularDrawer/hooks/useCurrenciesUnderFeatureFlag";
|
|
20
18
|
export function safeGetRefValue(ref) {
|
|
21
19
|
if (!ref.current) {
|
|
22
20
|
throw new Error("Ref objects doesn't have a current value");
|
|
23
21
|
}
|
|
24
22
|
return ref.current;
|
|
25
23
|
}
|
|
26
|
-
export function
|
|
27
|
-
|
|
28
|
-
accounts.
|
|
29
|
-
|
|
24
|
+
export function useWalletAPIAccounts(walletState, accounts) {
|
|
25
|
+
return useMemo(() => {
|
|
26
|
+
return accounts.map(account => {
|
|
27
|
+
const parentAccount = getParentAccount(account, accounts);
|
|
28
|
+
return accountToWalletAPIAccount(walletState, account, parentAccount);
|
|
30
29
|
});
|
|
31
|
-
}, [accounts]);
|
|
30
|
+
}, [walletState, accounts]);
|
|
32
31
|
}
|
|
33
|
-
export function
|
|
32
|
+
export function useWalletAPICurrencies() {
|
|
33
|
+
return useMemo(() => {
|
|
34
|
+
return listCurrencies(true).reduce((filtered, currency) => {
|
|
35
|
+
if (isWalletAPISupportedCurrency(currency)) {
|
|
36
|
+
filtered.push(currencyToWalletAPICurrency(currency));
|
|
37
|
+
}
|
|
38
|
+
return filtered;
|
|
39
|
+
}, []);
|
|
40
|
+
}, []);
|
|
41
|
+
}
|
|
42
|
+
export function useManifestCurrencies(manifest) {
|
|
34
43
|
return useMemo(() => {
|
|
35
44
|
return (manifest.dapp?.networks.map(network => {
|
|
36
|
-
return network.currency;
|
|
45
|
+
return getCryptoCurrencyById(network.currency);
|
|
37
46
|
}) ?? []);
|
|
38
47
|
}, [manifest.dapp?.networks]);
|
|
39
48
|
}
|
|
49
|
+
export function useGetAccountIds(accounts$) {
|
|
50
|
+
const [accounts, setAccounts] = useState([]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!accounts$) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const subscription = accounts$.subscribe(walletAccounts => {
|
|
56
|
+
setAccounts(walletAccounts);
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
subscription.unsubscribe();
|
|
60
|
+
};
|
|
61
|
+
}, [accounts$]);
|
|
62
|
+
return useMemo(() => {
|
|
63
|
+
if (!accounts$) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return accounts.reduce((accountIds, account) => {
|
|
67
|
+
accountIds.set(getAccountIdFromWalletAccountId(account.id), true);
|
|
68
|
+
return accountIds;
|
|
69
|
+
}, new Map());
|
|
70
|
+
}, [accounts, accounts$]);
|
|
71
|
+
}
|
|
40
72
|
export function usePermission(manifest) {
|
|
41
73
|
return useMemo(() => ({
|
|
42
|
-
|
|
74
|
+
currencyIds: manifest.currencies === "*" ? ["**"] : manifest.currencies,
|
|
75
|
+
methodIds: manifest.permissions, // TODO remove when using the correct manifest type
|
|
43
76
|
}), [manifest]);
|
|
44
77
|
}
|
|
45
78
|
function useTransport(postMessage) {
|
|
@@ -57,7 +90,7 @@ export function useConfig({ appId, userId, tracking, wallet, mevProtected, }) {
|
|
|
57
90
|
tracking,
|
|
58
91
|
wallet,
|
|
59
92
|
mevProtected,
|
|
60
|
-
}), [appId,
|
|
93
|
+
}), [appId, tracking, userId, wallet]);
|
|
61
94
|
}
|
|
62
95
|
function useDeviceTransport({ manifest, tracking }) {
|
|
63
96
|
const ref = useRef();
|
|
@@ -107,257 +140,73 @@ function useDeviceTransport({ manifest, tracking }) {
|
|
|
107
140
|
return useMemo(() => ({ ref, subscribe, close, exchange }), [close, exchange, subscribe]);
|
|
108
141
|
}
|
|
109
142
|
export function useWalletAPIServer({ walletState, manifest, accounts, tracking, config, webviewHook, uiHook: { "account.request": uiAccountRequest, "account.receive": uiAccountReceive, "message.sign": uiMessageSign, "storage.get": uiStorageGet, "storage.set": uiStorageSet, "transaction.sign": uiTxSign, "transaction.signRaw": uiTxSignRaw, "transaction.broadcast": uiTxBroadcast, "device.transport": uiDeviceTransport, "device.select": uiDeviceSelect, "exchange.start": uiExchangeStart, "exchange.complete": uiExchangeComplete, }, customHandlers, }) {
|
|
110
|
-
const dispatch = useDispatch();
|
|
111
|
-
const { deactivatedCurrencyIds } = useCurrenciesUnderFeatureFlag();
|
|
112
143
|
const permission = usePermission(manifest);
|
|
113
144
|
const transport = useTransport(webviewHook.postMessage);
|
|
114
145
|
const [widgetLoaded, setWidgetLoaded] = useState(false);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
useSetWalletAPIAccounts(accounts);
|
|
146
|
+
const walletAPIAccounts = useWalletAPIAccounts(walletState, accounts);
|
|
147
|
+
const walletAPICurrencies = useWalletAPICurrencies();
|
|
118
148
|
const { server, onMessage } = useWalletAPIServerRaw({
|
|
119
149
|
transport,
|
|
120
150
|
config,
|
|
151
|
+
accounts: walletAPIAccounts,
|
|
152
|
+
currencies: walletAPICurrencies,
|
|
121
153
|
permission,
|
|
122
154
|
customHandlers,
|
|
123
155
|
});
|
|
124
156
|
useEffect(() => {
|
|
125
157
|
tracking.load(manifest);
|
|
126
158
|
}, [tracking, manifest]);
|
|
127
|
-
// TODO: refactor each handler into its own logic function for clarity
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
server.setHandler("currency.list", async ({ currencyIds }) => {
|
|
130
|
-
tracking.currencyListRequested(manifest);
|
|
131
|
-
try {
|
|
132
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
133
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
134
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
135
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
136
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
137
|
-
if (queryCurrencyIdsSet) {
|
|
138
|
-
// If we have a query filter, narrow down what we need to fetch
|
|
139
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
140
|
-
if (manifestId === "**") {
|
|
141
|
-
// Query can ask for anything, so use the query list
|
|
142
|
-
return [...queryCurrencyIdsSet];
|
|
143
|
-
}
|
|
144
|
-
else if (manifestId.endsWith("/**")) {
|
|
145
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
146
|
-
const family = manifestId.slice(0, -3);
|
|
147
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
148
|
-
}
|
|
149
|
-
else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
150
|
-
// Specific currency/token that's in the query
|
|
151
|
-
return [manifestId];
|
|
152
|
-
}
|
|
153
|
-
// Not in query, skip it
|
|
154
|
-
return [];
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
// 3. Parse effective currency IDs to determine what to fetch
|
|
158
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
159
|
-
const specificCurrencies = new Set();
|
|
160
|
-
const tokenFamilies = new Set();
|
|
161
|
-
const specificTokenIds = new Set();
|
|
162
|
-
for (const id of effectiveCurrencyIds) {
|
|
163
|
-
if (id === "**") {
|
|
164
|
-
// Already handled above
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
else if (id.endsWith("/**")) {
|
|
168
|
-
// Pattern like "ethereum/**" or "solana/**" - include tokens for this family
|
|
169
|
-
const family = id.slice(0, -3);
|
|
170
|
-
tokenFamilies.add(family);
|
|
171
|
-
}
|
|
172
|
-
else if (id.includes("/")) {
|
|
173
|
-
// Specific token ID like "ethereum/erc20/usd__coin"
|
|
174
|
-
specificTokenIds.add(id);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
// Specific currency like "bitcoin" or "ethereum"
|
|
178
|
-
specificCurrencies.add(id);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
// 4. Gather all supported parent currencies
|
|
182
|
-
const allCurrencies = listSupportedCurrencies().reduce((acc, c) => {
|
|
183
|
-
if (isWalletAPISupportedCurrency(c) && !deactivatedCurrencyIds.has(c.id))
|
|
184
|
-
acc.push(currencyToWalletAPICurrency(c));
|
|
185
|
-
return acc;
|
|
186
|
-
}, []);
|
|
187
|
-
// 5. Determine which currencies to include based on patterns
|
|
188
|
-
let includedCurrencies = [];
|
|
189
|
-
if (includeAllCurrencies) {
|
|
190
|
-
includedCurrencies = allCurrencies;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
includedCurrencies = allCurrencies.filter(c => specificCurrencies.has(c.id));
|
|
194
|
-
}
|
|
195
|
-
// 6. Fetch specific tokens by ID if any
|
|
196
|
-
const specificTokens = [];
|
|
197
|
-
if (specificTokenIds.size > 0) {
|
|
198
|
-
const tokenPromises = [...specificTokenIds].map(async (tokenId) => {
|
|
199
|
-
const token = await getCryptoAssetsStore().findTokenById(tokenId);
|
|
200
|
-
return token ? currencyToWalletAPICurrency(token) : null;
|
|
201
|
-
});
|
|
202
|
-
const resolvedTokens = await Promise.all(tokenPromises);
|
|
203
|
-
specificTokens.push(...resolvedTokens.filter((t) => t !== null));
|
|
204
|
-
}
|
|
205
|
-
// 7. Determine which token families to fetch (only if not already fetched as specific tokens)
|
|
206
|
-
const familiesToFetch = new Set();
|
|
207
|
-
if (includeAllCurrencies) {
|
|
208
|
-
// Fetch tokens for all currency families
|
|
209
|
-
allCurrencies.forEach(c => {
|
|
210
|
-
if (c.type === "CryptoCurrency")
|
|
211
|
-
familiesToFetch.add(c.family);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
else if (tokenFamilies.size > 0) {
|
|
215
|
-
// Only fetch tokens for families explicitly marked with /**
|
|
216
|
-
tokenFamilies.forEach(family => familiesToFetch.add(family));
|
|
217
|
-
}
|
|
218
|
-
// 8. Fetch tokens for relevant families
|
|
219
|
-
const fetchAllPagesForFamily = async (family) => {
|
|
220
|
-
const args = { networkFamily: family, pageSize: 1000 };
|
|
221
|
-
let hasNextPage = true;
|
|
222
|
-
let data;
|
|
223
|
-
while (hasNextPage) {
|
|
224
|
-
const querySub = dispatch(calEndpoints.getTokensData.initiate(args, data ? { direction: "forward" } : undefined));
|
|
225
|
-
try {
|
|
226
|
-
const result = await querySub;
|
|
227
|
-
data = result.data;
|
|
228
|
-
hasNextPage = result.hasNextPage;
|
|
229
|
-
if (result.error)
|
|
230
|
-
throw result.error;
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
querySub.unsubscribe();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return (data?.pages ?? []).flatMap(p => p.tokens);
|
|
237
|
-
};
|
|
238
|
-
const tokensByFamily = await Promise.all([...familiesToFetch].map(f => fetchAllPagesForFamily(f)));
|
|
239
|
-
// 9. Combine all results (no additional filter needed since we pre-filtered)
|
|
240
|
-
const result = tokensByFamily.reduce((acc, tokens) => [...acc, ...tokens.map(t => currencyToWalletAPICurrency(t))], [...includedCurrencies, ...specificTokens]);
|
|
241
|
-
tracking.currencyListSuccess(manifest);
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
catch (err) {
|
|
245
|
-
tracking.currencyListFail(manifest);
|
|
246
|
-
throw err;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}, [walletState, manifest, server, tracking, dispatch, deactivatedCurrencyIds]);
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
server.setHandler("account.list", ({ currencyIds }) => {
|
|
252
|
-
tracking.accountListRequested(manifest);
|
|
253
|
-
try {
|
|
254
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
255
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
256
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
257
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
258
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
259
|
-
if (queryCurrencyIdsSet) {
|
|
260
|
-
// If we have a query filter, narrow down what we need to check
|
|
261
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
262
|
-
if (manifestId === "**") {
|
|
263
|
-
// Query can ask for anything, so use the query list
|
|
264
|
-
return [...queryCurrencyIdsSet];
|
|
265
|
-
}
|
|
266
|
-
else if (manifestId.endsWith("/**")) {
|
|
267
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
268
|
-
const family = manifestId.slice(0, -3);
|
|
269
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
270
|
-
}
|
|
271
|
-
else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
272
|
-
// Specific currency/token that's in the query
|
|
273
|
-
return [manifestId];
|
|
274
|
-
}
|
|
275
|
-
// Not in query, skip it
|
|
276
|
-
return [];
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
// 3. Build a set of allowed currency IDs based on effective patterns
|
|
280
|
-
const allowedCurrencyIds = new Set();
|
|
281
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
282
|
-
const tokenFamilyPrefixes = new Set();
|
|
283
|
-
for (const id of effectiveCurrencyIds) {
|
|
284
|
-
if (id === "**") {
|
|
285
|
-
// Will match all currencies
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
else if (id.endsWith("/**")) {
|
|
289
|
-
// Pattern like "ethereum/**" - store prefix for matching
|
|
290
|
-
const family = id.slice(0, -3);
|
|
291
|
-
tokenFamilyPrefixes.add(family);
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
// Specific currency/token ID
|
|
295
|
-
allowedCurrencyIds.add(id);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
// 4. Filter accounts based on effective currency IDs
|
|
299
|
-
const wapiAccounts = accounts.reduce((acc, account) => {
|
|
300
|
-
const parentAccount = getParentAccount(account, accounts);
|
|
301
|
-
const accountCurrencyId = account.type === "TokenAccount" ? account.token.id : account.currency.id;
|
|
302
|
-
const parentCurrencyId = account.type === "TokenAccount" ? account.token.parentCurrency.id : account.currency.id;
|
|
303
|
-
// Check if account currency ID matches the effective patterns
|
|
304
|
-
const isAllowed = includeAllCurrencies ||
|
|
305
|
-
allowedCurrencyIds.has(accountCurrencyId) ||
|
|
306
|
-
tokenFamilyPrefixes.has(parentCurrencyId);
|
|
307
|
-
if (isAllowed) {
|
|
308
|
-
acc.push(accountToWalletAPIAccount(walletState, account, parentAccount));
|
|
309
|
-
}
|
|
310
|
-
return acc;
|
|
311
|
-
}, []);
|
|
312
|
-
tracking.accountListSuccess(manifest);
|
|
313
|
-
return wapiAccounts;
|
|
314
|
-
}
|
|
315
|
-
catch (err) {
|
|
316
|
-
tracking.accountListFail(manifest);
|
|
317
|
-
throw err;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
}, [walletState, manifest, server, tracking, uiAccountRequest, accounts]);
|
|
321
159
|
useEffect(() => {
|
|
322
160
|
if (!uiAccountRequest)
|
|
323
161
|
return;
|
|
324
|
-
server.setHandler("account.request", async ({
|
|
162
|
+
server.setHandler("account.request", async ({ accounts$, currencies$, drawerConfiguration, areCurrenciesFiltered, useCase }) => {
|
|
325
163
|
tracking.requestAccountRequested(manifest);
|
|
164
|
+
const currencies = await firstValueFrom(currencies$);
|
|
326
165
|
return new Promise((resolve, reject) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
166
|
+
(async () => {
|
|
167
|
+
try {
|
|
168
|
+
// handle no curencies selected case
|
|
169
|
+
const currencyList = [];
|
|
170
|
+
for (const { id } of currencies) {
|
|
171
|
+
const currency = findCryptoCurrencyById(id) || (await getCryptoAssetsStore().findTokenById(id));
|
|
172
|
+
if (currency) {
|
|
173
|
+
currencyList.push(currency);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
let done = false;
|
|
177
|
+
uiAccountRequest({
|
|
178
|
+
accounts$,
|
|
179
|
+
currencies: currencyList,
|
|
180
|
+
drawerConfiguration,
|
|
181
|
+
areCurrenciesFiltered,
|
|
182
|
+
useCase,
|
|
183
|
+
onSuccess: (account, parentAccount) => {
|
|
184
|
+
if (done)
|
|
185
|
+
return;
|
|
186
|
+
done = true;
|
|
187
|
+
tracking.requestAccountSuccess(manifest);
|
|
188
|
+
resolve(accountToWalletAPIAccount(walletState, account, parentAccount));
|
|
189
|
+
},
|
|
190
|
+
onCancel: () => {
|
|
191
|
+
if (done)
|
|
192
|
+
return;
|
|
193
|
+
done = true;
|
|
194
|
+
tracking.requestAccountFail(manifest);
|
|
195
|
+
reject(new Error("Canceled by user"));
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
reject(error);
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
354
203
|
});
|
|
355
204
|
});
|
|
356
205
|
}, [walletState, manifest, server, tracking, uiAccountRequest]);
|
|
357
206
|
useEffect(() => {
|
|
358
207
|
if (!uiAccountReceive)
|
|
359
208
|
return;
|
|
360
|
-
server.setHandler("account.receive", ({
|
|
209
|
+
server.setHandler("account.receive", ({ account, tokenCurrency }) => receiveOnAccountLogic(walletState, { manifest, accounts, tracking }, account.id, (account, parentAccount, accountAddress) => new Promise((resolve, reject) => {
|
|
361
210
|
let done = false;
|
|
362
211
|
return uiAccountReceive({
|
|
363
212
|
account,
|
|
@@ -390,7 +239,7 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
390
239
|
useEffect(() => {
|
|
391
240
|
if (!uiMessageSign)
|
|
392
241
|
return;
|
|
393
|
-
server.setHandler("message.sign", ({
|
|
242
|
+
server.setHandler("message.sign", ({ account, message, options }) => signMessageLogic({ manifest, accounts, tracking }, account.id, message.toString("hex"), (account, message) => new Promise((resolve, reject) => {
|
|
394
243
|
let done = false;
|
|
395
244
|
return uiMessageSign({
|
|
396
245
|
account,
|
|
@@ -435,38 +284,31 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
435
284
|
useEffect(() => {
|
|
436
285
|
if (!uiTxSign)
|
|
437
286
|
return;
|
|
438
|
-
server.setHandler("transaction.sign", async ({
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
account
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (done)
|
|
461
|
-
return;
|
|
462
|
-
done = true;
|
|
463
|
-
tracking.signTransactionFail(manifest);
|
|
464
|
-
reject(error);
|
|
465
|
-
},
|
|
466
|
-
});
|
|
287
|
+
server.setHandler("transaction.sign", async ({ account, tokenCurrency, transaction, options }) => {
|
|
288
|
+
const signedOperation = await signTransactionLogic({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, signFlowInfos) => new Promise((resolve, reject) => {
|
|
289
|
+
let done = false;
|
|
290
|
+
return uiTxSign({
|
|
291
|
+
account,
|
|
292
|
+
parentAccount,
|
|
293
|
+
signFlowInfos,
|
|
294
|
+
options,
|
|
295
|
+
onSuccess: signedOperation => {
|
|
296
|
+
if (done)
|
|
297
|
+
return;
|
|
298
|
+
done = true;
|
|
299
|
+
tracking.signTransactionSuccess(manifest);
|
|
300
|
+
resolve(signedOperation);
|
|
301
|
+
},
|
|
302
|
+
onError: error => {
|
|
303
|
+
if (done)
|
|
304
|
+
return;
|
|
305
|
+
done = true;
|
|
306
|
+
tracking.signTransactionFail(manifest);
|
|
307
|
+
reject(error);
|
|
308
|
+
},
|
|
467
309
|
});
|
|
468
|
-
}, tokenCurrency);
|
|
469
|
-
return currency === "solana"
|
|
310
|
+
}), tokenCurrency);
|
|
311
|
+
return account.currency === "solana"
|
|
470
312
|
? Buffer.from(signedOperation.signature, "hex")
|
|
471
313
|
: Buffer.from(signedOperation.signature);
|
|
472
314
|
});
|
|
@@ -474,8 +316,8 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
474
316
|
useEffect(() => {
|
|
475
317
|
if (!uiTxSignRaw)
|
|
476
318
|
return;
|
|
477
|
-
server.setHandler("transaction.signRaw", async ({
|
|
478
|
-
const signedOperation = await signRawTransactionLogic({ manifest, accounts, tracking },
|
|
319
|
+
server.setHandler("transaction.signRaw", async ({ account, transaction, broadcast, options }) => {
|
|
320
|
+
const signedOperation = await signRawTransactionLogic({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, tx) => new Promise((resolve, reject) => {
|
|
479
321
|
let done = false;
|
|
480
322
|
return uiTxSignRaw({
|
|
481
323
|
account,
|
|
@@ -500,7 +342,7 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
500
342
|
}));
|
|
501
343
|
let hash;
|
|
502
344
|
if (broadcast) {
|
|
503
|
-
hash = await broadcastTransactionLogic({ manifest, accounts, tracking },
|
|
345
|
+
hash = await broadcastTransactionLogic({ manifest, accounts, tracking }, account.id, signedOperation, async (account, parentAccount, signedOperation) => {
|
|
504
346
|
const bridge = getAccountBridge(account, parentAccount);
|
|
505
347
|
const mainAccount = getMainAccount(account, parentAccount);
|
|
506
348
|
let optimisticOperation = signedOperation.operation;
|
|
@@ -532,9 +374,9 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
532
374
|
useEffect(() => {
|
|
533
375
|
if (!uiTxSign)
|
|
534
376
|
return;
|
|
535
|
-
server.setHandler("transaction.signAndBroadcast", async ({
|
|
377
|
+
server.setHandler("transaction.signAndBroadcast", async ({ account, tokenCurrency, transaction, options }) => {
|
|
536
378
|
const sponsored = transaction.family === "ethereum" && transaction.sponsored;
|
|
537
|
-
const signedTransaction = await signTransactionLogic({ manifest, accounts, tracking },
|
|
379
|
+
const signedTransaction = await signTransactionLogic({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, signFlowInfos) => new Promise((resolve, reject) => {
|
|
538
380
|
let done = false;
|
|
539
381
|
return uiTxSign({
|
|
540
382
|
account,
|
|
@@ -557,7 +399,7 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
557
399
|
},
|
|
558
400
|
});
|
|
559
401
|
}), tokenCurrency);
|
|
560
|
-
return broadcastTransactionLogic({ manifest, accounts, tracking },
|
|
402
|
+
return broadcastTransactionLogic({ manifest, accounts, tracking }, account.id, signedTransaction, async (account, parentAccount, signedOperation) => {
|
|
561
403
|
const bridge = getAccountBridge(account, parentAccount);
|
|
562
404
|
const mainAccount = getMainAccount(account, parentAccount);
|
|
563
405
|
let optimisticOperation = signedOperation.operation;
|
|
@@ -763,8 +605,8 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
763
605
|
// retrofit of the exchange params to fit the old platform spec
|
|
764
606
|
const request = {
|
|
765
607
|
provider: params.provider,
|
|
766
|
-
fromAccountId: params.
|
|
767
|
-
toAccountId: params.exchangeType === "SWAP" ? params.
|
|
608
|
+
fromAccountId: params.fromAccount.id,
|
|
609
|
+
toAccountId: params.exchangeType === "SWAP" ? params.toAccount.id : undefined,
|
|
768
610
|
transaction: params.transaction,
|
|
769
611
|
binaryPayload: params.binaryPayload.toString("hex"),
|
|
770
612
|
signature: params.signature.toString("hex"),
|
|
@@ -797,7 +639,7 @@ export function useWalletAPIServer({ walletState, manifest, accounts, tracking,
|
|
|
797
639
|
});
|
|
798
640
|
}, [uiExchangeComplete, accounts, manifest, server, tracking]);
|
|
799
641
|
return {
|
|
800
|
-
widgetLoaded
|
|
642
|
+
widgetLoaded,
|
|
801
643
|
onMessage,
|
|
802
644
|
onLoad,
|
|
803
645
|
onReload,
|
|
@@ -917,9 +759,9 @@ export function useRecentlyUsed(manifests, [recentlyUsedManifestsDb, setState])
|
|
|
917
759
|
...res,
|
|
918
760
|
usedAt: calculateTimeDiff(recentlyUsed.usedAt),
|
|
919
761
|
}
|
|
920
|
-
:
|
|
762
|
+
: res;
|
|
921
763
|
})
|
|
922
|
-
.filter(
|
|
764
|
+
.filter(manifest => manifest !== undefined), [recentlyUsedManifestsDb, manifests]);
|
|
923
765
|
const append = useCallback((manifest) => {
|
|
924
766
|
setState(state => {
|
|
925
767
|
const index = state.recentlyUsed.findIndex(({ id }) => id === manifest.id);
|