@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/lib/wallet-api/react.js
CHANGED
|
@@ -3,26 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDisclaimerRaw = exports.useRecentlyUsed = exports.useCacheBustedLiveApps = exports.useLocalLiveApp = exports.useCategories = exports.ExchangeType = exports.useWalletAPIServer = exports.useConfig = exports.usePermission = exports.
|
|
6
|
+
exports.useDisclaimerRaw = exports.useRecentlyUsed = exports.useCacheBustedLiveApps = exports.useLocalLiveApp = exports.useCategories = exports.ExchangeType = exports.useWalletAPIServer = exports.useConfig = exports.usePermission = exports.useGetAccountIds = exports.useManifestCurrencies = exports.useWalletAPICurrencies = exports.useWalletAPIAccounts = exports.safeGetRefValue = void 0;
|
|
7
7
|
const react_1 = require("react");
|
|
8
|
-
const react_redux_1 = require("react-redux");
|
|
9
8
|
const semver_1 = __importDefault(require("semver"));
|
|
10
9
|
const date_fns_1 = require("date-fns");
|
|
11
|
-
const
|
|
10
|
+
const react_2 = require("@ledgerhq/wallet-api-server/lib/react");
|
|
11
|
+
const rxjs_1 = require("rxjs");
|
|
12
12
|
const operators_1 = require("rxjs/operators");
|
|
13
|
-
const live_env_1 = require("@ledgerhq/live-env");
|
|
14
|
-
const errors_1 = require("@ledgerhq/errors");
|
|
15
|
-
const api_1 = require("@ledgerhq/cryptoassets/cal-client/state-manager/api");
|
|
16
13
|
const converters_1 = require("./converters");
|
|
17
14
|
const helpers_1 = require("./helpers");
|
|
18
15
|
const account_1 = require("../account");
|
|
19
16
|
const currencies_1 = require("../currencies");
|
|
20
|
-
const
|
|
17
|
+
const index_1 = require("../bridge/crypto-assets/index");
|
|
21
18
|
const logic_1 = require("./logic");
|
|
22
19
|
const bridge_1 = require("../bridge");
|
|
20
|
+
const live_env_1 = require("@ledgerhq/live-env");
|
|
23
21
|
const openTransportAsSubject_1 = __importDefault(require("../hw/openTransportAsSubject"));
|
|
22
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
24
23
|
const constants_1 = require("./constants");
|
|
25
|
-
const useCurrenciesUnderFeatureFlag_1 = require("../modularDrawer/hooks/useCurrenciesUnderFeatureFlag");
|
|
26
24
|
function safeGetRefValue(ref) {
|
|
27
25
|
if (!ref.current) {
|
|
28
26
|
throw new Error("Ref objects doesn't have a current value");
|
|
@@ -30,25 +28,62 @@ function safeGetRefValue(ref) {
|
|
|
30
28
|
return ref.current;
|
|
31
29
|
}
|
|
32
30
|
exports.safeGetRefValue = safeGetRefValue;
|
|
33
|
-
function
|
|
34
|
-
(0, react_1.
|
|
35
|
-
accounts.
|
|
36
|
-
(0,
|
|
31
|
+
function useWalletAPIAccounts(walletState, accounts) {
|
|
32
|
+
return (0, react_1.useMemo)(() => {
|
|
33
|
+
return accounts.map(account => {
|
|
34
|
+
const parentAccount = (0, account_1.getParentAccount)(account, accounts);
|
|
35
|
+
return (0, converters_1.accountToWalletAPIAccount)(walletState, account, parentAccount);
|
|
37
36
|
});
|
|
38
|
-
}, [accounts]);
|
|
37
|
+
}, [walletState, accounts]);
|
|
39
38
|
}
|
|
40
|
-
exports.
|
|
41
|
-
function
|
|
39
|
+
exports.useWalletAPIAccounts = useWalletAPIAccounts;
|
|
40
|
+
function useWalletAPICurrencies() {
|
|
41
|
+
return (0, react_1.useMemo)(() => {
|
|
42
|
+
return (0, currencies_1.listCurrencies)(true).reduce((filtered, currency) => {
|
|
43
|
+
if ((0, helpers_1.isWalletAPISupportedCurrency)(currency)) {
|
|
44
|
+
filtered.push((0, converters_1.currencyToWalletAPICurrency)(currency));
|
|
45
|
+
}
|
|
46
|
+
return filtered;
|
|
47
|
+
}, []);
|
|
48
|
+
}, []);
|
|
49
|
+
}
|
|
50
|
+
exports.useWalletAPICurrencies = useWalletAPICurrencies;
|
|
51
|
+
function useManifestCurrencies(manifest) {
|
|
42
52
|
return (0, react_1.useMemo)(() => {
|
|
43
53
|
return (manifest.dapp?.networks.map(network => {
|
|
44
|
-
return network.currency;
|
|
54
|
+
return (0, currencies_1.getCryptoCurrencyById)(network.currency);
|
|
45
55
|
}) ?? []);
|
|
46
56
|
}, [manifest.dapp?.networks]);
|
|
47
57
|
}
|
|
48
|
-
exports.
|
|
58
|
+
exports.useManifestCurrencies = useManifestCurrencies;
|
|
59
|
+
function useGetAccountIds(accounts$) {
|
|
60
|
+
const [accounts, setAccounts] = (0, react_1.useState)([]);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
if (!accounts$) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const subscription = accounts$.subscribe(walletAccounts => {
|
|
66
|
+
setAccounts(walletAccounts);
|
|
67
|
+
});
|
|
68
|
+
return () => {
|
|
69
|
+
subscription.unsubscribe();
|
|
70
|
+
};
|
|
71
|
+
}, [accounts$]);
|
|
72
|
+
return (0, react_1.useMemo)(() => {
|
|
73
|
+
if (!accounts$) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return accounts.reduce((accountIds, account) => {
|
|
77
|
+
accountIds.set((0, converters_1.getAccountIdFromWalletAccountId)(account.id), true);
|
|
78
|
+
return accountIds;
|
|
79
|
+
}, new Map());
|
|
80
|
+
}, [accounts, accounts$]);
|
|
81
|
+
}
|
|
82
|
+
exports.useGetAccountIds = useGetAccountIds;
|
|
49
83
|
function usePermission(manifest) {
|
|
50
84
|
return (0, react_1.useMemo)(() => ({
|
|
51
|
-
|
|
85
|
+
currencyIds: manifest.currencies === "*" ? ["**"] : manifest.currencies,
|
|
86
|
+
methodIds: manifest.permissions, // TODO remove when using the correct manifest type
|
|
52
87
|
}), [manifest]);
|
|
53
88
|
}
|
|
54
89
|
exports.usePermission = usePermission;
|
|
@@ -67,7 +102,7 @@ function useConfig({ appId, userId, tracking, wallet, mevProtected, }) {
|
|
|
67
102
|
tracking,
|
|
68
103
|
wallet,
|
|
69
104
|
mevProtected,
|
|
70
|
-
}), [appId,
|
|
105
|
+
}), [appId, tracking, userId, wallet]);
|
|
71
106
|
}
|
|
72
107
|
exports.useConfig = useConfig;
|
|
73
108
|
function useDeviceTransport({ manifest, tracking }) {
|
|
@@ -118,257 +153,73 @@ function useDeviceTransport({ manifest, tracking }) {
|
|
|
118
153
|
return (0, react_1.useMemo)(() => ({ ref, subscribe, close, exchange }), [close, exchange, subscribe]);
|
|
119
154
|
}
|
|
120
155
|
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, }) {
|
|
121
|
-
const dispatch = (0, react_redux_1.useDispatch)();
|
|
122
|
-
const { deactivatedCurrencyIds } = (0, useCurrenciesUnderFeatureFlag_1.useCurrenciesUnderFeatureFlag)();
|
|
123
156
|
const permission = usePermission(manifest);
|
|
124
157
|
const transport = useTransport(webviewHook.postMessage);
|
|
125
158
|
const [widgetLoaded, setWidgetLoaded] = (0, react_1.useState)(false);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const { server, onMessage } = (0, wallet_api_server_1.useWalletAPIServer)({
|
|
159
|
+
const walletAPIAccounts = useWalletAPIAccounts(walletState, accounts);
|
|
160
|
+
const walletAPICurrencies = useWalletAPICurrencies();
|
|
161
|
+
const { server, onMessage } = (0, react_2.useWalletAPIServer)({
|
|
130
162
|
transport,
|
|
131
163
|
config,
|
|
164
|
+
accounts: walletAPIAccounts,
|
|
165
|
+
currencies: walletAPICurrencies,
|
|
132
166
|
permission,
|
|
133
167
|
customHandlers,
|
|
134
168
|
});
|
|
135
169
|
(0, react_1.useEffect)(() => {
|
|
136
170
|
tracking.load(manifest);
|
|
137
171
|
}, [tracking, manifest]);
|
|
138
|
-
// TODO: refactor each handler into its own logic function for clarity
|
|
139
|
-
(0, react_1.useEffect)(() => {
|
|
140
|
-
server.setHandler("currency.list", async ({ currencyIds }) => {
|
|
141
|
-
tracking.currencyListRequested(manifest);
|
|
142
|
-
try {
|
|
143
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
144
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
145
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
146
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
147
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
148
|
-
if (queryCurrencyIdsSet) {
|
|
149
|
-
// If we have a query filter, narrow down what we need to fetch
|
|
150
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
151
|
-
if (manifestId === "**") {
|
|
152
|
-
// Query can ask for anything, so use the query list
|
|
153
|
-
return [...queryCurrencyIdsSet];
|
|
154
|
-
}
|
|
155
|
-
else if (manifestId.endsWith("/**")) {
|
|
156
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
157
|
-
const family = manifestId.slice(0, -3);
|
|
158
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
159
|
-
}
|
|
160
|
-
else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
161
|
-
// Specific currency/token that's in the query
|
|
162
|
-
return [manifestId];
|
|
163
|
-
}
|
|
164
|
-
// Not in query, skip it
|
|
165
|
-
return [];
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
// 3. Parse effective currency IDs to determine what to fetch
|
|
169
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
170
|
-
const specificCurrencies = new Set();
|
|
171
|
-
const tokenFamilies = new Set();
|
|
172
|
-
const specificTokenIds = new Set();
|
|
173
|
-
for (const id of effectiveCurrencyIds) {
|
|
174
|
-
if (id === "**") {
|
|
175
|
-
// Already handled above
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
else if (id.endsWith("/**")) {
|
|
179
|
-
// Pattern like "ethereum/**" or "solana/**" - include tokens for this family
|
|
180
|
-
const family = id.slice(0, -3);
|
|
181
|
-
tokenFamilies.add(family);
|
|
182
|
-
}
|
|
183
|
-
else if (id.includes("/")) {
|
|
184
|
-
// Specific token ID like "ethereum/erc20/usd__coin"
|
|
185
|
-
specificTokenIds.add(id);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
// Specific currency like "bitcoin" or "ethereum"
|
|
189
|
-
specificCurrencies.add(id);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
// 4. Gather all supported parent currencies
|
|
193
|
-
const allCurrencies = (0, currencies_1.listSupportedCurrencies)().reduce((acc, c) => {
|
|
194
|
-
if ((0, helpers_1.isWalletAPISupportedCurrency)(c) && !deactivatedCurrencyIds.has(c.id))
|
|
195
|
-
acc.push((0, converters_1.currencyToWalletAPICurrency)(c));
|
|
196
|
-
return acc;
|
|
197
|
-
}, []);
|
|
198
|
-
// 5. Determine which currencies to include based on patterns
|
|
199
|
-
let includedCurrencies = [];
|
|
200
|
-
if (includeAllCurrencies) {
|
|
201
|
-
includedCurrencies = allCurrencies;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
includedCurrencies = allCurrencies.filter(c => specificCurrencies.has(c.id));
|
|
205
|
-
}
|
|
206
|
-
// 6. Fetch specific tokens by ID if any
|
|
207
|
-
const specificTokens = [];
|
|
208
|
-
if (specificTokenIds.size > 0) {
|
|
209
|
-
const tokenPromises = [...specificTokenIds].map(async (tokenId) => {
|
|
210
|
-
const token = await (0, crypto_assets_1.getCryptoAssetsStore)().findTokenById(tokenId);
|
|
211
|
-
return token ? (0, converters_1.currencyToWalletAPICurrency)(token) : null;
|
|
212
|
-
});
|
|
213
|
-
const resolvedTokens = await Promise.all(tokenPromises);
|
|
214
|
-
specificTokens.push(...resolvedTokens.filter((t) => t !== null));
|
|
215
|
-
}
|
|
216
|
-
// 7. Determine which token families to fetch (only if not already fetched as specific tokens)
|
|
217
|
-
const familiesToFetch = new Set();
|
|
218
|
-
if (includeAllCurrencies) {
|
|
219
|
-
// Fetch tokens for all currency families
|
|
220
|
-
allCurrencies.forEach(c => {
|
|
221
|
-
if (c.type === "CryptoCurrency")
|
|
222
|
-
familiesToFetch.add(c.family);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
else if (tokenFamilies.size > 0) {
|
|
226
|
-
// Only fetch tokens for families explicitly marked with /**
|
|
227
|
-
tokenFamilies.forEach(family => familiesToFetch.add(family));
|
|
228
|
-
}
|
|
229
|
-
// 8. Fetch tokens for relevant families
|
|
230
|
-
const fetchAllPagesForFamily = async (family) => {
|
|
231
|
-
const args = { networkFamily: family, pageSize: 1000 };
|
|
232
|
-
let hasNextPage = true;
|
|
233
|
-
let data;
|
|
234
|
-
while (hasNextPage) {
|
|
235
|
-
const querySub = dispatch(api_1.endpoints.getTokensData.initiate(args, data ? { direction: "forward" } : undefined));
|
|
236
|
-
try {
|
|
237
|
-
const result = await querySub;
|
|
238
|
-
data = result.data;
|
|
239
|
-
hasNextPage = result.hasNextPage;
|
|
240
|
-
if (result.error)
|
|
241
|
-
throw result.error;
|
|
242
|
-
}
|
|
243
|
-
finally {
|
|
244
|
-
querySub.unsubscribe();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return (data?.pages ?? []).flatMap(p => p.tokens);
|
|
248
|
-
};
|
|
249
|
-
const tokensByFamily = await Promise.all([...familiesToFetch].map(f => fetchAllPagesForFamily(f)));
|
|
250
|
-
// 9. Combine all results (no additional filter needed since we pre-filtered)
|
|
251
|
-
const result = tokensByFamily.reduce((acc, tokens) => [...acc, ...tokens.map(t => (0, converters_1.currencyToWalletAPICurrency)(t))], [...includedCurrencies, ...specificTokens]);
|
|
252
|
-
tracking.currencyListSuccess(manifest);
|
|
253
|
-
return result;
|
|
254
|
-
}
|
|
255
|
-
catch (err) {
|
|
256
|
-
tracking.currencyListFail(manifest);
|
|
257
|
-
throw err;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}, [walletState, manifest, server, tracking, dispatch, deactivatedCurrencyIds]);
|
|
261
|
-
(0, react_1.useEffect)(() => {
|
|
262
|
-
server.setHandler("account.list", ({ currencyIds }) => {
|
|
263
|
-
tracking.accountListRequested(manifest);
|
|
264
|
-
try {
|
|
265
|
-
// 1. Parse manifest currency patterns to determine what to include
|
|
266
|
-
const manifestCurrencyIds = manifest.currencies === "*" ? ["**"] : manifest.currencies;
|
|
267
|
-
// 2. Apply query filter early - intersect with manifest patterns
|
|
268
|
-
const queryCurrencyIdsSet = currencyIds ? new Set(currencyIds) : undefined;
|
|
269
|
-
let effectiveCurrencyIds = manifestCurrencyIds;
|
|
270
|
-
if (queryCurrencyIdsSet) {
|
|
271
|
-
// If we have a query filter, narrow down what we need to check
|
|
272
|
-
effectiveCurrencyIds = manifestCurrencyIds.flatMap(manifestId => {
|
|
273
|
-
if (manifestId === "**") {
|
|
274
|
-
// Query can ask for anything, so use the query list
|
|
275
|
-
return [...queryCurrencyIdsSet];
|
|
276
|
-
}
|
|
277
|
-
else if (manifestId.endsWith("/**")) {
|
|
278
|
-
// Pattern like "ethereum/**" - keep tokens from query that match this family
|
|
279
|
-
const family = manifestId.slice(0, -3);
|
|
280
|
-
return [...queryCurrencyIdsSet].filter(qId => qId.startsWith(`${family}/`));
|
|
281
|
-
}
|
|
282
|
-
else if (queryCurrencyIdsSet.has(manifestId)) {
|
|
283
|
-
// Specific currency/token that's in the query
|
|
284
|
-
return [manifestId];
|
|
285
|
-
}
|
|
286
|
-
// Not in query, skip it
|
|
287
|
-
return [];
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
// 3. Build a set of allowed currency IDs based on effective patterns
|
|
291
|
-
const allowedCurrencyIds = new Set();
|
|
292
|
-
const includeAllCurrencies = effectiveCurrencyIds.includes("**");
|
|
293
|
-
const tokenFamilyPrefixes = new Set();
|
|
294
|
-
for (const id of effectiveCurrencyIds) {
|
|
295
|
-
if (id === "**") {
|
|
296
|
-
// Will match all currencies
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
else if (id.endsWith("/**")) {
|
|
300
|
-
// Pattern like "ethereum/**" - store prefix for matching
|
|
301
|
-
const family = id.slice(0, -3);
|
|
302
|
-
tokenFamilyPrefixes.add(family);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
// Specific currency/token ID
|
|
306
|
-
allowedCurrencyIds.add(id);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// 4. Filter accounts based on effective currency IDs
|
|
310
|
-
const wapiAccounts = accounts.reduce((acc, account) => {
|
|
311
|
-
const parentAccount = (0, account_1.getParentAccount)(account, accounts);
|
|
312
|
-
const accountCurrencyId = account.type === "TokenAccount" ? account.token.id : account.currency.id;
|
|
313
|
-
const parentCurrencyId = account.type === "TokenAccount" ? account.token.parentCurrency.id : account.currency.id;
|
|
314
|
-
// Check if account currency ID matches the effective patterns
|
|
315
|
-
const isAllowed = includeAllCurrencies ||
|
|
316
|
-
allowedCurrencyIds.has(accountCurrencyId) ||
|
|
317
|
-
tokenFamilyPrefixes.has(parentCurrencyId);
|
|
318
|
-
if (isAllowed) {
|
|
319
|
-
acc.push((0, converters_1.accountToWalletAPIAccount)(walletState, account, parentAccount));
|
|
320
|
-
}
|
|
321
|
-
return acc;
|
|
322
|
-
}, []);
|
|
323
|
-
tracking.accountListSuccess(manifest);
|
|
324
|
-
return wapiAccounts;
|
|
325
|
-
}
|
|
326
|
-
catch (err) {
|
|
327
|
-
tracking.accountListFail(manifest);
|
|
328
|
-
throw err;
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
}, [walletState, manifest, server, tracking, uiAccountRequest, accounts]);
|
|
332
172
|
(0, react_1.useEffect)(() => {
|
|
333
173
|
if (!uiAccountRequest)
|
|
334
174
|
return;
|
|
335
|
-
server.setHandler("account.request", async ({
|
|
175
|
+
server.setHandler("account.request", async ({ accounts$, currencies$, drawerConfiguration, areCurrenciesFiltered, useCase }) => {
|
|
336
176
|
tracking.requestAccountRequested(manifest);
|
|
177
|
+
const currencies = await (0, rxjs_1.firstValueFrom)(currencies$);
|
|
337
178
|
return new Promise((resolve, reject) => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
179
|
+
(async () => {
|
|
180
|
+
try {
|
|
181
|
+
// handle no curencies selected case
|
|
182
|
+
const currencyList = [];
|
|
183
|
+
for (const { id } of currencies) {
|
|
184
|
+
const currency = (0, currencies_1.findCryptoCurrencyById)(id) || (await (0, index_1.getCryptoAssetsStore)().findTokenById(id));
|
|
185
|
+
if (currency) {
|
|
186
|
+
currencyList.push(currency);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
let done = false;
|
|
190
|
+
uiAccountRequest({
|
|
191
|
+
accounts$,
|
|
192
|
+
currencies: currencyList,
|
|
193
|
+
drawerConfiguration,
|
|
194
|
+
areCurrenciesFiltered,
|
|
195
|
+
useCase,
|
|
196
|
+
onSuccess: (account, parentAccount) => {
|
|
197
|
+
if (done)
|
|
198
|
+
return;
|
|
199
|
+
done = true;
|
|
200
|
+
tracking.requestAccountSuccess(manifest);
|
|
201
|
+
resolve((0, converters_1.accountToWalletAPIAccount)(walletState, account, parentAccount));
|
|
202
|
+
},
|
|
203
|
+
onCancel: () => {
|
|
204
|
+
if (done)
|
|
205
|
+
return;
|
|
206
|
+
done = true;
|
|
207
|
+
tracking.requestAccountFail(manifest);
|
|
208
|
+
reject(new Error("Canceled by user"));
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
reject(error);
|
|
214
|
+
}
|
|
215
|
+
})();
|
|
365
216
|
});
|
|
366
217
|
});
|
|
367
218
|
}, [walletState, manifest, server, tracking, uiAccountRequest]);
|
|
368
219
|
(0, react_1.useEffect)(() => {
|
|
369
220
|
if (!uiAccountReceive)
|
|
370
221
|
return;
|
|
371
|
-
server.setHandler("account.receive", ({
|
|
222
|
+
server.setHandler("account.receive", ({ account, tokenCurrency }) => (0, logic_1.receiveOnAccountLogic)(walletState, { manifest, accounts, tracking }, account.id, (account, parentAccount, accountAddress) => new Promise((resolve, reject) => {
|
|
372
223
|
let done = false;
|
|
373
224
|
return uiAccountReceive({
|
|
374
225
|
account,
|
|
@@ -401,7 +252,7 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
401
252
|
(0, react_1.useEffect)(() => {
|
|
402
253
|
if (!uiMessageSign)
|
|
403
254
|
return;
|
|
404
|
-
server.setHandler("message.sign", ({
|
|
255
|
+
server.setHandler("message.sign", ({ account, message, options }) => (0, logic_1.signMessageLogic)({ manifest, accounts, tracking }, account.id, message.toString("hex"), (account, message) => new Promise((resolve, reject) => {
|
|
405
256
|
let done = false;
|
|
406
257
|
return uiMessageSign({
|
|
407
258
|
account,
|
|
@@ -446,38 +297,31 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
446
297
|
(0, react_1.useEffect)(() => {
|
|
447
298
|
if (!uiTxSign)
|
|
448
299
|
return;
|
|
449
|
-
server.setHandler("transaction.sign", async ({
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
account
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (done)
|
|
472
|
-
return;
|
|
473
|
-
done = true;
|
|
474
|
-
tracking.signTransactionFail(manifest);
|
|
475
|
-
reject(error);
|
|
476
|
-
},
|
|
477
|
-
});
|
|
300
|
+
server.setHandler("transaction.sign", async ({ account, tokenCurrency, transaction, options }) => {
|
|
301
|
+
const signedOperation = await (0, logic_1.signTransactionLogic)({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, signFlowInfos) => new Promise((resolve, reject) => {
|
|
302
|
+
let done = false;
|
|
303
|
+
return uiTxSign({
|
|
304
|
+
account,
|
|
305
|
+
parentAccount,
|
|
306
|
+
signFlowInfos,
|
|
307
|
+
options,
|
|
308
|
+
onSuccess: signedOperation => {
|
|
309
|
+
if (done)
|
|
310
|
+
return;
|
|
311
|
+
done = true;
|
|
312
|
+
tracking.signTransactionSuccess(manifest);
|
|
313
|
+
resolve(signedOperation);
|
|
314
|
+
},
|
|
315
|
+
onError: error => {
|
|
316
|
+
if (done)
|
|
317
|
+
return;
|
|
318
|
+
done = true;
|
|
319
|
+
tracking.signTransactionFail(manifest);
|
|
320
|
+
reject(error);
|
|
321
|
+
},
|
|
478
322
|
});
|
|
479
|
-
}, tokenCurrency);
|
|
480
|
-
return currency === "solana"
|
|
323
|
+
}), tokenCurrency);
|
|
324
|
+
return account.currency === "solana"
|
|
481
325
|
? Buffer.from(signedOperation.signature, "hex")
|
|
482
326
|
: Buffer.from(signedOperation.signature);
|
|
483
327
|
});
|
|
@@ -485,8 +329,8 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
485
329
|
(0, react_1.useEffect)(() => {
|
|
486
330
|
if (!uiTxSignRaw)
|
|
487
331
|
return;
|
|
488
|
-
server.setHandler("transaction.signRaw", async ({
|
|
489
|
-
const signedOperation = await (0, logic_1.signRawTransactionLogic)({ manifest, accounts, tracking },
|
|
332
|
+
server.setHandler("transaction.signRaw", async ({ account, transaction, broadcast, options }) => {
|
|
333
|
+
const signedOperation = await (0, logic_1.signRawTransactionLogic)({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, tx) => new Promise((resolve, reject) => {
|
|
490
334
|
let done = false;
|
|
491
335
|
return uiTxSignRaw({
|
|
492
336
|
account,
|
|
@@ -511,7 +355,7 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
511
355
|
}));
|
|
512
356
|
let hash;
|
|
513
357
|
if (broadcast) {
|
|
514
|
-
hash = await (0, logic_1.broadcastTransactionLogic)({ manifest, accounts, tracking },
|
|
358
|
+
hash = await (0, logic_1.broadcastTransactionLogic)({ manifest, accounts, tracking }, account.id, signedOperation, async (account, parentAccount, signedOperation) => {
|
|
515
359
|
const bridge = (0, bridge_1.getAccountBridge)(account, parentAccount);
|
|
516
360
|
const mainAccount = (0, account_1.getMainAccount)(account, parentAccount);
|
|
517
361
|
let optimisticOperation = signedOperation.operation;
|
|
@@ -543,9 +387,9 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
543
387
|
(0, react_1.useEffect)(() => {
|
|
544
388
|
if (!uiTxSign)
|
|
545
389
|
return;
|
|
546
|
-
server.setHandler("transaction.signAndBroadcast", async ({
|
|
390
|
+
server.setHandler("transaction.signAndBroadcast", async ({ account, tokenCurrency, transaction, options }) => {
|
|
547
391
|
const sponsored = transaction.family === "ethereum" && transaction.sponsored;
|
|
548
|
-
const signedTransaction = await (0, logic_1.signTransactionLogic)({ manifest, accounts, tracking },
|
|
392
|
+
const signedTransaction = await (0, logic_1.signTransactionLogic)({ manifest, accounts, tracking }, account.id, transaction, (account, parentAccount, signFlowInfos) => new Promise((resolve, reject) => {
|
|
549
393
|
let done = false;
|
|
550
394
|
return uiTxSign({
|
|
551
395
|
account,
|
|
@@ -568,7 +412,7 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
568
412
|
},
|
|
569
413
|
});
|
|
570
414
|
}), tokenCurrency);
|
|
571
|
-
return (0, logic_1.broadcastTransactionLogic)({ manifest, accounts, tracking },
|
|
415
|
+
return (0, logic_1.broadcastTransactionLogic)({ manifest, accounts, tracking }, account.id, signedTransaction, async (account, parentAccount, signedOperation) => {
|
|
572
416
|
const bridge = (0, bridge_1.getAccountBridge)(account, parentAccount);
|
|
573
417
|
const mainAccount = (0, account_1.getMainAccount)(account, parentAccount);
|
|
574
418
|
let optimisticOperation = signedOperation.operation;
|
|
@@ -774,8 +618,8 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
774
618
|
// retrofit of the exchange params to fit the old platform spec
|
|
775
619
|
const request = {
|
|
776
620
|
provider: params.provider,
|
|
777
|
-
fromAccountId: params.
|
|
778
|
-
toAccountId: params.exchangeType === "SWAP" ? params.
|
|
621
|
+
fromAccountId: params.fromAccount.id,
|
|
622
|
+
toAccountId: params.exchangeType === "SWAP" ? params.toAccount.id : undefined,
|
|
779
623
|
transaction: params.transaction,
|
|
780
624
|
binaryPayload: params.binaryPayload.toString("hex"),
|
|
781
625
|
signature: params.signature.toString("hex"),
|
|
@@ -808,7 +652,7 @@ function useWalletAPIServer({ walletState, manifest, accounts, tracking, config,
|
|
|
808
652
|
});
|
|
809
653
|
}, [uiExchangeComplete, accounts, manifest, server, tracking]);
|
|
810
654
|
return {
|
|
811
|
-
widgetLoaded
|
|
655
|
+
widgetLoaded,
|
|
812
656
|
onMessage,
|
|
813
657
|
onLoad,
|
|
814
658
|
onReload,
|
|
@@ -932,9 +776,9 @@ function useRecentlyUsed(manifests, [recentlyUsedManifestsDb, setState]) {
|
|
|
932
776
|
...res,
|
|
933
777
|
usedAt: calculateTimeDiff(recentlyUsed.usedAt),
|
|
934
778
|
}
|
|
935
|
-
:
|
|
779
|
+
: res;
|
|
936
780
|
})
|
|
937
|
-
.filter(
|
|
781
|
+
.filter(manifest => manifest !== undefined), [recentlyUsedManifestsDb, manifests]);
|
|
938
782
|
const append = (0, react_1.useCallback)((manifest) => {
|
|
939
783
|
setState(state => {
|
|
940
784
|
const index = state.recentlyUsed.findIndex(({ id }) => id === manifest.id);
|