@ledgerhq/live-common 34.52.0-nightly.2 → 34.52.0-nightly.20251031023756
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/environment.js +2 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/apps/config.js +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +7 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +5 -4
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/dada-client/hooks/useAssetsData.d.ts +4 -10
- package/lib/dada-client/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/dada-client/hooks/useAssetsData.js +2 -1
- package/lib/dada-client/hooks/useAssetsData.js.map +1 -1
- package/lib/dada-client/hooks/useInterestRatesByCurrencies.d.ts +5 -1
- package/lib/dada-client/hooks/useInterestRatesByCurrencies.d.ts.map +1 -1
- package/lib/dada-client/hooks/useMarketByCurrencies.d.ts +4 -1
- package/lib/dada-client/hooks/useMarketByCurrencies.d.ts.map +1 -1
- package/lib/dada-client/state-manager/api.d.ts.map +1 -1
- package/lib/dada-client/state-manager/api.js +3 -0
- package/lib/dada-client/state-manager/api.js.map +1 -1
- package/lib/dada-client/state-manager/types.d.ts +1 -0
- package/lib/dada-client/state-manager/types.d.ts.map +1 -1
- package/lib/deposit/helper.d.ts.map +1 -1
- package/lib/deposit/helper.js +54 -1
- package/lib/deposit/helper.js.map +1 -1
- package/lib/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib/e2e/data/deviceLabelsData.js +38 -33
- package/lib/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib/e2e/deviceInteraction/TouchDeviceSimulator.d.ts.map +1 -1
- package/lib/e2e/deviceInteraction/TouchDeviceSimulator.js +13 -5
- package/lib/e2e/deviceInteraction/TouchDeviceSimulator.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +0 -1
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +0 -1
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +0 -1
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +0 -1
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Device.d.ts +1 -0
- package/lib/e2e/enum/Device.d.ts.map +1 -1
- package/lib/e2e/enum/Device.js +1 -0
- package/lib/e2e/enum/Device.js.map +1 -1
- package/lib/e2e/enum/DeviceLabels.d.ts +2 -0
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +2 -0
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/families/bitcoin.js +1 -1
- package/lib/e2e/families/bitcoin.js.map +1 -1
- package/lib/e2e/families/cardano.d.ts.map +1 -1
- package/lib/e2e/families/cardano.js +12 -11
- package/lib/e2e/families/cardano.js.map +1 -1
- package/lib/e2e/families/evm.d.ts.map +1 -1
- package/lib/e2e/families/evm.js +4 -3
- package/lib/e2e/families/evm.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +1 -1
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/index.d.ts +8 -2
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts +2 -0
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +10 -3
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosAppVersion.d.ts.map +1 -1
- package/lib/e2e/speculosAppVersion.js +5 -2
- package/lib/e2e/speculosAppVersion.js.map +1 -1
- package/lib/e2e/speculosCI.d.ts.map +1 -1
- package/lib/e2e/speculosCI.js +4 -0
- package/lib/e2e/speculosCI.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +3 -0
- package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib/exchange/swap/transactionStrategies.js +12 -2
- package/lib/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib/families/canton/bridge/mock.d.ts +2 -2
- package/lib/families/canton/bridge/mock.d.ts.map +1 -1
- package/lib/families/canton/bridge/mock.js +3 -0
- package/lib/families/canton/bridge/mock.js.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +3 -0
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/canton/setup.d.ts +3 -3
- package/lib/families/canton/setup.d.ts.map +1 -1
- package/lib/families/canton/setup.js.map +1 -1
- package/lib/families/evm/config.d.ts.map +1 -1
- package/lib/families/evm/config.js +18 -1
- package/lib/families/evm/config.js.map +1 -1
- package/lib/families/hedera/utils.d.ts +2 -0
- package/lib/families/hedera/utils.d.ts.map +1 -0
- package/lib/families/hedera/{logic.js → utils.js} +2 -2
- package/lib/families/hedera/utils.js.map +1 -0
- package/lib/families/sui/react.d.ts.map +1 -1
- package/lib/families/sui/react.js +1 -0
- package/lib/families/sui/react.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +3 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +3 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/generated/bridge/js.d.ts +1 -1
- package/lib/generated/bridge/mock.d.ts +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +1 -1
- package/lib/generated/specs.d.ts +1 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/hooks/useDeviceTransactionConfig.d.ts +19 -0
- package/lib/hooks/useDeviceTransactionConfig.d.ts.map +1 -0
- package/lib/hooks/useDeviceTransactionConfig.js +45 -0
- package/lib/hooks/useDeviceTransactionConfig.js.map +1 -0
- package/lib/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib/hw/connectAppEventMapper.js +2 -2
- package/lib/hw/connectAppEventMapper.js.map +1 -1
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +1 -0
- package/lib/load/speculos.js.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +7 -0
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib/postOnboarding/hooks/useAutoDismissPostOnboardingEntryPoint.js.map +1 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +7 -6
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -1
- package/lib/transaction/deviceTransactionConfig.d.ts +1 -1
- package/lib/transaction/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/transaction/deviceTransactionConfig.js +2 -2
- package/lib/transaction/deviceTransactionConfig.js.map +1 -1
- package/lib-es/__tests__/test-helpers/environment.js +2 -0
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/apps/config.js +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +7 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +5 -4
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/dada-client/hooks/useAssetsData.d.ts +4 -10
- package/lib-es/dada-client/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/dada-client/hooks/useAssetsData.js +2 -1
- package/lib-es/dada-client/hooks/useAssetsData.js.map +1 -1
- package/lib-es/dada-client/hooks/useInterestRatesByCurrencies.d.ts +5 -1
- package/lib-es/dada-client/hooks/useInterestRatesByCurrencies.d.ts.map +1 -1
- package/lib-es/dada-client/hooks/useMarketByCurrencies.d.ts +4 -1
- package/lib-es/dada-client/hooks/useMarketByCurrencies.d.ts.map +1 -1
- package/lib-es/dada-client/state-manager/api.d.ts.map +1 -1
- package/lib-es/dada-client/state-manager/api.js +3 -0
- package/lib-es/dada-client/state-manager/api.js.map +1 -1
- package/lib-es/dada-client/state-manager/types.d.ts +1 -0
- package/lib-es/dada-client/state-manager/types.d.ts.map +1 -1
- package/lib-es/deposit/helper.d.ts.map +1 -1
- package/lib-es/deposit/helper.js +54 -1
- package/lib-es/deposit/helper.js.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.js +38 -33
- package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib-es/e2e/deviceInteraction/TouchDeviceSimulator.d.ts.map +1 -1
- package/lib-es/e2e/deviceInteraction/TouchDeviceSimulator.js +13 -5
- package/lib-es/e2e/deviceInteraction/TouchDeviceSimulator.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +0 -1
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +0 -1
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +0 -1
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +0 -1
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Device.d.ts +1 -0
- package/lib-es/e2e/enum/Device.d.ts.map +1 -1
- package/lib-es/e2e/enum/Device.js +1 -0
- package/lib-es/e2e/enum/Device.js.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts +2 -0
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +2 -0
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/families/bitcoin.js +1 -1
- package/lib-es/e2e/families/bitcoin.js.map +1 -1
- package/lib-es/e2e/families/cardano.d.ts.map +1 -1
- package/lib-es/e2e/families/cardano.js +12 -11
- package/lib-es/e2e/families/cardano.js.map +1 -1
- package/lib-es/e2e/families/evm.d.ts.map +1 -1
- package/lib-es/e2e/families/evm.js +4 -3
- package/lib-es/e2e/families/evm.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +1 -1
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/index.d.ts +8 -2
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts +2 -0
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +10 -3
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosAppVersion.d.ts.map +1 -1
- package/lib-es/e2e/speculosAppVersion.js +5 -2
- package/lib-es/e2e/speculosAppVersion.js.map +1 -1
- package/lib-es/e2e/speculosCI.d.ts.map +1 -1
- package/lib-es/e2e/speculosCI.js +4 -0
- package/lib-es/e2e/speculosCI.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts +3 -0
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.js +10 -1
- package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib-es/families/canton/bridge/mock.d.ts +2 -2
- package/lib-es/families/canton/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/canton/bridge/mock.js +3 -0
- package/lib-es/families/canton/bridge/mock.js.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +3 -0
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/canton/setup.d.ts +3 -3
- package/lib-es/families/canton/setup.d.ts.map +1 -1
- package/lib-es/families/canton/setup.js.map +1 -1
- package/lib-es/families/evm/config.d.ts.map +1 -1
- package/lib-es/families/evm/config.js +18 -1
- package/lib-es/families/evm/config.js.map +1 -1
- package/lib-es/families/hedera/utils.d.ts +2 -0
- package/lib-es/families/hedera/utils.d.ts.map +1 -0
- package/lib-es/families/hedera/utils.js +3 -0
- package/lib-es/families/hedera/utils.js.map +1 -0
- package/lib-es/families/sui/react.d.ts.map +1 -1
- package/lib-es/families/sui/react.js +1 -0
- package/lib-es/families/sui/react.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +3 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +3 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +1 -1
- package/lib-es/generated/bridge/mock.d.ts +1 -1
- package/lib-es/generated/deviceTransactionConfig.d.ts +1 -1
- package/lib-es/generated/specs.d.ts +1 -0
- package/lib-es/generated/specs.d.ts.map +1 -1
- package/lib-es/hooks/useDeviceTransactionConfig.d.ts +19 -0
- package/lib-es/hooks/useDeviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/hooks/useDeviceTransactionConfig.js +41 -0
- package/lib-es/hooks/useDeviceTransactionConfig.js.map +1 -0
- package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib-es/hw/connectAppEventMapper.js +3 -3
- package/lib-es/hw/connectAppEventMapper.js.map +1 -1
- package/lib-es/load/speculos.d.ts.map +1 -1
- package/lib-es/load/speculos.js +1 -0
- package/lib-es/load/speculos.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +7 -0
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib-es/postOnboarding/hooks/useAutoDismissPostOnboardingEntryPoint.js.map +1 -1
- package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -1
- package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.js +7 -6
- package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -1
- package/lib-es/transaction/deviceTransactionConfig.d.ts +1 -1
- package/lib-es/transaction/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/transaction/deviceTransactionConfig.js +2 -2
- package/lib-es/transaction/deviceTransactionConfig.js.map +1 -1
- package/package.json +76 -75
- package/src/__tests__/environment.test.ts +8 -5
- package/src/__tests__/migration/account-migration.ts +1 -0
- package/src/__tests__/test-helpers/environment.ts +2 -0
- package/src/account/serialization.test.ts +1 -0
- package/src/apps/config.ts +1 -1
- package/src/bridge/generic-alpaca/getAccountShape.ts +8 -1
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +25 -2
- package/src/bridge/generic-alpaca/utils.test.ts +165 -0
- package/src/bridge/generic-alpaca/utils.ts +5 -4
- package/src/dada-client/hooks/useAssetsData.ts +4 -8
- package/src/dada-client/state-manager/api.ts +3 -0
- package/src/dada-client/state-manager/types.ts +1 -0
- package/src/deposit/helper.ts +65 -1
- package/src/e2e/data/deviceLabelsData.ts +39 -33
- package/src/e2e/deviceInteraction/TouchDeviceSimulator.ts +13 -5
- package/src/e2e/enum/Account.ts +0 -6
- package/src/e2e/enum/Currency.ts +0 -7
- package/src/e2e/enum/Device.ts +1 -0
- package/src/e2e/enum/DeviceLabels.ts +2 -0
- package/src/e2e/families/bitcoin.ts +1 -1
- package/src/e2e/families/cardano.ts +12 -15
- package/src/e2e/families/evm.ts +4 -3
- package/src/e2e/families/solana.ts +1 -4
- package/src/e2e/speculos.ts +20 -3
- package/src/e2e/speculosAppVersion.ts +5 -2
- package/src/e2e/speculosCI.ts +4 -0
- package/src/exchange/swap/getIncompatibleCurrencyKeys.ts +4 -0
- package/src/exchange/swap/transactionStrategies.ts +16 -1
- package/src/families/bitcoin/satstack.test.ts +1 -0
- package/src/families/canton/bridge/mock.ts +10 -7
- package/src/families/canton/config.ts +3 -0
- package/src/families/canton/setup.ts +3 -3
- package/src/families/evm/config.ts +18 -1
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +222 -86
- package/src/families/hedera/utils.ts +2 -0
- package/src/families/sui/react.ts +5 -0
- package/src/featureFlags/defaultFeatures.ts +3 -1
- package/src/hooks/useDeviceTransactionConfig.test.tsx +200 -0
- package/src/hooks/useDeviceTransactionConfig.ts +65 -0
- package/src/hw/connectAppEventMapper.ts +2 -4
- package/src/load/speculos.ts +1 -0
- package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +7 -0
- package/src/postOnboarding/hooks/useAutoDismissPostOnboardingEntryPoint.ts +1 -1
- package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +7 -9
- package/src/transaction/deviceTransactionConfig.ts +3 -3
- package/lib/families/hedera/logic.d.ts +0 -2
- package/lib/families/hedera/logic.d.ts.map +0 -1
- package/lib/families/hedera/logic.js.map +0 -1
- package/lib-es/families/hedera/logic.d.ts +0 -2
- package/lib-es/families/hedera/logic.d.ts.map +0 -1
- package/lib-es/families/hedera/logic.js +0 -3
- package/lib-es/families/hedera/logic.js.map +0 -1
- package/src/dada-client/MIGRATION_GUIDE.md +0 -187
- package/src/families/hedera/logic.ts +0 -2
- package/src/families/sui/__snapshots__/bridge.integration.test.ts.snap +0 -428
|
@@ -110,6 +110,11 @@ export const mapStakingPositions = (
|
|
|
110
110
|
validator,
|
|
111
111
|
stakedSuiId: sp.stakedSuiId,
|
|
112
112
|
formattedAmount: formatCurrencyUnit(unit, BigNumber(sp.principal), formatConfig),
|
|
113
|
+
formattedEstimatedReward: formatCurrencyUnit(
|
|
114
|
+
unit,
|
|
115
|
+
BigNumber(sp.status === "Active" ? sp.estimatedReward : 0),
|
|
116
|
+
formatConfig,
|
|
117
|
+
),
|
|
113
118
|
};
|
|
114
119
|
});
|
|
115
120
|
};
|
|
@@ -97,12 +97,15 @@ export const CURRENCY_DEFAULT_FEATURES = {
|
|
|
97
97
|
currencyBerachain: DEFAULT_FEATURE,
|
|
98
98
|
currencyHyperevm: DEFAULT_FEATURE,
|
|
99
99
|
currencyCantonNetwork: DEFAULT_FEATURE,
|
|
100
|
+
currencyCantonNetworkDevnet: DEFAULT_FEATURE,
|
|
101
|
+
currencyCantonNetworkTestnet: DEFAULT_FEATURE,
|
|
100
102
|
currencyKaspa: DEFAULT_FEATURE,
|
|
101
103
|
currencyEthereumHoodi: DEFAULT_FEATURE,
|
|
102
104
|
currencyCore: DEFAULT_FEATURE,
|
|
103
105
|
currencyWestend: DEFAULT_FEATURE,
|
|
104
106
|
currencyAssetHubPolkadot: DEFAULT_FEATURE,
|
|
105
107
|
currencyAssetHubWestend: DEFAULT_FEATURE,
|
|
108
|
+
currencyMonad: DEFAULT_FEATURE,
|
|
106
109
|
};
|
|
107
110
|
|
|
108
111
|
/**
|
|
@@ -528,7 +531,6 @@ export const DEFAULT_FEATURES: Features = {
|
|
|
528
531
|
},
|
|
529
532
|
enableAppsBackup: DEFAULT_FEATURE,
|
|
530
533
|
web3hub: DEFAULT_FEATURE,
|
|
531
|
-
llmMarketQuickActions: DEFAULT_FEATURE,
|
|
532
534
|
llmMemoTag: DEFAULT_FEATURE,
|
|
533
535
|
lldMemoTag: DEFAULT_FEATURE,
|
|
534
536
|
ldmkTransport: {
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { TextDecoder, TextEncoder } from "util";
|
|
6
|
+
|
|
7
|
+
// Polyfill for TextDecoder/TextEncoder required by Cardano dependencies
|
|
8
|
+
global.TextDecoder = TextDecoder as any;
|
|
9
|
+
global.TextEncoder = TextEncoder as any;
|
|
10
|
+
|
|
11
|
+
// Mock the deviceTransactionConfig module before importing anything else
|
|
12
|
+
jest.mock("../transaction/deviceTransactionConfig", () => ({
|
|
13
|
+
getDeviceTransactionConfig: jest.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
import { renderHook, waitFor } from "@testing-library/react";
|
|
17
|
+
import { useDeviceTransactionConfig } from "./useDeviceTransactionConfig";
|
|
18
|
+
import { getDeviceTransactionConfig } from "../transaction/deviceTransactionConfig";
|
|
19
|
+
import { Account } from "@ledgerhq/types-live";
|
|
20
|
+
import { Transaction, TransactionStatus } from "../generated/types";
|
|
21
|
+
import BigNumber from "bignumber.js";
|
|
22
|
+
import { getCryptoCurrencyById } from "../currencies/index";
|
|
23
|
+
|
|
24
|
+
const mockGetDeviceTransactionConfig = getDeviceTransactionConfig as jest.MockedFunction<
|
|
25
|
+
typeof getDeviceTransactionConfig
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
const btc = getCryptoCurrencyById("bitcoin");
|
|
29
|
+
|
|
30
|
+
describe("useDeviceTransactionConfig", () => {
|
|
31
|
+
const mockAccount: Account = {
|
|
32
|
+
type: "Account",
|
|
33
|
+
id: "test-account-id",
|
|
34
|
+
seedIdentifier: "seed-id",
|
|
35
|
+
derivationMode: "" as const,
|
|
36
|
+
index: 0,
|
|
37
|
+
freshAddress: "test-address",
|
|
38
|
+
freshAddressPath: "44'/0'/0'/0/0",
|
|
39
|
+
used: true,
|
|
40
|
+
balance: new BigNumber(1000000),
|
|
41
|
+
spendableBalance: new BigNumber(1000000),
|
|
42
|
+
creationDate: new Date(),
|
|
43
|
+
blockHeight: 100,
|
|
44
|
+
currency: btc,
|
|
45
|
+
operationsCount: 0,
|
|
46
|
+
operations: [],
|
|
47
|
+
pendingOperations: [],
|
|
48
|
+
lastSyncDate: new Date(),
|
|
49
|
+
balanceHistoryCache: {
|
|
50
|
+
HOUR: { latestDate: null, balances: [] },
|
|
51
|
+
DAY: { latestDate: null, balances: [] },
|
|
52
|
+
WEEK: { latestDate: null, balances: [] },
|
|
53
|
+
},
|
|
54
|
+
swapHistory: [],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const mockTransaction: Transaction = {
|
|
58
|
+
family: "bitcoin" as any,
|
|
59
|
+
amount: new BigNumber(100),
|
|
60
|
+
recipient: "test-recipient",
|
|
61
|
+
useAllAmount: false,
|
|
62
|
+
} as Transaction;
|
|
63
|
+
|
|
64
|
+
const mockStatus: TransactionStatus = {
|
|
65
|
+
errors: {},
|
|
66
|
+
warnings: {},
|
|
67
|
+
estimatedFees: new BigNumber(10),
|
|
68
|
+
amount: new BigNumber(100),
|
|
69
|
+
totalSpent: new BigNumber(110),
|
|
70
|
+
} as TransactionStatus;
|
|
71
|
+
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
jest.clearAllMocks();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should load device transaction config fields successfully", async () => {
|
|
77
|
+
const mockFields = [
|
|
78
|
+
{ type: "amount", label: "Amount" },
|
|
79
|
+
{ type: "fees", label: "Fees" },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
mockGetDeviceTransactionConfig.mockResolvedValue(mockFields as any);
|
|
83
|
+
|
|
84
|
+
const { result } = renderHook(() =>
|
|
85
|
+
useDeviceTransactionConfig({
|
|
86
|
+
account: mockAccount,
|
|
87
|
+
parentAccount: null,
|
|
88
|
+
transaction: mockTransaction,
|
|
89
|
+
status: mockStatus,
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Initially loading
|
|
94
|
+
expect(result.current.loading).toBe(true);
|
|
95
|
+
expect(result.current.fields).toEqual([]);
|
|
96
|
+
|
|
97
|
+
// Wait for async operation
|
|
98
|
+
await waitFor(() => {
|
|
99
|
+
expect(result.current.loading).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(result.current.fields).toEqual(mockFields);
|
|
103
|
+
expect(mockGetDeviceTransactionConfig).toHaveBeenCalledWith({
|
|
104
|
+
account: mockAccount,
|
|
105
|
+
parentAccount: null,
|
|
106
|
+
transaction: mockTransaction,
|
|
107
|
+
status: mockStatus,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should handle errors gracefully", async () => {
|
|
112
|
+
const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation();
|
|
113
|
+
mockGetDeviceTransactionConfig.mockRejectedValue(new Error("Test error"));
|
|
114
|
+
|
|
115
|
+
const { result } = renderHook(() =>
|
|
116
|
+
useDeviceTransactionConfig({
|
|
117
|
+
account: mockAccount,
|
|
118
|
+
parentAccount: null,
|
|
119
|
+
transaction: mockTransaction,
|
|
120
|
+
status: mockStatus,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(result.current.loading).toBe(true);
|
|
125
|
+
|
|
126
|
+
await waitFor(() => {
|
|
127
|
+
expect(result.current.loading).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(result.current.fields).toEqual([]);
|
|
131
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
132
|
+
"Failed to load device transaction config:",
|
|
133
|
+
expect.any(Error),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
consoleErrorSpy.mockRestore();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("should reload fields when dependencies change", async () => {
|
|
140
|
+
const mockFields1 = [{ type: "amount", label: "Amount 1" }];
|
|
141
|
+
const mockFields2 = [{ type: "amount", label: "Amount 2" }];
|
|
142
|
+
|
|
143
|
+
mockGetDeviceTransactionConfig
|
|
144
|
+
.mockResolvedValueOnce(mockFields1 as any)
|
|
145
|
+
.mockResolvedValueOnce(mockFields2 as any);
|
|
146
|
+
|
|
147
|
+
const { result, rerender } = renderHook(
|
|
148
|
+
({ transaction }) =>
|
|
149
|
+
useDeviceTransactionConfig({
|
|
150
|
+
account: mockAccount,
|
|
151
|
+
parentAccount: null,
|
|
152
|
+
transaction,
|
|
153
|
+
status: mockStatus,
|
|
154
|
+
}),
|
|
155
|
+
{
|
|
156
|
+
initialProps: { transaction: mockTransaction },
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
await waitFor(() => {
|
|
161
|
+
expect(result.current.loading).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
expect(result.current.fields).toEqual(mockFields1);
|
|
165
|
+
|
|
166
|
+
// Change transaction
|
|
167
|
+
const newTransaction = {
|
|
168
|
+
...mockTransaction,
|
|
169
|
+
amount: new BigNumber(200),
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
rerender({ transaction: newTransaction });
|
|
173
|
+
|
|
174
|
+
await waitFor(() => {
|
|
175
|
+
expect(result.current.loading).toBe(false);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
expect(result.current.fields).toEqual(mockFields2);
|
|
179
|
+
expect(mockGetDeviceTransactionConfig).toHaveBeenCalledTimes(2);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("should cleanup on unmount", async () => {
|
|
183
|
+
const mockFields = [{ type: "amount", label: "Amount" }];
|
|
184
|
+
mockGetDeviceTransactionConfig.mockResolvedValue(mockFields as any);
|
|
185
|
+
|
|
186
|
+
const { unmount } = renderHook(() =>
|
|
187
|
+
useDeviceTransactionConfig({
|
|
188
|
+
account: mockAccount,
|
|
189
|
+
parentAccount: null,
|
|
190
|
+
transaction: mockTransaction,
|
|
191
|
+
status: mockStatus,
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
unmount();
|
|
196
|
+
|
|
197
|
+
// Should not throw any errors
|
|
198
|
+
expect(mockGetDeviceTransactionConfig).toHaveBeenCalled();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { Account, AccountLike } from "@ledgerhq/types-live";
|
|
3
|
+
import { Transaction, TransactionStatus } from "../generated/types";
|
|
4
|
+
import {
|
|
5
|
+
getDeviceTransactionConfig,
|
|
6
|
+
DeviceTransactionField,
|
|
7
|
+
} from "../transaction/deviceTransactionConfig";
|
|
8
|
+
|
|
9
|
+
type UseDeviceTransactionConfigParams = {
|
|
10
|
+
account: AccountLike;
|
|
11
|
+
parentAccount: Account | null | undefined;
|
|
12
|
+
transaction: Transaction;
|
|
13
|
+
status: TransactionStatus;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hook to fetch device transaction configuration fields asynchronously.
|
|
18
|
+
* This anticipates the future async nature of crypto assets store operations.
|
|
19
|
+
*/
|
|
20
|
+
export function useDeviceTransactionConfig({
|
|
21
|
+
account,
|
|
22
|
+
parentAccount,
|
|
23
|
+
transaction,
|
|
24
|
+
status,
|
|
25
|
+
}: UseDeviceTransactionConfigParams): {
|
|
26
|
+
fields: DeviceTransactionField[];
|
|
27
|
+
loading: boolean;
|
|
28
|
+
} {
|
|
29
|
+
const [fields, setFields] = useState<DeviceTransactionField[]>([]);
|
|
30
|
+
const [loading, setLoading] = useState(true);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
let mounted = true;
|
|
34
|
+
|
|
35
|
+
async function loadFields() {
|
|
36
|
+
try {
|
|
37
|
+
setLoading(true);
|
|
38
|
+
const result = await getDeviceTransactionConfig({
|
|
39
|
+
account,
|
|
40
|
+
parentAccount,
|
|
41
|
+
transaction,
|
|
42
|
+
status,
|
|
43
|
+
});
|
|
44
|
+
if (mounted) {
|
|
45
|
+
setFields(result);
|
|
46
|
+
setLoading(false);
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("Failed to load device transaction config:", error);
|
|
50
|
+
if (mounted) {
|
|
51
|
+
setFields([]);
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
loadFields();
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
mounted = false;
|
|
61
|
+
};
|
|
62
|
+
}, [account, parentAccount, transaction, status]);
|
|
63
|
+
|
|
64
|
+
return { fields, loading };
|
|
65
|
+
}
|
|
@@ -12,11 +12,9 @@ import type {
|
|
|
12
12
|
import {
|
|
13
13
|
DeviceActionStatus,
|
|
14
14
|
DeviceDisconnectedWhileSendingError,
|
|
15
|
-
DeviceLockedError,
|
|
16
15
|
DeviceSessionStateType,
|
|
17
16
|
UserInteractionRequired,
|
|
18
17
|
OutOfMemoryDAError,
|
|
19
|
-
SecureChannelError,
|
|
20
18
|
UnsupportedFirmwareDAError,
|
|
21
19
|
} from "@ledgerhq/device-management-kit";
|
|
22
20
|
import type {
|
|
@@ -254,10 +252,10 @@ export class ConnectAppEventMapper {
|
|
|
254
252
|
deviceState.firmwareUpdateContext!.currentFirmware.version,
|
|
255
253
|
}),
|
|
256
254
|
);
|
|
257
|
-
} else if (error
|
|
255
|
+
} else if ("_tag" in error && error._tag === "DeviceLockedError") {
|
|
258
256
|
this.eventSubject.next({ type: "lockedDevice" });
|
|
259
257
|
this.eventSubject.complete();
|
|
260
|
-
} else if (error
|
|
258
|
+
} else if ("_tag" in error && error._tag === "RefusedByUserDAError") {
|
|
261
259
|
this.eventSubject.error(new UserRefusedAllowManager());
|
|
262
260
|
} else if (error instanceof DeviceDisconnectedWhileSendingError) {
|
|
263
261
|
this.eventSubject.next({ type: "disconnected", expected: false });
|
package/src/load/speculos.ts
CHANGED
|
@@ -70,6 +70,8 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
70
70
|
const berachain = useFeature("currencyBerachain");
|
|
71
71
|
const hyperevm = useFeature("currencyHyperevm");
|
|
72
72
|
const canton = useFeature("currencyCantonNetwork");
|
|
73
|
+
const cantonDevnet = useFeature("currencyCantonNetworkDevnet");
|
|
74
|
+
const cantonTestnet = useFeature("currencyCantonNetworkTestnet");
|
|
73
75
|
const kaspa = useFeature("currencyKaspa");
|
|
74
76
|
const core = useFeature("currencyCore");
|
|
75
77
|
const ethereumHoodi = useFeature("currencyEthereumHoodi");
|
|
@@ -77,6 +79,7 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
77
79
|
const assetHubWestend = useFeature("currencyAssetHubWestend");
|
|
78
80
|
const assetHubPolkadot = useFeature("currencyAssetHubPolkadot");
|
|
79
81
|
const polkadot = useFeature("currencyPolkadot");
|
|
82
|
+
const monad = useFeature("currencyMonad");
|
|
80
83
|
|
|
81
84
|
const featureFlaggedCurrencies = useMemo(
|
|
82
85
|
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
|
|
@@ -143,6 +146,8 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
143
146
|
mina,
|
|
144
147
|
babylon,
|
|
145
148
|
canton_network: canton,
|
|
149
|
+
canton_network_devnet: cantonDevnet,
|
|
150
|
+
canton_network_testnet: cantonTestnet,
|
|
146
151
|
kaspa,
|
|
147
152
|
core,
|
|
148
153
|
ethereum_hoodi: ethereumHoodi,
|
|
@@ -150,6 +155,7 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
150
155
|
assethub_westend: assetHubWestend,
|
|
151
156
|
assethub_polkadot: assetHubPolkadot,
|
|
152
157
|
polkadot,
|
|
158
|
+
monad,
|
|
153
159
|
}),
|
|
154
160
|
[
|
|
155
161
|
aptos,
|
|
@@ -222,6 +228,7 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
222
228
|
assetHubWestend,
|
|
223
229
|
assetHubPolkadot,
|
|
224
230
|
polkadot,
|
|
231
|
+
monad,
|
|
225
232
|
],
|
|
226
233
|
);
|
|
227
234
|
|
|
@@ -6,7 +6,7 @@ import { usePostOnboardingEntryPointVisibleOnWallet } from "./usePostOnboardingE
|
|
|
6
6
|
|
|
7
7
|
const millisecondsInADay = 1000 * 60 * 60 * 24;
|
|
8
8
|
|
|
9
|
-
const isMoreThanSevenDaysAgo = (date: Date) => {
|
|
9
|
+
const isMoreThanSevenDaysAgo = (date: Date | null) => {
|
|
10
10
|
if (!date) return false;
|
|
11
11
|
|
|
12
12
|
const datePlusSevenDays = new Date(date).getTime() + 7 * millisecondsInADay;
|
|
@@ -26,15 +26,13 @@ export function usePostOnboardingHubState(): PostOnboardingHubState {
|
|
|
26
26
|
actionsState: [],
|
|
27
27
|
postOnboardingInProgress: hubState.postOnboardingInProgress,
|
|
28
28
|
};
|
|
29
|
-
const actionsState = hubState.actionsToComplete
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
!actionWithState.featureFlagId || getFeature(actionWithState.featureFlagId)?.enabled,
|
|
37
|
-
);
|
|
29
|
+
const actionsState = hubState.actionsToComplete.flatMap(actionId => {
|
|
30
|
+
const action = getPostOnboardingAction(actionId);
|
|
31
|
+
if (!action || (action.featureFlagId && !getFeature(action.featureFlagId)?.enabled)) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return [{ ...action, completed: !!hubState.actionsCompleted[actionId] }];
|
|
35
|
+
});
|
|
38
36
|
const lastActionCompleted = hubState.lastActionCompleted
|
|
39
37
|
? getPostOnboardingAction(hubState.lastActionCompleted)
|
|
40
38
|
: null;
|
|
@@ -6,14 +6,14 @@ import { getMainAccount } from "../account";
|
|
|
6
6
|
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
7
7
|
|
|
8
8
|
export type DeviceTransactionField = CommonDeviceTransactionField | ExtraDeviceTransactionField;
|
|
9
|
-
export function getDeviceTransactionConfig(arg: {
|
|
9
|
+
export async function getDeviceTransactionConfig(arg: {
|
|
10
10
|
account: AccountLike;
|
|
11
11
|
parentAccount: Account | null | undefined;
|
|
12
12
|
transaction: Transaction;
|
|
13
13
|
status: TransactionStatus;
|
|
14
|
-
}): Array<DeviceTransactionField
|
|
14
|
+
}): Promise<Array<DeviceTransactionField>> {
|
|
15
15
|
const mainAccount = getMainAccount(arg.account, arg.parentAccount);
|
|
16
16
|
const f = perFamily[mainAccount.currency.family];
|
|
17
17
|
if (!f) return [];
|
|
18
|
-
return f(arg);
|
|
18
|
+
return await f(arg);
|
|
19
19
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../src/families/hedera/logic.ts"],"names":[],"mappings":"AACA,cAAc,6BAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../src/families/hedera/logic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,8DAA4C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../src/families/hedera/logic.ts"],"names":[],"mappings":"AACA,cAAc,6BAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../src/families/hedera/logic.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# DaDa Client Migration Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Migrate from `listTokens()` and `listTokensForCryptoCurrency()` to the DaDa Client API.
|
|
6
|
-
|
|
7
|
-
> **Remove CAL Initiative ([LIVE-21487](https://ledgerhq.atlassian.net/browse/LIVE-21487))**: Replace static token lists with dynamic, server-managed asset data. Beware there are many usages of listTokens that actually are going to get dropped or moved to simpler solution than even using DaDa. This guide is for the usecases we still need to list tokens.
|
|
8
|
-
|
|
9
|
-
### useAssetsData
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
const { data, isLoading, isSuccess, isError, loadNext, error, refetch } = useAssetsData({
|
|
13
|
-
product: "lld" | "llm", // app identifier
|
|
14
|
-
version: string, // app version
|
|
15
|
-
search?: string, // server-side search query
|
|
16
|
-
currencyIds?: string[], // filter by parent currencies
|
|
17
|
-
areCurrenciesFiltered?: boolean, // required when using currencyIds
|
|
18
|
-
useCase?: string, // optimize server response
|
|
19
|
-
isStaging?: boolean, // use staging API
|
|
20
|
-
});
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Integration on LLD
|
|
24
|
-
|
|
25
|
-
**Configuration:**
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
product: "lld";
|
|
29
|
-
version: __APP_VERSION__;
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Pagination:** Use `react-window`'s `InfiniteLoader` + `FixedSizeList` with `loadMoreItems` callback, or implement scroll detection to call `loadNext`
|
|
33
|
-
|
|
34
|
-
## Integration on LLM
|
|
35
|
-
|
|
36
|
-
**Configuration:**
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { VersionNumber } from "react-native-version-number";
|
|
40
|
-
|
|
41
|
-
product: "llm";
|
|
42
|
-
version: VersionNumber.appVersion;
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Pagination:** Use `BottomSheetVirtualizedList` or `FlatList` with `onEndReached={loadNext}`
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Migration Examples
|
|
49
|
-
|
|
50
|
-
### 1. Basic Token Lists
|
|
51
|
-
|
|
52
|
-
**Before:**
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
import { listTokens } from "@ledgerhq/cryptoassets";
|
|
56
|
-
|
|
57
|
-
function TokenList() {
|
|
58
|
-
const tokens = listTokens();
|
|
59
|
-
return (
|
|
60
|
-
<div>
|
|
61
|
-
{tokens.map(token => <div key={token.id}>{token.name}</div>)}
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**After:**
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import { useAssetsData } from "@ledgerhq/live-common/dada-client/hooks/useAssetsData";
|
|
71
|
-
|
|
72
|
-
function TokenList() {
|
|
73
|
-
const { data, isLoading, loadNext } = useAssetsData({
|
|
74
|
-
product: "lld",
|
|
75
|
-
version: __APP_VERSION__,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (isLoading) return <div>Loading...</div>;
|
|
79
|
-
|
|
80
|
-
const tokens = Object.values(data?.cryptoOrTokenCurrencies || {})
|
|
81
|
-
.filter(currency => currency.type === "TokenCurrency");
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<SomethingThatManagesInfiniteScrollList
|
|
85
|
-
data={tokens}
|
|
86
|
-
renderItem={(token, index) => (
|
|
87
|
-
<div key={token.id}>{token.name}</div>
|
|
88
|
-
)}
|
|
89
|
-
onScrollEnd={loadNext}
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### 2. Currency-Specific Tokens
|
|
96
|
-
|
|
97
|
-
**Before:**
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets";
|
|
101
|
-
|
|
102
|
-
function EthereumTokens({ currency }) {
|
|
103
|
-
const tokens = listTokensForCryptoCurrency(currency);
|
|
104
|
-
return (
|
|
105
|
-
<select>
|
|
106
|
-
{tokens.map(token => (
|
|
107
|
-
<option key={token.id} value={token.id}>{token.name}</option>
|
|
108
|
-
))}
|
|
109
|
-
</select>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**After:**
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { useAssetsData } from "@ledgerhq/live-common/dada-client/hooks/useAssetsData";
|
|
118
|
-
|
|
119
|
-
function EthereumTokens({ currency }) {
|
|
120
|
-
const { data, isLoading } = useAssetsData({
|
|
121
|
-
currencyIds: [currency.id],
|
|
122
|
-
areCurrenciesFiltered: true,
|
|
123
|
-
product: "lld",
|
|
124
|
-
version: __APP_VERSION__,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
if (isLoading) return <div>Loading...</div>;
|
|
128
|
-
|
|
129
|
-
const tokens = Object.values(data?.cryptoOrTokenCurrencies || {})
|
|
130
|
-
.filter(c => c.type === "TokenCurrency" && c.parentCurrency?.id === currency.id);
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<select>
|
|
134
|
-
{tokens.map(token => (
|
|
135
|
-
<option key={token.id} value={token.id}>{token.name}</option>
|
|
136
|
-
))}
|
|
137
|
-
</select>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### 3. Search
|
|
143
|
-
|
|
144
|
-
**Before:**
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
import { listTokens } from "@ledgerhq/cryptoassets";
|
|
148
|
-
|
|
149
|
-
function SearchableTokens({ searchQuery }) {
|
|
150
|
-
const allTokens = listTokens();
|
|
151
|
-
const filteredTokens = allTokens.filter(token =>
|
|
152
|
-
token.name.toLowerCase().includes(searchQuery.toLowerCase())
|
|
153
|
-
);
|
|
154
|
-
return (
|
|
155
|
-
<div>
|
|
156
|
-
{filteredTokens.map(token => <div key={token.id}>{token.name}</div>)}
|
|
157
|
-
</div>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**After:**
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
import { useAssetsData } from "@ledgerhq/live-common/dada-client/hooks/useAssetsData";
|
|
166
|
-
|
|
167
|
-
function SearchableTokens({ searchQuery }) {
|
|
168
|
-
const { data, isLoading, loadNext } = useAssetsData({
|
|
169
|
-
search: searchQuery,
|
|
170
|
-
product: "lld",
|
|
171
|
-
version: __APP_VERSION__,
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (isLoading) return <div>Loading...</div>;
|
|
175
|
-
|
|
176
|
-
const tokens = Object.values(data?.cryptoOrTokenCurrencies || {})
|
|
177
|
-
.filter(currency => currency.type === "TokenCurrency");
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<SomethingThatManagesInfiniteScrollList
|
|
181
|
-
data={tokens}
|
|
182
|
-
renderItem={(token) => <div key={token.id}>{token.name}</div>}
|
|
183
|
-
onScrollEnd={loadNext}
|
|
184
|
-
/>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
```
|