@ledgerhq/live-common 34.47.0 → 34.48.0-nightly.1
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/bridge/crypto-assets/cal-integration.d.ts +4 -0
- package/lib/bridge/crypto-assets/cal-integration.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.js +26 -0
- package/lib/bridge/crypto-assets/cal-integration.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts +2 -0
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.test.js +45 -0
- package/lib/bridge/crypto-assets/cal-integration.test.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.d.ts +14 -0
- package/lib/bridge/crypto-assets/cal-store.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.js +58 -0
- package/lib/bridge/crypto-assets/cal-store.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.test.d.ts +2 -0
- package/lib/bridge/crypto-assets/cal-store.test.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.test.js +70 -0
- package/lib/bridge/crypto-assets/cal-store.test.js.map +1 -0
- package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +4 -0
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +36 -0
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js +6 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js +89 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +2 -3
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.js +4 -14
- package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +4 -4
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +0 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +14 -3
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +21 -5
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +6 -5
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/utils.test.js +123 -0
- package/lib/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib/e2e/enum/DeviceLabels.d.ts +9 -6
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +8 -5
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/families/tezos.d.ts.map +1 -1
- package/lib/e2e/families/tezos.js +2 -0
- package/lib/e2e/families/tezos.js.map +1 -1
- package/lib/e2e/index.d.ts +7 -6
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts +2 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +25 -17
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.js +3 -5
- package/lib/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +5 -2
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib/exchange/swap/initSwap.js +5 -2
- package/lib/exchange/swap/initSwap.js.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +4 -0
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/solana/setup.d.ts.map +1 -1
- package/lib/families/solana/setup.js +9 -0
- package/lib/families/solana/setup.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -2
- 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/modularDrawer/__mocks__/dada.mock.d.ts +3336 -0
- package/lib/modularDrawer/__mocks__/dada.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/dada.mock.js +3879 -0
- package/lib/modularDrawer/__mocks__/dada.mock.js.map +1 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts +16 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts.map +1 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.js +21 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.js.map +1 -0
- package/lib/modularDrawer/data/state-manager/api.d.ts +727 -37
- package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib/modularDrawer/data/state-manager/api.js +38 -17
- package/lib/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib/modularDrawer/data/state-manager/types.d.ts +24 -0
- package/lib/modularDrawer/data/state-manager/types.d.ts.map +1 -0
- package/lib/modularDrawer/data/state-manager/types.js +13 -0
- package/lib/modularDrawer/data/state-manager/types.js.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +134 -78
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +206 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +43 -10
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useAssetsData.d.ts +10 -6
- package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.js +40 -17
- package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts +3 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.js +23 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js +15 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts +4 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js +30 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js +29 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +87 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +66 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js +41 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js +54 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js +36 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js +17 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.d.ts +13 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.js +20 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.js.map +1 -0
- package/lib/modularDrawer/utils/getLoadingStatus.d.ts +9 -0
- package/lib/modularDrawer/utils/getLoadingStatus.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getLoadingStatus.js +18 -0
- package/lib/modularDrawer/utils/getLoadingStatus.js.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.js +32 -0
- package/lib/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +90 -1
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +2 -2
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/ModularDrawer/types.d.ts +6 -6
- package/lib/wallet-api/ModularDrawer/types.d.ts.map +1 -1
- package/lib/wallet-api/ModularDrawer/types.js +1 -1
- package/lib/wallet-api/ModularDrawer/types.js.map +1 -1
- package/lib/wallet-api/react.d.ts +2 -0
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +3 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts +4 -0
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.js +21 -0
- package/lib-es/bridge/crypto-assets/cal-integration.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts +2 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.js +43 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.d.ts +14 -0
- package/lib-es/bridge/crypto-assets/cal-store.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.js +54 -0
- package/lib-es/bridge/crypto-assets/cal-store.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts +2 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.js +68 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.js.map +1 -0
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +4 -0
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +36 -0
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js +6 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js +64 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +2 -3
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +4 -12
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +3 -3
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +0 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +14 -3
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +21 -5
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +6 -5
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js +118 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib-es/e2e/enum/DeviceLabels.d.ts +9 -6
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +8 -5
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/families/tezos.d.ts.map +1 -1
- package/lib-es/e2e/families/tezos.js +2 -0
- package/lib-es/e2e/families/tezos.js.map +1 -1
- package/lib-es/e2e/index.d.ts +7 -6
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts +2 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +23 -16
- package/lib-es/e2e/speculos.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/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/platform/transfer/completeExchange.js +3 -2
- package/lib-es/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/swap/completeExchange.js +5 -2
- package/lib-es/exchange/swap/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib-es/exchange/swap/initSwap.js +5 -2
- package/lib-es/exchange/swap/initSwap.js.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +4 -0
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/solana/setup.d.ts.map +1 -1
- package/lib-es/families/solana/setup.js +9 -0
- package/lib-es/families/solana/setup.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -2
- 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/modularDrawer/__mocks__/dada.mock.d.ts +3336 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.js +3876 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.js.map +1 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts +16 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.js +18 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.js.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/api.d.ts +727 -37
- package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/api.js +35 -14
- package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/types.d.ts +24 -0
- package/lib-es/modularDrawer/data/state-manager/types.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/types.js +10 -0
- package/lib-es/modularDrawer/data/state-manager/types.js.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +135 -79
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +204 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +21 -8
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +10 -6
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.js +42 -19
- package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts +3 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.js +19 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js +11 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts +4 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js +26 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js +25 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +83 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +62 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js +39 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +48 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js +34 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js +13 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.d.ts +13 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.js +16 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.js.map +1 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts +9 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.js +14 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.js.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js +25 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +90 -1
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +2 -2
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.d.ts +6 -6
- package/lib-es/wallet-api/ModularDrawer/types.d.ts.map +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.js +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts +2 -0
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +3 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/package.json +51 -51
- package/src/bridge/crypto-assets/cal-integration.test.ts +53 -0
- package/src/bridge/crypto-assets/cal-integration.ts +23 -0
- package/src/bridge/crypto-assets/cal-store.test.ts +93 -0
- package/src/bridge/crypto-assets/cal-store.ts +63 -0
- package/src/bridge/crypto-assets/index.test.ts +47 -0
- package/src/bridge/crypto-assets/index.ts +5 -0
- package/src/bridge/generic-alpaca/alpaca/index.ts +14 -1
- package/src/bridge/generic-alpaca/alpaca/index.unit.test.ts +78 -0
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +5 -4
- package/src/bridge/generic-alpaca/buildSubAccounts.ts +5 -14
- package/src/bridge/generic-alpaca/getAccountShape.ts +3 -4
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +0 -1
- package/src/bridge/generic-alpaca/prepareTransaction.ts +44 -17
- package/src/bridge/generic-alpaca/signOperation.ts +1 -1
- package/src/bridge/generic-alpaca/utils.test.ts +133 -0
- package/src/bridge/generic-alpaca/utils.ts +7 -5
- package/src/e2e/enum/DeviceLabels.ts +8 -5
- package/src/e2e/families/tezos.ts +2 -0
- package/src/e2e/speculos.ts +24 -17
- package/src/exchange/platform/transfer/completeExchange.ts +3 -2
- package/src/exchange/swap/completeExchange.ts +5 -2
- package/src/exchange/swap/initSwap.ts +5 -4
- package/src/families/canton/config.ts +5 -0
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +27 -7
- package/src/families/solana/setup.ts +9 -0
- package/src/featureFlags/defaultFeatures.ts +1 -2
- package/src/modularDrawer/__mocks__/dada.mock.ts +3890 -0
- package/src/modularDrawer/data/entities/interestRateSelectors.ts +39 -0
- package/src/modularDrawer/data/state-manager/api.ts +42 -27
- package/src/modularDrawer/data/state-manager/types.ts +28 -0
- package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +141 -80
- package/src/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.ts +251 -0
- package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +27 -9
- package/src/modularDrawer/hooks/{modules/useAssetAccountCounts.tsx → useAssetAccountCounts.tsx} +2 -2
- package/src/modularDrawer/hooks/useAssetsData.ts +59 -22
- package/src/modularDrawer/hooks/useInterestRatesByCurrencies.ts +23 -0
- package/src/modularDrawer/hooks/useLeftAccounts.tsx +23 -0
- package/src/modularDrawer/hooks/useLeftAccountsApy.tsx +44 -0
- package/src/modularDrawer/hooks/useModularDrawerConfiguration.ts +33 -0
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +140 -0
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +116 -0
- package/src/modularDrawer/modules/createAssetConfiguration.ts +62 -0
- package/src/modularDrawer/modules/createNetworkConfiguration.ts +87 -0
- package/src/modularDrawer/utils/__tests__/getInterestRateForAsset.test.ts +58 -0
- package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +25 -0
- package/src/modularDrawer/utils/getInterestRateForAsset.ts +32 -0
- package/src/modularDrawer/utils/getLoadingStatus.ts +24 -0
- package/src/modularDrawer/utils/sortByBalance.tsx +32 -0
- package/src/modularDrawer/utils/type.ts +98 -0
- package/src/wallet-api/Exchange/server.ts +2 -2
- package/src/wallet-api/ModularDrawer/types.ts +1 -1
- package/src/wallet-api/react.ts +5 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.js +0 -20
- package/lib/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib/modularDrawer/types.d.ts +0 -2
- package/lib/modularDrawer/types.d.ts.map +0 -1
- package/lib/modularDrawer/types.js +0 -3
- package/lib/modularDrawer/types.js.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js +0 -18
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib-es/modularDrawer/types.d.ts +0 -2
- package/lib-es/modularDrawer/types.d.ts.map +0 -1
- package/lib-es/modularDrawer/types.js +0 -2
- package/lib-es/modularDrawer/types.js.map +0 -1
- package/src/bridge/generic-alpaca/tests/utils.test.ts +0 -19
- package/src/modularDrawer/types.ts +0 -1
- /package/lib/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
- /package/lib-es/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
@@ -1,6 +1,8 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useMemo } from "react";
|
2
2
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
-
import { ApyType } from "../../
|
3
|
+
import { ApyType } from "../../utils/type";
|
4
|
+
import { useInterestRatesByCurrencies } from "../useInterestRatesByCurrencies";
|
5
|
+
import { getInterestRateForAsset } from "../../utils/getInterestRateForAsset";
|
4
6
|
|
5
7
|
const createApyItem = ({
|
6
8
|
value,
|
@@ -13,14 +15,30 @@ const createApyItem = ({
|
|
13
15
|
}) => <ApyIndicator value={value} type={type} />;
|
14
16
|
|
15
17
|
export const useLeftApyModule = (
|
16
|
-
|
18
|
+
currencies: CryptoOrTokenCurrency[],
|
17
19
|
ApyIndicator: React.ComponentType<{ value: number; type: ApyType }>,
|
18
20
|
) => {
|
19
|
-
const
|
20
|
-
const type = "APY"; // TODO to be retrieved from DADA
|
21
|
+
const interestRates = useInterestRatesByCurrencies(currencies);
|
21
22
|
|
22
|
-
return
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
return useMemo(() => {
|
24
|
+
return currencies.map(currency => {
|
25
|
+
const { interestRate, interestRatePercentageRounded } = getInterestRateForAsset(
|
26
|
+
currency,
|
27
|
+
interestRates,
|
28
|
+
);
|
29
|
+
|
30
|
+
if (!interestRate || interestRatePercentageRounded <= 0) {
|
31
|
+
return currency;
|
32
|
+
}
|
33
|
+
|
34
|
+
return {
|
35
|
+
...currency,
|
36
|
+
leftElement: createApyItem({
|
37
|
+
value: interestRatePercentageRounded,
|
38
|
+
type: interestRate.type,
|
39
|
+
ApyIndicator,
|
40
|
+
}),
|
41
|
+
};
|
42
|
+
});
|
43
|
+
}, [currencies, interestRates, ApyIndicator]);
|
26
44
|
};
|
package/src/modularDrawer/hooks/{modules/useAssetAccountCounts.tsx → useAssetAccountCounts.tsx}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Observable } from "rxjs";
|
2
2
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
-
import { getAccountTuplesForCurrency } from "
|
3
|
+
import { getAccountTuplesForCurrency } from "../../utils/getAccountTuplesForCurrency";
|
4
4
|
import type { Account } from "@ledgerhq/types-live";
|
5
|
-
import { WalletAPIAccount } from "
|
5
|
+
import { WalletAPIAccount } from "../../wallet-api/types";
|
6
6
|
|
7
7
|
type AccountModuleParams = {
|
8
8
|
assets: CryptoOrTokenCurrency[];
|
@@ -1,36 +1,73 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { useMemo } from "react";
|
2
|
+
import { useGetAssetsDataInfiniteQuery } from "../data/state-manager/api";
|
3
|
+
import { AssetsDataWithPagination } from "../data/state-manager/types";
|
4
|
+
|
5
|
+
const emptyData = () => ({
|
6
|
+
cryptoAssets: {},
|
7
|
+
networks: {},
|
8
|
+
cryptoOrTokenCurrencies: {},
|
9
|
+
interestRates: {},
|
10
|
+
markets: {},
|
11
|
+
currenciesOrder: {
|
12
|
+
currenciesIds: [],
|
13
|
+
metaCurrencyIds: [],
|
14
|
+
key: "",
|
15
|
+
order: "",
|
16
|
+
},
|
17
|
+
pagination: { nextCursor: "" },
|
18
|
+
});
|
3
19
|
|
4
20
|
export function useAssetsData({
|
5
21
|
search,
|
6
22
|
currencyIds,
|
23
|
+
useCase,
|
24
|
+
areCurrenciesFiltered,
|
25
|
+
product,
|
26
|
+
version,
|
7
27
|
}: {
|
8
28
|
search?: string;
|
9
29
|
currencyIds?: string[];
|
30
|
+
useCase?: string;
|
31
|
+
areCurrenciesFiltered?: boolean;
|
32
|
+
product: "llm" | "lld";
|
33
|
+
version: string;
|
10
34
|
}) {
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
const { data, isLoading, error, fetchNextPage, isSuccess, refetch } =
|
36
|
+
useGetAssetsDataInfiniteQuery({
|
37
|
+
search,
|
38
|
+
useCase,
|
39
|
+
currencyIds: areCurrenciesFiltered ? currencyIds : undefined,
|
40
|
+
product,
|
41
|
+
version,
|
42
|
+
});
|
43
|
+
|
44
|
+
const joinedPages = useMemo(() => {
|
45
|
+
return data?.pages.reduce<AssetsDataWithPagination>((acc, page) => {
|
46
|
+
Object.assign(acc.cryptoAssets, page.cryptoAssets);
|
47
|
+
Object.assign(acc.networks, page.networks);
|
48
|
+
Object.assign(acc.cryptoOrTokenCurrencies, page.cryptoOrTokenCurrencies);
|
49
|
+
Object.assign(acc.interestRates, page.interestRates);
|
50
|
+
Object.assign(acc.markets, page.markets);
|
51
|
+
|
52
|
+
acc.currenciesOrder.currenciesIds.push(...page.currenciesOrder.currenciesIds);
|
53
|
+
acc.currenciesOrder.metaCurrencyIds.push(...page.currenciesOrder.metaCurrencyIds);
|
54
|
+
|
55
|
+
acc.currenciesOrder.key = page.currenciesOrder.key;
|
56
|
+
acc.currenciesOrder.order = page.currenciesOrder.order;
|
57
|
+
acc.pagination.nextCursor = page.pagination.nextCursor;
|
58
|
+
|
59
|
+
return acc;
|
60
|
+
}, emptyData());
|
61
|
+
}, [data]);
|
62
|
+
|
63
|
+
const hasMore = Boolean(joinedPages?.pagination.nextCursor);
|
26
64
|
|
27
65
|
return {
|
28
|
-
data,
|
29
|
-
error,
|
66
|
+
data: joinedPages,
|
30
67
|
isLoading,
|
68
|
+
error,
|
69
|
+
loadNext: hasMore ? fetchNextPage : undefined,
|
31
70
|
isSuccess,
|
32
|
-
|
33
|
-
cursor,
|
34
|
-
loadNext,
|
71
|
+
refetch,
|
35
72
|
};
|
36
73
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { useSelector } from "react-redux";
|
2
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { selectInterestRateByCurrency } from "../data/entities/interestRateSelectors";
|
4
|
+
import { ApyType } from "../utils/type";
|
5
|
+
|
6
|
+
const isValidApyType = (type: string): type is ApyType =>
|
7
|
+
type === "NRR" || type === "APY" || type === "APR";
|
8
|
+
|
9
|
+
export const useInterestRatesByCurrencies = (currencies: CryptoOrTokenCurrency[]) => {
|
10
|
+
return useSelector(state => {
|
11
|
+
const rates: Record<string, { value: number; type: ApyType } | undefined> = {};
|
12
|
+
currencies.forEach(currency => {
|
13
|
+
const apiRate = selectInterestRateByCurrency(state, currency.id);
|
14
|
+
if (apiRate && isValidApyType(apiRate.type)) {
|
15
|
+
rates[currency.id] = {
|
16
|
+
value: apiRate.rate,
|
17
|
+
type: apiRate.type,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
});
|
21
|
+
return rates;
|
22
|
+
});
|
23
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { ReactNode } from "react";
|
3
|
+
import { AccountModuleParams, AccountDataItem } from "../utils/type";
|
4
|
+
|
5
|
+
export const createUseLeftAccountsModule = ({
|
6
|
+
useAccountData,
|
7
|
+
accountsCount,
|
8
|
+
}: {
|
9
|
+
useAccountData: (params: AccountModuleParams) => AccountDataItem[];
|
10
|
+
accountsCount: (args: { label: string }) => ReactNode;
|
11
|
+
}) => {
|
12
|
+
return function useLeftAccountsModule(
|
13
|
+
params: AccountModuleParams,
|
14
|
+
): Array<CryptoOrTokenCurrency & { leftElement?: ReactNode; count: number }> {
|
15
|
+
const accountData = useAccountData(params);
|
16
|
+
|
17
|
+
return accountData.map(({ asset, label, count }) => ({
|
18
|
+
...asset,
|
19
|
+
leftElement: count > 0 ? accountsCount({ label }) : undefined,
|
20
|
+
count,
|
21
|
+
}));
|
22
|
+
};
|
23
|
+
};
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import {
|
2
|
+
AccountDataItem,
|
3
|
+
AccountModuleParams,
|
4
|
+
CreateAccountsCountAndApy,
|
5
|
+
NetworkWithCount,
|
6
|
+
} from "../utils/type";
|
7
|
+
import { useInterestRatesByCurrencies } from "../hooks/useInterestRatesByCurrencies";
|
8
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
9
|
+
import { getInterestRateForAsset } from "../utils/getInterestRateForAsset";
|
10
|
+
|
11
|
+
export function useLeftAccountsApyModule(
|
12
|
+
params: AccountModuleParams,
|
13
|
+
useAccountData: (params: AccountModuleParams) => AccountDataItem[],
|
14
|
+
accountsCountAndApy: CreateAccountsCountAndApy,
|
15
|
+
networks: CryptoOrTokenCurrency[],
|
16
|
+
): NetworkWithCount[] {
|
17
|
+
const accountData = useAccountData(params);
|
18
|
+
const interestRates = useInterestRatesByCurrencies(networks);
|
19
|
+
|
20
|
+
// Map each account to its APY info using the shared utility
|
21
|
+
return accountData.map(({ asset, label, count }) => {
|
22
|
+
const { interestRate, interestRatePercentageRounded } = getInterestRateForAsset(
|
23
|
+
asset,
|
24
|
+
interestRates,
|
25
|
+
networks,
|
26
|
+
);
|
27
|
+
|
28
|
+
if ((!interestRate || interestRatePercentageRounded <= 0) && count <= 0) {
|
29
|
+
return {
|
30
|
+
...asset,
|
31
|
+
count,
|
32
|
+
};
|
33
|
+
}
|
34
|
+
return {
|
35
|
+
...asset,
|
36
|
+
leftElement: accountsCountAndApy({
|
37
|
+
label: count > 0 ? label : undefined,
|
38
|
+
value: interestRatePercentageRounded,
|
39
|
+
type: interestRate?.type,
|
40
|
+
}),
|
41
|
+
count,
|
42
|
+
};
|
43
|
+
});
|
44
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { useFeature } from "../../featureFlags";
|
2
|
+
import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
|
3
|
+
|
4
|
+
const assetConfigurationDisabled: EnhancedModularDrawerConfiguration["assets"] = {
|
5
|
+
rightElement: "undefined",
|
6
|
+
leftElement: "undefined",
|
7
|
+
filter: "undefined",
|
8
|
+
};
|
9
|
+
|
10
|
+
const networkConfigurationDisabled: EnhancedModularDrawerConfiguration["networks"] = {
|
11
|
+
rightElement: "undefined",
|
12
|
+
leftElement: "undefined",
|
13
|
+
};
|
14
|
+
|
15
|
+
export const useModularDrawerConfiguration = (
|
16
|
+
featureFlagKey: "lldModularDrawer" | "llmModularDrawer",
|
17
|
+
drawerConfiguration?: EnhancedModularDrawerConfiguration,
|
18
|
+
) => {
|
19
|
+
const featureModularDrawer = useFeature(featureFlagKey);
|
20
|
+
|
21
|
+
const modularizationEnabled = featureModularDrawer?.params?.enableModularization ?? false;
|
22
|
+
const assetsConfiguration = modularizationEnabled
|
23
|
+
? drawerConfiguration?.assets
|
24
|
+
: assetConfigurationDisabled;
|
25
|
+
const networkConfiguration = modularizationEnabled
|
26
|
+
? drawerConfiguration?.networks
|
27
|
+
: networkConfigurationDisabled;
|
28
|
+
|
29
|
+
return {
|
30
|
+
assetsConfiguration,
|
31
|
+
networkConfiguration,
|
32
|
+
};
|
33
|
+
};
|
@@ -0,0 +1,140 @@
|
|
1
|
+
import { useMemo } from "react";
|
2
|
+
import type { ReactNode } from "react";
|
3
|
+
import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
|
4
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
|
5
|
+
import BigNumber from "bignumber.js";
|
6
|
+
import { counterValueFormatter } from "../utils/counterValueFormatter";
|
7
|
+
import { compareByBalanceThenFiat } from "../utils/sortByBalance";
|
8
|
+
import { UseBalanceDeps } from "../utils/type";
|
9
|
+
import { buildProviderCurrenciesMap } from "../utils/buildProviderCurrenciesMap";
|
10
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
11
|
+
import { calculateProviderTotals } from "../utils/calculateProviderTotal";
|
12
|
+
import { getProviderCurrency } from "../utils/getProviderCurrency";
|
13
|
+
import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
|
14
|
+
import { groupAccountsByAsset } from "../utils/groupAccountsByAsset";
|
15
|
+
|
16
|
+
export type AssetDeps = {
|
17
|
+
useBalanceDeps: UseBalanceDeps;
|
18
|
+
balanceItem: (asset: { fiatValue?: string; balance?: string }) => ReactNode;
|
19
|
+
};
|
20
|
+
|
21
|
+
export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem }: AssetDeps) {
|
22
|
+
const formatProviderResult = (
|
23
|
+
providerCurrency: CryptoOrTokenCurrency,
|
24
|
+
totalBalance: BigNumber,
|
25
|
+
totalFiatValue: BigNumber,
|
26
|
+
counterValueCurrency: Currency,
|
27
|
+
locale: string,
|
28
|
+
discreet: boolean,
|
29
|
+
) => {
|
30
|
+
const unit = providerCurrency.units?.[0];
|
31
|
+
const balance = unit
|
32
|
+
? formatCurrencyUnit(unit, totalBalance, { showCode: true, discreet })
|
33
|
+
: `${totalBalance.toFixed()} ${providerCurrency.ticker ?? providerCurrency.symbol}`;
|
34
|
+
const fiatValue = counterValueFormatter({
|
35
|
+
currency: counterValueCurrency.ticker,
|
36
|
+
value: totalFiatValue.toNumber(),
|
37
|
+
locale,
|
38
|
+
allowZeroValue: true,
|
39
|
+
});
|
40
|
+
return { balance, fiatValue };
|
41
|
+
};
|
42
|
+
|
43
|
+
return function useRightBalanceAsset(
|
44
|
+
assets: CryptoOrTokenCurrency[],
|
45
|
+
currenciesByProvider: CurrenciesByProviderId[],
|
46
|
+
) {
|
47
|
+
const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
|
48
|
+
|
49
|
+
const grouped = useMemo(
|
50
|
+
() => groupAccountsByAsset(flattenedAccounts, state, counterValueCurrency, discreet),
|
51
|
+
[flattenedAccounts, state, counterValueCurrency, discreet],
|
52
|
+
);
|
53
|
+
|
54
|
+
const providerMap = useMemo(
|
55
|
+
() => buildProviderCurrenciesMap(currenciesByProvider),
|
56
|
+
[currenciesByProvider],
|
57
|
+
);
|
58
|
+
|
59
|
+
return useMemo(() => {
|
60
|
+
if (!providerMap) {
|
61
|
+
const allBalance = getBalanceAndFiatValueByAssets(
|
62
|
+
flattenedAccounts,
|
63
|
+
assets,
|
64
|
+
state,
|
65
|
+
counterValueCurrency,
|
66
|
+
discreet,
|
67
|
+
locale,
|
68
|
+
);
|
69
|
+
const balanceMap = new Map(allBalance.map(b => [b.id, b]));
|
70
|
+
const assetsWithBalanceData = assets.map(asset => {
|
71
|
+
const balanceData = balanceMap.get(asset.id) || {};
|
72
|
+
return {
|
73
|
+
asset,
|
74
|
+
balanceData,
|
75
|
+
};
|
76
|
+
});
|
77
|
+
|
78
|
+
assetsWithBalanceData.sort((a, b) =>
|
79
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
80
|
+
);
|
81
|
+
|
82
|
+
return assetsWithBalanceData.map(({ asset, balanceData }) => ({
|
83
|
+
...asset,
|
84
|
+
rightElement: balanceItem(balanceData),
|
85
|
+
}));
|
86
|
+
}
|
87
|
+
|
88
|
+
const assetsSet = new Set(assets.map(a => a.id));
|
89
|
+
const providerResultsMap = new Map<string, { balance?: string; fiatValue?: string }>();
|
90
|
+
|
91
|
+
for (const [, { currencies, mainCurrency }] of providerMap) {
|
92
|
+
if (!assetsSet.has(mainCurrency.id)) continue;
|
93
|
+
const providerCurrency = getProviderCurrency(mainCurrency, currencies);
|
94
|
+
if (!providerCurrency) continue;
|
95
|
+
|
96
|
+
const { totalBalance, totalFiatValue, hasAccounts } = calculateProviderTotals(
|
97
|
+
currencies,
|
98
|
+
grouped,
|
99
|
+
);
|
100
|
+
if (!hasAccounts) continue;
|
101
|
+
|
102
|
+
const { balance, fiatValue } = formatProviderResult(
|
103
|
+
providerCurrency,
|
104
|
+
totalBalance,
|
105
|
+
totalFiatValue,
|
106
|
+
counterValueCurrency,
|
107
|
+
locale,
|
108
|
+
discreet,
|
109
|
+
);
|
110
|
+
providerResultsMap.set(mainCurrency.id, { balance, fiatValue });
|
111
|
+
}
|
112
|
+
|
113
|
+
const assetsWithBalanceData = assets.map(asset => {
|
114
|
+
const balanceData = providerResultsMap.get(asset.id) || {};
|
115
|
+
return {
|
116
|
+
asset,
|
117
|
+
balanceData,
|
118
|
+
};
|
119
|
+
});
|
120
|
+
|
121
|
+
assetsWithBalanceData.sort((a, b) =>
|
122
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
123
|
+
);
|
124
|
+
|
125
|
+
return assetsWithBalanceData.map(({ asset, balanceData }) => ({
|
126
|
+
...asset,
|
127
|
+
rightElement: balanceItem(balanceData),
|
128
|
+
}));
|
129
|
+
}, [
|
130
|
+
assets,
|
131
|
+
providerMap,
|
132
|
+
flattenedAccounts,
|
133
|
+
state,
|
134
|
+
counterValueCurrency,
|
135
|
+
discreet,
|
136
|
+
locale,
|
137
|
+
grouped,
|
138
|
+
]);
|
139
|
+
};
|
140
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { useMemo, type ReactNode } from "react";
|
2
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { compareByBalanceThenFiat } from "../utils/sortByBalance";
|
4
|
+
import { BalanceUI, UseBalanceDeps } from "../utils/type";
|
5
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
6
|
+
import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
|
7
|
+
|
8
|
+
export type NetworkDeps = {
|
9
|
+
balanceItem: (asset: { fiatValue?: string; balance?: string }) => ReactNode;
|
10
|
+
useBalanceDeps: UseBalanceDeps;
|
11
|
+
};
|
12
|
+
|
13
|
+
type Params = {
|
14
|
+
assets: CryptoOrTokenCurrency[];
|
15
|
+
selectedAssetId: string;
|
16
|
+
currenciesByProvider: CurrenciesByProviderId[];
|
17
|
+
};
|
18
|
+
|
19
|
+
export function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }: NetworkDeps) {
|
20
|
+
return function useRightBalanceNetwork({
|
21
|
+
assets: networks,
|
22
|
+
selectedAssetId,
|
23
|
+
currenciesByProvider,
|
24
|
+
}: Params) {
|
25
|
+
const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
|
26
|
+
|
27
|
+
return useMemo(() => {
|
28
|
+
if (currenciesByProvider && currenciesByProvider.length > 0) {
|
29
|
+
const providerOfSelectedAsset = currenciesByProvider.find(provider =>
|
30
|
+
provider.currenciesByNetwork.some(currency => currency.id === selectedAssetId),
|
31
|
+
);
|
32
|
+
|
33
|
+
if (providerOfSelectedAsset) {
|
34
|
+
const pairs = networks.map(network => ({
|
35
|
+
network,
|
36
|
+
asset: providerOfSelectedAsset.currenciesByNetwork.find(currency =>
|
37
|
+
currency.type === "TokenCurrency"
|
38
|
+
? currency.parentCurrency.id === network.id
|
39
|
+
: currency.id === network.id,
|
40
|
+
),
|
41
|
+
}));
|
42
|
+
|
43
|
+
const validAssets = pairs.filter(p => p.asset).map(p => p.asset!);
|
44
|
+
|
45
|
+
const allBalanceData =
|
46
|
+
validAssets.length > 0
|
47
|
+
? getBalanceAndFiatValueByAssets(
|
48
|
+
flattenedAccounts,
|
49
|
+
validAssets,
|
50
|
+
state,
|
51
|
+
counterValueCurrency,
|
52
|
+
discreet,
|
53
|
+
locale,
|
54
|
+
)
|
55
|
+
: [];
|
56
|
+
|
57
|
+
const balanceMap = new Map(allBalanceData.map(b => [b.id, b]));
|
58
|
+
|
59
|
+
const networkWithBalanceData = pairs.map(({ network, asset }) => {
|
60
|
+
const balanceData: BalanceUI = asset ? balanceMap.get(asset.id) || {} : {};
|
61
|
+
return {
|
62
|
+
network,
|
63
|
+
balanceData,
|
64
|
+
};
|
65
|
+
});
|
66
|
+
|
67
|
+
networkWithBalanceData.sort((a, b) =>
|
68
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
69
|
+
);
|
70
|
+
|
71
|
+
return networkWithBalanceData.map(({ network, balanceData }) => ({
|
72
|
+
...network,
|
73
|
+
rightElement: balanceItem(balanceData),
|
74
|
+
}));
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
const networkBalanceData = getBalanceAndFiatValueByAssets(
|
79
|
+
flattenedAccounts,
|
80
|
+
networks,
|
81
|
+
state,
|
82
|
+
counterValueCurrency,
|
83
|
+
discreet,
|
84
|
+
locale,
|
85
|
+
);
|
86
|
+
|
87
|
+
const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
|
88
|
+
|
89
|
+
const networksWithBalance = networks.map(network => {
|
90
|
+
const balanceData = balanceMap.get(network.id) || {};
|
91
|
+
return {
|
92
|
+
network,
|
93
|
+
balanceData,
|
94
|
+
};
|
95
|
+
});
|
96
|
+
|
97
|
+
networksWithBalance.sort((a, b) =>
|
98
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
99
|
+
);
|
100
|
+
|
101
|
+
return networksWithBalance.map(({ network, balanceData }) => ({
|
102
|
+
...network,
|
103
|
+
rightElement: balanceItem(balanceData),
|
104
|
+
}));
|
105
|
+
}, [
|
106
|
+
networks,
|
107
|
+
selectedAssetId,
|
108
|
+
currenciesByProvider,
|
109
|
+
flattenedAccounts,
|
110
|
+
state,
|
111
|
+
counterValueCurrency,
|
112
|
+
discreet,
|
113
|
+
locale,
|
114
|
+
]);
|
115
|
+
};
|
116
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { AssetType, CreateAssetConfigurationHook, AssetConfigurationDeps } from "../utils/type";
|
3
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
4
|
+
import { composeHooks } from "../../utils/composeHooks";
|
5
|
+
import { useLeftApyModule } from "../hooks/modules/useLeftApyModule";
|
6
|
+
import { createUseRightBalanceAsset } from "../hooks/useRightBalanceAsset";
|
7
|
+
|
8
|
+
const getRightElement =
|
9
|
+
(AssetConfigurationDeps: AssetConfigurationDeps) => (rightElement?: string) => {
|
10
|
+
switch (rightElement) {
|
11
|
+
case "undefined":
|
12
|
+
return undefined;
|
13
|
+
case "marketTrend":
|
14
|
+
case "balance":
|
15
|
+
default:
|
16
|
+
return createUseRightBalanceAsset({
|
17
|
+
useBalanceDeps: AssetConfigurationDeps.useBalanceDeps,
|
18
|
+
balanceItem: AssetConfigurationDeps.balanceItem,
|
19
|
+
});
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const getLeftElement =
|
24
|
+
(AssetConfigurationDeps: AssetConfigurationDeps) => (leftElement?: string) => {
|
25
|
+
switch (leftElement) {
|
26
|
+
case "apy":
|
27
|
+
return (assets: CryptoOrTokenCurrency[]) =>
|
28
|
+
useLeftApyModule(assets, AssetConfigurationDeps.ApyIndicator);
|
29
|
+
case "marketTrend":
|
30
|
+
case "undefined":
|
31
|
+
default:
|
32
|
+
return undefined;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
const createAssetConfigurationHook: CreateAssetConfigurationHook =
|
37
|
+
deps =>
|
38
|
+
({ assetsConfiguration, currenciesByProvider }) => {
|
39
|
+
const { rightElement, leftElement } = assetsConfiguration ?? {};
|
40
|
+
|
41
|
+
const rightHook = getRightElement(deps)(rightElement);
|
42
|
+
const leftHook = getLeftElement(deps)(leftElement);
|
43
|
+
|
44
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
45
|
+
const hooks = [rightHook, leftHook].filter(Boolean) as Array<
|
46
|
+
(
|
47
|
+
assets: CryptoOrTokenCurrency[],
|
48
|
+
currenciesByProvider?: CurrenciesByProviderId[],
|
49
|
+
) => AssetType[]
|
50
|
+
>;
|
51
|
+
|
52
|
+
return (assets: CryptoOrTokenCurrency[]) => {
|
53
|
+
const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(
|
54
|
+
...hooks.map(
|
55
|
+
hook => (assets: CryptoOrTokenCurrency[]) => hook(assets, currenciesByProvider),
|
56
|
+
),
|
57
|
+
);
|
58
|
+
return composedHook(assets);
|
59
|
+
};
|
60
|
+
};
|
61
|
+
|
62
|
+
export default createAssetConfigurationHook;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { createUseLeftAccountsModule } from "../hooks/useLeftAccounts";
|
3
|
+
import { useLeftAccountsApyModule } from "../hooks/useLeftAccountsApy";
|
4
|
+
import { createUseRightBalanceNetwork } from "../hooks/useRightBalanceNetwork";
|
5
|
+
import {
|
6
|
+
CreateNetworkConfigurationHookProps,
|
7
|
+
NetworkConfigurationDeps,
|
8
|
+
LeftElementKind,
|
9
|
+
Network,
|
10
|
+
NetworkHook,
|
11
|
+
RightElementKind,
|
12
|
+
AccountModuleParams,
|
13
|
+
} from "../utils/type";
|
14
|
+
import { composeHooks } from "../../utils/composeHooks";
|
15
|
+
|
16
|
+
export const getLeftElement =
|
17
|
+
(NetworkConfigurationDeps: NetworkConfigurationDeps) =>
|
18
|
+
(leftElement?: LeftElementKind): NetworkHook | undefined => {
|
19
|
+
switch (leftElement) {
|
20
|
+
case "undefined":
|
21
|
+
return undefined;
|
22
|
+
case "numberOfAccountsAndApy":
|
23
|
+
return (params: AccountModuleParams & { networks: CryptoOrTokenCurrency[] }) =>
|
24
|
+
useLeftAccountsApyModule(
|
25
|
+
params,
|
26
|
+
NetworkConfigurationDeps.useAccountData,
|
27
|
+
NetworkConfigurationDeps.accountsCountAndApy,
|
28
|
+
params.networks,
|
29
|
+
);
|
30
|
+
case "numberOfAccounts":
|
31
|
+
default:
|
32
|
+
return createUseLeftAccountsModule({
|
33
|
+
useAccountData: NetworkConfigurationDeps.useAccountData,
|
34
|
+
accountsCount: NetworkConfigurationDeps.accountsCount,
|
35
|
+
});
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
export const getRightElement =
|
40
|
+
(NetworkConfigurationDeps: NetworkConfigurationDeps) =>
|
41
|
+
(rightElement?: RightElementKind): NetworkHook | undefined => {
|
42
|
+
switch (rightElement) {
|
43
|
+
case "undefined":
|
44
|
+
return undefined;
|
45
|
+
case "balance":
|
46
|
+
default:
|
47
|
+
return createUseRightBalanceNetwork({
|
48
|
+
useBalanceDeps: NetworkConfigurationDeps.useBalanceDeps,
|
49
|
+
balanceItem: NetworkConfigurationDeps.balanceItem,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
export const createNetworkConfigurationHook =
|
55
|
+
(NetworkConfigurationDeps: NetworkConfigurationDeps) =>
|
56
|
+
({
|
57
|
+
networksConfig,
|
58
|
+
selectedAssetId,
|
59
|
+
currenciesByProvider,
|
60
|
+
accounts$,
|
61
|
+
}: CreateNetworkConfigurationHookProps) => {
|
62
|
+
const { leftElement, rightElement } = networksConfig ?? {};
|
63
|
+
const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
|
64
|
+
const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
|
65
|
+
|
66
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
67
|
+
const hooks = [rightHook, leftHook].filter(Boolean) as NetworkHook[];
|
68
|
+
|
69
|
+
return (
|
70
|
+
assets: CryptoOrTokenCurrency[],
|
71
|
+
networks: CryptoOrTokenCurrency[],
|
72
|
+
): Array<CryptoOrTokenCurrency & Network> => {
|
73
|
+
const composedHook = composeHooks<CryptoOrTokenCurrency, Network>(
|
74
|
+
...hooks.map(
|
75
|
+
hook => () =>
|
76
|
+
hook({
|
77
|
+
assets,
|
78
|
+
selectedAssetId,
|
79
|
+
currenciesByProvider: currenciesByProvider || [],
|
80
|
+
accounts$,
|
81
|
+
networks,
|
82
|
+
}),
|
83
|
+
),
|
84
|
+
);
|
85
|
+
return composedHook(assets);
|
86
|
+
};
|
87
|
+
};
|