@ledgerhq/live-common 34.46.0 → 34.47.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/__tests__/test-helpers/environment.js +2 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/bridge/crypto-assets/index.d.ts +1 -1
- package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +1 -1
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +2 -2
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +12 -12
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +3 -4
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts +0 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +0 -1
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/impl.d.ts +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/currencies/index.d.ts +1 -1
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +1 -2
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +2 -1
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/domain/getTokensWithFunds.test.js +1 -1
- package/lib/domain/getTokensWithFunds.test.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +1 -1
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.d.ts +3 -2
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +2 -1
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/enum/Provider.d.ts.map +1 -1
- package/lib/e2e/enum/Provider.js +2 -2
- package/lib/e2e/enum/Provider.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +4 -4
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/index.d.ts +5 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +4 -5
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosCI.d.ts +4 -0
- package/lib/e2e/speculosCI.d.ts.map +1 -1
- package/lib/e2e/speculosCI.js +16 -6
- 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/api/v5/actions.js +1 -1
- package/lib/exchange/swap/api/v5/actions.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +1 -1
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +35 -1
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/evm/setup.d.ts.map +1 -1
- package/lib/families/evm/setup.js +11 -1
- package/lib/families/evm/setup.js.map +1 -1
- package/lib/families/hedera/constants.d.ts +2 -0
- package/lib/families/hedera/constants.d.ts.map +1 -0
- package/lib/families/hedera/constants.js +19 -0
- package/lib/families/hedera/constants.js.map +1 -0
- package/lib/families/hedera/setup.d.ts +5 -5
- package/lib/families/hedera/setup.d.ts.map +1 -1
- package/lib/families/hedera/setup.js.map +1 -1
- package/lib/families/solana/setup.d.ts.map +1 -1
- package/lib/families/solana/setup.js +2 -1
- package/lib/families/solana/setup.js.map +1 -1
- package/lib/families/sui/constants.d.ts +2 -0
- package/lib/families/sui/constants.d.ts.map +1 -0
- package/lib/families/sui/constants.js +19 -0
- package/lib/families/sui/constants.js.map +1 -0
- package/lib/families/sui/logic.d.ts +2 -0
- package/lib/families/sui/logic.d.ts.map +1 -0
- package/lib/families/sui/logic.js +19 -0
- package/lib/families/sui/logic.js.map +1 -0
- package/lib/families/sui/react.d.ts +8 -0
- package/lib/families/sui/react.d.ts.map +1 -0
- package/lib/families/sui/react.js +85 -0
- package/lib/families/sui/react.js.map +1 -0
- package/lib/families/sui/types.d.ts +2 -0
- package/lib/families/sui/types.d.ts.map +1 -0
- package/lib/families/sui/types.js +19 -0
- package/lib/families/sui/types.js.map +1 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -0
- 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/market/utils/countervalueFormatter.d.ts.map +1 -1
- package/lib/market/utils/countervalueFormatter.js.map +1 -1
- package/lib/market/utils/types.d.ts +2 -0
- package/lib/market/utils/types.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/currencies.mock.js +7 -7
- package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
- package/lib/modularDrawer/data/entities/index.d.ts +68 -0
- package/lib/modularDrawer/data/entities/index.d.ts.map +1 -0
- package/lib/modularDrawer/data/entities/index.js +3 -0
- package/lib/modularDrawer/data/entities/index.js.map +1 -0
- package/lib/modularDrawer/data/state-manager/api.d.ts +857 -0
- package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -0
- package/lib/modularDrawer/data/state-manager/api.js +63 -0
- package/lib/modularDrawer/data/state-manager/api.js.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +176 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js +16 -0
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +18 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
- package/lib/modularDrawer/hooks/useAssetsData.d.ts +12 -0
- package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useAssetsData.js +50 -0
- package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -0
- package/lib/modularDrawer/types.d.ts +2 -0
- package/lib/modularDrawer/types.d.ts.map +1 -0
- package/lib/modularDrawer/types.js +3 -0
- package/lib/modularDrawer/types.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js +496 -0
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
- package/lib/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
- package/lib/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
- package/lib/modularDrawer/utils/calculateProviderTotal.js +23 -0
- package/lib/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
- package/lib/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
- package/lib/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
- package/lib/modularDrawer/utils/counterValueFormatter.js +107 -0
- package/lib/modularDrawer/utils/counterValueFormatter.js.map +1 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +45 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getProviderCurrency.js +14 -0
- package/lib/modularDrawer/utils/getProviderCurrency.js.map +1 -0
- package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
- package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
- package/lib/modularDrawer/utils/groupAccountsByAsset.js +32 -0
- package/lib/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
- package/lib/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
- package/lib/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
- package/lib/modularDrawer/utils/parseToBigNumber.js +24 -0
- package/lib/modularDrawer/utils/parseToBigNumber.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +21 -0
- package/lib/modularDrawer/utils/type.d.ts.map +1 -0
- package/lib/modularDrawer/utils/type.js +3 -0
- package/lib/modularDrawer/utils/type.js.map +1 -0
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/lib/wallet-api/Exchange/error.d.ts +1 -0
- package/lib/wallet-api/Exchange/error.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/error.js +11 -1
- package/lib/wallet-api/Exchange/error.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts +2 -0
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +29 -5
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/Exchange/server.test.js +3 -0
- package/lib/wallet-api/Exchange/server.test.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/bridge/crypto-assets/index.d.ts +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +1 -1
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +6 -4
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +2 -2
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +12 -12
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +3 -4
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts +0 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +0 -1
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/impl.d.ts +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/currencies/index.d.ts +1 -1
- package/lib-es/currencies/index.d.ts.map +1 -1
- package/lib-es/currencies/index.js +1 -1
- package/lib-es/currencies/index.js.map +1 -1
- package/lib-es/currencies/sortByMarketcap.test.js +2 -1
- package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib-es/domain/getTokensWithFunds.test.js +1 -1
- package/lib-es/domain/getTokensWithFunds.test.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts +3 -2
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +2 -1
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
- package/lib-es/e2e/enum/Provider.js +2 -2
- package/lib-es/e2e/enum/Provider.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +4 -4
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/index.d.ts +5 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +4 -5
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosCI.d.ts +4 -0
- package/lib-es/e2e/speculosCI.d.ts.map +1 -1
- package/lib-es/e2e/speculosCI.js +14 -5
- 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/api/v5/actions.js +1 -1
- package/lib-es/exchange/swap/api/v5/actions.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +1 -1
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +35 -1
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/evm/setup.d.ts.map +1 -1
- package/lib-es/families/evm/setup.js +11 -1
- package/lib-es/families/evm/setup.js.map +1 -1
- package/lib-es/families/hedera/constants.d.ts +2 -0
- package/lib-es/families/hedera/constants.d.ts.map +1 -0
- package/lib-es/families/hedera/constants.js +3 -0
- package/lib-es/families/hedera/constants.js.map +1 -0
- package/lib-es/families/hedera/setup.d.ts +5 -5
- package/lib-es/families/hedera/setup.d.ts.map +1 -1
- package/lib-es/families/hedera/setup.js.map +1 -1
- package/lib-es/families/solana/setup.d.ts.map +1 -1
- package/lib-es/families/solana/setup.js +2 -1
- package/lib-es/families/solana/setup.js.map +1 -1
- package/lib-es/families/sui/constants.d.ts +2 -0
- package/lib-es/families/sui/constants.d.ts.map +1 -0
- package/lib-es/families/sui/constants.js +3 -0
- package/lib-es/families/sui/constants.js.map +1 -0
- package/lib-es/families/sui/logic.d.ts +2 -0
- package/lib-es/families/sui/logic.d.ts.map +1 -0
- package/lib-es/families/sui/logic.js +3 -0
- package/lib-es/families/sui/logic.js.map +1 -0
- package/lib-es/families/sui/react.d.ts +8 -0
- package/lib-es/families/sui/react.d.ts.map +1 -0
- package/lib-es/families/sui/react.js +78 -0
- package/lib-es/families/sui/react.js.map +1 -0
- package/lib-es/families/sui/types.d.ts +2 -0
- package/lib-es/families/sui/types.d.ts.map +1 -0
- package/lib-es/families/sui/types.js +3 -0
- package/lib-es/families/sui/types.js.map +1 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -0
- 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/market/utils/countervalueFormatter.d.ts.map +1 -1
- package/lib-es/market/utils/countervalueFormatter.js.map +1 -1
- package/lib-es/market/utils/types.d.ts +2 -0
- package/lib-es/market/utils/types.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
- package/lib-es/modularDrawer/data/entities/index.d.ts +68 -0
- package/lib-es/modularDrawer/data/entities/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/entities/index.js +2 -0
- package/lib-es/modularDrawer/data/entities/index.js.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/api.d.ts +857 -0
- package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/api.js +60 -0
- package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts +5 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +174 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts +19 -0
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js +12 -0
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +52 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +11 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +12 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.js +46 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -0
- package/lib-es/modularDrawer/types.d.ts +2 -0
- package/lib-es/modularDrawer/types.d.ts.map +1 -0
- package/lib-es/modularDrawer/types.js +2 -0
- package/lib-es/modularDrawer/types.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js +494 -0
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
- package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts +9 -0
- package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/calculateProviderTotal.js +16 -0
- package/lib-es/modularDrawer/utils/calculateProviderTotal.js.map +1 -0
- package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts +14 -0
- package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/counterValueFormatter.js +103 -0
- package/lib-es/modularDrawer/utils/counterValueFormatter.js.map +1 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +11 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +41 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.js +10 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +1 -0
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts +11 -0
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.js +25 -0
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.js.map +1 -0
- package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts +9 -0
- package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/parseToBigNumber.js +17 -0
- package/lib-es/modularDrawer/utils/parseToBigNumber.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +21 -0
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/type.js +2 -0
- package/lib-es/modularDrawer/utils/type.js.map +1 -0
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/lib-es/wallet-api/Exchange/error.d.ts +1 -0
- package/lib-es/wallet-api/Exchange/error.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/error.js +9 -0
- package/lib-es/wallet-api/Exchange/error.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts +2 -0
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +30 -6
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.test.js +3 -0
- package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
- package/package.json +68 -66
- package/src/DataModel.test.ts +1 -1
- package/src/__tests__/accounts/groupPerDay.ts +1 -1
- package/src/__tests__/test-helpers/environment.ts +2 -0
- package/src/__tests__/test-helpers/setup.ts +1 -1
- package/src/account/serialization.test.ts +1 -1
- package/src/bridge/crypto-assets/index.test.ts +1 -1
- package/src/bridge/crypto-assets/index.ts +3 -2
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +11 -5
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +2 -1
- package/src/bridge/generic-alpaca/prepareTransaction.ts +20 -16
- package/src/bridge/generic-alpaca/signOperation.ts +3 -2
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
- package/src/bridge/generic-alpaca/utils.ts +0 -2
- package/src/bridge/impl.ts +1 -1
- package/src/currencies/index.ts +0 -1
- package/src/currencies/sortByMarketcap.test.ts +3 -2
- package/src/domain/getTokensWithFunds.test.ts +1 -1
- package/src/e2e/enum/AppInfos.ts +1 -1
- package/src/e2e/enum/DeviceLabels.ts +2 -1
- package/src/e2e/enum/Provider.ts +2 -2
- package/src/e2e/families/solana.ts +7 -4
- package/src/e2e/speculos.ts +4 -5
- package/src/e2e/speculosCI.ts +18 -6
- package/src/exchange/swap/api/v5/actions.ts +1 -1
- package/src/exchange/swap/types.ts +1 -1
- package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +7 -0
- package/src/families/bitcoin/satstack.test.ts +1 -1
- package/src/families/canton/config.ts +36 -1
- package/src/families/evm/setup.ts +12 -1
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +464 -1135
- package/src/families/hedera/constants.ts +2 -0
- package/src/families/hedera/setup.ts +7 -3
- package/src/families/solana/setup.ts +2 -0
- package/src/families/sui/__snapshots__/bridge.integration.test.ts.snap +3 -1
- package/src/families/sui/constants.ts +2 -0
- package/src/families/sui/logic.ts +2 -0
- package/src/families/sui/react.ts +115 -0
- package/src/families/sui/types.ts +2 -0
- package/src/families/tron/data.mock.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +1 -0
- package/src/market/utils/countervalueFormatter.ts +0 -1
- package/src/market/utils/types.ts +4 -0
- package/src/modularDrawer/__mocks__/currencies.mock.ts +1 -1
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +1 -1
- package/src/modularDrawer/data/entities/index.ts +79 -0
- package/src/modularDrawer/data/state-manager/api.ts +83 -0
- package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +200 -0
- package/src/modularDrawer/hooks/modules/useAssetAccountCounts.tsx +36 -0
- package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +26 -0
- package/src/modularDrawer/hooks/useAssetsData.ts +59 -0
- package/src/modularDrawer/types.ts +1 -0
- package/src/modularDrawer/utils/__tests__/counterValueFormatter.test.ts +549 -0
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
- package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +2 -2
- package/src/modularDrawer/utils/calculateProviderTotal.ts +23 -0
- package/src/modularDrawer/utils/counterValueFormatter.ts +165 -0
- package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +76 -0
- package/src/modularDrawer/utils/getProviderCurrency.ts +13 -0
- package/src/modularDrawer/utils/groupAccountsByAsset.ts +51 -0
- package/src/modularDrawer/utils/parseToBigNumber.ts +17 -0
- package/src/modularDrawer/utils/type.ts +22 -0
- package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +1 -1
- package/src/wallet-api/Exchange/error.ts +10 -0
- package/src/wallet-api/Exchange/server.test.ts +5 -1
- package/src/wallet-api/Exchange/server.ts +44 -5
@@ -4,17 +4,21 @@ import { createBridges } from "@ledgerhq/coin-hedera/bridge/index";
|
|
4
4
|
import Transport from "@ledgerhq/hw-transport";
|
5
5
|
import Hedera from "@ledgerhq/hw-app-hedera";
|
6
6
|
import hederaResolver from "@ledgerhq/coin-hedera/signer/index";
|
7
|
-
import type {
|
7
|
+
import type {
|
8
|
+
TransactionStatus,
|
9
|
+
Transaction,
|
10
|
+
HederaAccount,
|
11
|
+
} from "@ledgerhq/coin-hedera/types/index";
|
12
|
+
import type { Bridge } from "@ledgerhq/types-live";
|
8
13
|
import makeCliTools from "@ledgerhq/coin-hedera/test/cli";
|
9
14
|
import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/setup";
|
10
15
|
import { Resolver } from "../../hw/getAddress/types";
|
11
|
-
import { TransactionStatus, Transaction } from "@ledgerhq/coin-hedera/types/index";
|
12
16
|
|
13
17
|
const createSigner: CreateSigner<Hedera> = (transport: Transport) => {
|
14
18
|
return new Hedera(transport);
|
15
19
|
};
|
16
20
|
|
17
|
-
const bridge: Bridge<Transaction,
|
21
|
+
const bridge: Bridge<Transaction, HederaAccount, TransactionStatus> = createBridges(
|
18
22
|
executeWithSigner(createSigner),
|
19
23
|
);
|
20
24
|
|
@@ -19,6 +19,7 @@ import { SolanaCoinConfig } from "@ledgerhq/coin-solana/config";
|
|
19
19
|
import { getCryptoCurrencyById } from "../../currencies";
|
20
20
|
import { signMessage } from "@ledgerhq/coin-solana/hw-signMessage";
|
21
21
|
import { LegacySignerSolana } from "@ledgerhq/live-signer-solana";
|
22
|
+
import { getCryptoAssetsStore } from "../../bridge/crypto-assets";
|
22
23
|
|
23
24
|
const createSigner: CreateSigner<SolanaSigner> = (transport: Transport) =>
|
24
25
|
new LegacySignerSolana(transport);
|
@@ -30,6 +31,7 @@ const getCurrencyConfig = () => {
|
|
30
31
|
const bridge: Bridge<Transaction, SolanaAccount, TransactionStatus> = createBridges(
|
31
32
|
executeWithSigner(createSigner),
|
32
33
|
getCurrencyConfig,
|
34
|
+
getCryptoAssetsStore,
|
33
35
|
);
|
34
36
|
|
35
37
|
const messageSigner = {
|
@@ -14,9 +14,10 @@ exports[`sui currency bridge scanAccounts sui seed 1 1`] = `
|
|
14
14
|
"pendingOperations": [],
|
15
15
|
"seedIdentifier": "e5fb8c817b97e9e9aec677b9e822e8a60c7471624f36b701c94560b88195a8e7",
|
16
16
|
"spendableBalance": "102696240",
|
17
|
+
"subAccounts": [],
|
17
18
|
"suiResources": {},
|
18
19
|
"swapHistory": [],
|
19
|
-
"syncHash":
|
20
|
+
"syncHash": "6p9XjoTwZ81o9xTkodgswDbETbrN5Lkv1b2shBN4p99s",
|
20
21
|
"used": true,
|
21
22
|
},
|
22
23
|
{
|
@@ -31,6 +32,7 @@ exports[`sui currency bridge scanAccounts sui seed 1 1`] = `
|
|
31
32
|
"pendingOperations": [],
|
32
33
|
"seedIdentifier": "e5fb8c817b97e9e9aec677b9e822e8a60c7471624f36b701c94560b88195a8e7",
|
33
34
|
"spendableBalance": "0",
|
35
|
+
"subAccounts": [],
|
34
36
|
"suiResources": {},
|
35
37
|
"swapHistory": [],
|
36
38
|
"syncHash": undefined,
|
@@ -0,0 +1,115 @@
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
2
|
+
import { FIGMENT_SUI_VALIDATOR_ADDRESS } from "@ledgerhq/coin-sui/constants";
|
3
|
+
import { BigNumber } from "bignumber.js";
|
4
|
+
import { SuiAccount, SuiResources, SuiValidator, MappedStake } from "./types";
|
5
|
+
import { getAccountCurrency } from "../../account";
|
6
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
7
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
8
|
+
import { getCurrentSuiPreloadData } from "@ledgerhq/coin-sui/preload";
|
9
|
+
import { getOperationExtra } from "@ledgerhq/coin-sui/getOperationExtra";
|
10
|
+
import { OperationType } from "@ledgerhq/types-live";
|
11
|
+
|
12
|
+
export function useSuiMappedStakingPositions(account: SuiAccount) {
|
13
|
+
const { validators } = getCurrentSuiPreloadData();
|
14
|
+
const stakingPositions = account.suiResources?.stakes;
|
15
|
+
|
16
|
+
const unit = getAccountCurrency(account).units[0];
|
17
|
+
|
18
|
+
return useMemo(
|
19
|
+
() => mapStakingPositions(stakingPositions ?? [], validators, unit),
|
20
|
+
[stakingPositions, validators, unit],
|
21
|
+
);
|
22
|
+
}
|
23
|
+
|
24
|
+
export function useGetExtraDetails(account: SuiAccount, type: OperationType, digest: string) {
|
25
|
+
if (!account.suiResources) {
|
26
|
+
account.suiResources = {};
|
27
|
+
}
|
28
|
+
if (!account.suiResources.cachedOps) {
|
29
|
+
account.suiResources.cachedOps = {};
|
30
|
+
}
|
31
|
+
const cache = account.suiResources.cachedOps;
|
32
|
+
const [data, setData] = useState(cache[digest]);
|
33
|
+
|
34
|
+
useEffect(() => {
|
35
|
+
if (type !== "DELEGATE" && type !== "UNDELEGATE") return;
|
36
|
+
if (data) return;
|
37
|
+
getOperationExtra(digest).then(result => {
|
38
|
+
setData(result);
|
39
|
+
cache[digest] = result;
|
40
|
+
});
|
41
|
+
}, [data, digest, cache, type]);
|
42
|
+
|
43
|
+
return data;
|
44
|
+
}
|
45
|
+
|
46
|
+
export function useLedgerFirstShuffledValidatorsSui(search: string) {
|
47
|
+
const { validators: unorderedValidators } = getCurrentSuiPreloadData();
|
48
|
+
const validators = reorderValidators(unorderedValidators);
|
49
|
+
return useMemo(() => {
|
50
|
+
if (validators.length === 0 || !search || search === "") {
|
51
|
+
return validators;
|
52
|
+
}
|
53
|
+
|
54
|
+
const lowercaseSearch = search.toLowerCase();
|
55
|
+
|
56
|
+
const filtered = validators.filter(
|
57
|
+
validator =>
|
58
|
+
validator.suiAddress?.toLowerCase().includes(lowercaseSearch) ||
|
59
|
+
validator.name.toLowerCase().includes(lowercaseSearch),
|
60
|
+
);
|
61
|
+
|
62
|
+
return filtered;
|
63
|
+
}, [validators, search]);
|
64
|
+
}
|
65
|
+
|
66
|
+
function reorderValidators(validators: SuiValidator[]): SuiValidator[] {
|
67
|
+
const sortedValidators = [...validators].sort((a, b) =>
|
68
|
+
new BigNumber(b.stakingPoolSuiBalance).minus(new BigNumber(a.stakingPoolSuiBalance)).toNumber(),
|
69
|
+
);
|
70
|
+
|
71
|
+
// move Ledger validator to the first position
|
72
|
+
const ledgerValidator = sortedValidators.find(
|
73
|
+
v => v.suiAddress === FIGMENT_SUI_VALIDATOR_ADDRESS,
|
74
|
+
);
|
75
|
+
|
76
|
+
if (ledgerValidator) {
|
77
|
+
const sortedValidatorsLedgerFirst = sortedValidators.filter(
|
78
|
+
v => v.suiAddress !== FIGMENT_SUI_VALIDATOR_ADDRESS,
|
79
|
+
);
|
80
|
+
sortedValidatorsLedgerFirst.unshift(ledgerValidator);
|
81
|
+
|
82
|
+
return sortedValidatorsLedgerFirst;
|
83
|
+
}
|
84
|
+
|
85
|
+
return sortedValidators;
|
86
|
+
}
|
87
|
+
|
88
|
+
type Stake = Required<SuiResources>["stakes"];
|
89
|
+
|
90
|
+
export const mapStakingPositions = (
|
91
|
+
stakingPositions: Stake,
|
92
|
+
validators: SuiValidator[],
|
93
|
+
unit: Unit,
|
94
|
+
): MappedStake[] => {
|
95
|
+
const data = stakingPositions.flatMap(sp =>
|
96
|
+
sp.stakes.map(s => ({ ...s, validatorAddress: sp.validatorAddress })),
|
97
|
+
);
|
98
|
+
return data.map<MappedStake>(sp => {
|
99
|
+
const rank = validators.findIndex(v => v.suiAddress === sp.validatorAddress);
|
100
|
+
const validator = validators[rank] ?? sp;
|
101
|
+
const formatConfig = {
|
102
|
+
disableRounding: false,
|
103
|
+
alwaysShowSign: false,
|
104
|
+
showCode: true,
|
105
|
+
};
|
106
|
+
|
107
|
+
return {
|
108
|
+
...sp,
|
109
|
+
rank,
|
110
|
+
validator,
|
111
|
+
stakedSuiId: sp.stakedSuiId,
|
112
|
+
formattedAmount: formatCurrencyUnit(unit, BigNumber(sp.principal), formatConfig),
|
113
|
+
};
|
114
|
+
});
|
115
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { fromAccountRaw } from "../../account/serialization";
|
2
2
|
import { TronAccount } from "@ledgerhq/coin-tron/types/index";
|
3
3
|
import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
|
4
|
-
import { CryptoAssetsStore } from "@ledgerhq/
|
4
|
+
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
5
5
|
|
6
6
|
export const __NEXT_REWARD_DATE__ = new Date(Date.now() - 6 * 60 * 60 * 1000);
|
7
7
|
|
@@ -144,6 +144,7 @@ export type MarketItemResponse = {
|
|
144
144
|
circulatingSupply: number;
|
145
145
|
fullyDilutedValuation: number;
|
146
146
|
high24h: number;
|
147
|
+
currencyId: string;
|
147
148
|
id: string;
|
148
149
|
image: string;
|
149
150
|
ledgerIds: string[];
|
@@ -167,6 +168,9 @@ export type MarketItemResponse = {
|
|
167
168
|
totalVolume: number;
|
168
169
|
updatedAt: string;
|
169
170
|
};
|
171
|
+
|
172
|
+
export type PartialMarketItemResponse = Partial<MarketItemResponse>;
|
173
|
+
|
170
174
|
export type MarketItemPerformer = {
|
171
175
|
id: string;
|
172
176
|
name: string;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
|
2
1
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { getCryptoCurrencyById } from "../../currencies";
|
3
3
|
|
4
4
|
export const mockBtcCryptoCurrency = getCryptoCurrencyById("bitcoin");
|
5
5
|
export const mockEthCryptoCurrency = getCryptoCurrencyById("ethereum");
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import type { ApiAsset } from "@ledgerhq/cryptoassets";
|
3
|
+
import { PartialMarketItemResponse } from "@ledgerhq/live-common/market/utils/types";
|
4
|
+
|
5
|
+
// Types for crypto asset metadata
|
6
|
+
export interface CryptoAssetMeta {
|
7
|
+
/** Asset identifier */
|
8
|
+
id: string;
|
9
|
+
/** Asset ticker symbol */
|
10
|
+
ticker: string;
|
11
|
+
/** Asset display name */
|
12
|
+
name: string;
|
13
|
+
/** Map of network IDs to their corresponding asset IDs */
|
14
|
+
assetsIds: Record<string, string>;
|
15
|
+
}
|
16
|
+
|
17
|
+
// Types for network information
|
18
|
+
export interface NetworkInfo {
|
19
|
+
/** Network identifier */
|
20
|
+
id: string;
|
21
|
+
/** Network display name */
|
22
|
+
name: string;
|
23
|
+
}
|
24
|
+
|
25
|
+
// Types for interest rate data
|
26
|
+
export interface InterestRate {
|
27
|
+
/** Currency identifier */
|
28
|
+
currencyId: string;
|
29
|
+
/** Interest rate value */
|
30
|
+
rate: number;
|
31
|
+
/** Type of rate (NRR, APR, APY, etc.) */
|
32
|
+
type: string;
|
33
|
+
/** Timestamp when the rate was fetched */
|
34
|
+
fetchAt: string;
|
35
|
+
}
|
36
|
+
|
37
|
+
// Types for currency ordering
|
38
|
+
export interface CurrenciesOrder {
|
39
|
+
/** Sorting key (e.g., "marketCap") */
|
40
|
+
key: string;
|
41
|
+
/** Sort order (e.g., "desc") */
|
42
|
+
order: string;
|
43
|
+
/** Ordered list of currency IDs */
|
44
|
+
currenciesIds: string[];
|
45
|
+
/** Ordered list of meta-currency IDs */
|
46
|
+
metaCurrencyIds: string[];
|
47
|
+
}
|
48
|
+
|
49
|
+
// Types for raw API response (before transformation)
|
50
|
+
export interface RawApiResponse {
|
51
|
+
/** Grouped crypto assets by meta-currency */
|
52
|
+
cryptoAssets: Record<string, CryptoAssetMeta>;
|
53
|
+
/** Network information */
|
54
|
+
networks: Record<string, NetworkInfo>;
|
55
|
+
/** Raw crypto currencies and token currencies from API */
|
56
|
+
cryptoOrTokenCurrencies: Record<string, ApiAsset>;
|
57
|
+
/** Interest rates for various currencies */
|
58
|
+
interestRates: Record<string, InterestRate>;
|
59
|
+
/** Market data for currencies */
|
60
|
+
markets: Record<string, PartialMarketItemResponse>;
|
61
|
+
/** Currency ordering information */
|
62
|
+
currenciesOrder: CurrenciesOrder;
|
63
|
+
}
|
64
|
+
|
65
|
+
// Types for transformed API response (after transformation)
|
66
|
+
export interface AssetsData {
|
67
|
+
/** Grouped crypto assets by meta-currency */
|
68
|
+
cryptoAssets: Record<string, CryptoAssetMeta>;
|
69
|
+
/** Network information */
|
70
|
+
networks: Record<string, NetworkInfo>;
|
71
|
+
/** Transformed crypto currencies and token currencies compatible with Ledger Live */
|
72
|
+
cryptoOrTokenCurrencies: Record<string, CryptoOrTokenCurrency>;
|
73
|
+
/** Interest rates for various currencies */
|
74
|
+
interestRates: Record<string, InterestRate>;
|
75
|
+
/** Market data for currencies */
|
76
|
+
markets: Record<string, PartialMarketItemResponse>;
|
77
|
+
/** Currency ordering information */
|
78
|
+
currenciesOrder: CurrenciesOrder;
|
79
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { createApi, fetchBaseQuery, FetchBaseQueryMeta } from "@reduxjs/toolkit/query/react";
|
2
|
+
import { convertApiAssets } from "@ledgerhq/cryptoassets";
|
3
|
+
import { AssetsData, RawApiResponse } from "../entities";
|
4
|
+
import { getEnv } from "@ledgerhq/live-env";
|
5
|
+
|
6
|
+
export enum AssetsDataTags {
|
7
|
+
Assets = "Assets",
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface GetAssetsDataParams {
|
11
|
+
search?: string;
|
12
|
+
currencyIds?: string[];
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface PageParam {
|
16
|
+
cursor?: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface AssetsDataWithPagination extends AssetsData {
|
20
|
+
pagination: {
|
21
|
+
nextCursor?: string;
|
22
|
+
};
|
23
|
+
}
|
24
|
+
|
25
|
+
function transformAssetsResponse(
|
26
|
+
response: RawApiResponse,
|
27
|
+
meta?: FetchBaseQueryMeta,
|
28
|
+
): AssetsDataWithPagination {
|
29
|
+
const enrichedCryptoOrTokenCurrencies = convertApiAssets(response.cryptoOrTokenCurrencies);
|
30
|
+
|
31
|
+
const nextCursor = meta?.response?.headers.get("x-ledger-next") || undefined;
|
32
|
+
|
33
|
+
return {
|
34
|
+
...response,
|
35
|
+
cryptoOrTokenCurrencies: enrichedCryptoOrTokenCurrencies,
|
36
|
+
pagination: {
|
37
|
+
nextCursor,
|
38
|
+
},
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
export const assetsDataApi = createApi({
|
43
|
+
reducerPath: "assetsDataApi",
|
44
|
+
baseQuery: fetchBaseQuery({
|
45
|
+
baseUrl: __DEV__ ? getEnv("DADA_API_STAGING") : getEnv("DADA_API_PROD"),
|
46
|
+
}),
|
47
|
+
tagTypes: [AssetsDataTags.Assets],
|
48
|
+
endpoints: build => ({
|
49
|
+
getAssetsData: build.infiniteQuery<AssetsDataWithPagination, GetAssetsDataParams, PageParam>({
|
50
|
+
query: ({ pageParam, queryArg }) => {
|
51
|
+
const params = {
|
52
|
+
pageSize: 100,
|
53
|
+
...(pageParam?.cursor && { cursor: pageParam.cursor }),
|
54
|
+
// ...(queryArg?.currencyIds && queryArg?.currencyIds.length > 0 && { currencyIds: queryArg.currencyIds }),
|
55
|
+
...(queryArg?.search && { search: queryArg.search }),
|
56
|
+
};
|
57
|
+
|
58
|
+
return {
|
59
|
+
url: "assets",
|
60
|
+
params,
|
61
|
+
};
|
62
|
+
},
|
63
|
+
providesTags: [AssetsDataTags.Assets],
|
64
|
+
transformResponse: transformAssetsResponse,
|
65
|
+
infiniteQueryOptions: {
|
66
|
+
initialPageParam: {
|
67
|
+
cursor: "",
|
68
|
+
},
|
69
|
+
getNextPageParam: lastPage => {
|
70
|
+
if (lastPage.pagination.nextCursor) {
|
71
|
+
return {
|
72
|
+
cursor: lastPage.pagination.nextCursor,
|
73
|
+
};
|
74
|
+
} else {
|
75
|
+
return undefined;
|
76
|
+
}
|
77
|
+
},
|
78
|
+
},
|
79
|
+
}),
|
80
|
+
}),
|
81
|
+
});
|
82
|
+
|
83
|
+
export const { useGetAssetsDataInfiniteQuery } = assetsDataApi;
|
@@ -0,0 +1,200 @@
|
|
1
|
+
/**
|
2
|
+
* @jest-environment jsdom
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { renderHook } from "@testing-library/react";
|
6
|
+
import { useAssetsData } from "../useAssetsData";
|
7
|
+
import { useGetAssetsDataInfiniteQuery } from "../../data/state-manager/api";
|
8
|
+
|
9
|
+
jest.mock("../../data/state-manager/api", () => ({
|
10
|
+
useGetAssetsDataInfiniteQuery: jest.fn(),
|
11
|
+
}));
|
12
|
+
|
13
|
+
const mockuseGetAssetsDataInfiniteQuery = jest.mocked(useGetAssetsDataInfiniteQuery);
|
14
|
+
|
15
|
+
const defaultMockValues = {
|
16
|
+
data: undefined,
|
17
|
+
isLoading: false,
|
18
|
+
error: undefined,
|
19
|
+
fetchNextPage: jest.fn(),
|
20
|
+
isSuccess: true,
|
21
|
+
isFetching: false,
|
22
|
+
isError: false,
|
23
|
+
fetchPreviousPage: jest.fn(),
|
24
|
+
isFetchingPreviousPage: false,
|
25
|
+
refetch: jest.fn(),
|
26
|
+
status: "success",
|
27
|
+
};
|
28
|
+
|
29
|
+
describe("useAssetsData", () => {
|
30
|
+
beforeEach(() => {
|
31
|
+
jest.clearAllMocks();
|
32
|
+
});
|
33
|
+
|
34
|
+
it("should return loading state when API is loading", () => {
|
35
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
36
|
+
...defaultMockValues,
|
37
|
+
isLoading: true,
|
38
|
+
status: "pending",
|
39
|
+
});
|
40
|
+
|
41
|
+
const { result } = renderHook(() => useAssetsData({}));
|
42
|
+
|
43
|
+
expect(result.current.isLoading).toBe(true);
|
44
|
+
expect(result.current.data).toBe(undefined);
|
45
|
+
});
|
46
|
+
|
47
|
+
it("should return combined data from multiple pages", () => {
|
48
|
+
const mockPages = [
|
49
|
+
{
|
50
|
+
cryptoAssets: { bitcoin: { id: "bitcoin", name: "Bitcoin" } },
|
51
|
+
networks: { bitcoin: { id: "bitcoin", name: "Bitcoin" } },
|
52
|
+
cryptoOrTokenCurrencies: { bitcoin: { id: "bitcoin" } },
|
53
|
+
interestRates: {},
|
54
|
+
markets: {},
|
55
|
+
currenciesOrder: {
|
56
|
+
currenciesIds: ["bitcoin"],
|
57
|
+
metaCurrencyIds: ["bitcoin"],
|
58
|
+
key: "marketCap",
|
59
|
+
order: "desc",
|
60
|
+
},
|
61
|
+
pagination: { nextCursor: "cursor-2" },
|
62
|
+
},
|
63
|
+
{
|
64
|
+
cryptoAssets: { ethereum: { id: "ethereum", name: "Ethereum" } },
|
65
|
+
networks: { ethereum: { id: "ethereum", name: "Ethereum" } },
|
66
|
+
cryptoOrTokenCurrencies: { ethereum: { id: "ethereum" } },
|
67
|
+
interestRates: {},
|
68
|
+
markets: {},
|
69
|
+
currenciesOrder: {
|
70
|
+
currenciesIds: ["ethereum"],
|
71
|
+
metaCurrencyIds: ["ethereum"],
|
72
|
+
key: "marketCap",
|
73
|
+
order: "desc",
|
74
|
+
},
|
75
|
+
pagination: { nextCursor: undefined },
|
76
|
+
},
|
77
|
+
];
|
78
|
+
|
79
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
80
|
+
...defaultMockValues,
|
81
|
+
data: { pages: mockPages, pageParams: [{ cursor: "" }, { cursor: "cursor-2" }] },
|
82
|
+
});
|
83
|
+
|
84
|
+
const { result } = renderHook(() => useAssetsData({}));
|
85
|
+
|
86
|
+
expect(result.current.data).toEqual({
|
87
|
+
cryptoAssets: {
|
88
|
+
bitcoin: { id: "bitcoin", name: "Bitcoin" },
|
89
|
+
ethereum: { id: "ethereum", name: "Ethereum" },
|
90
|
+
},
|
91
|
+
networks: {
|
92
|
+
bitcoin: { id: "bitcoin", name: "Bitcoin" },
|
93
|
+
ethereum: { id: "ethereum", name: "Ethereum" },
|
94
|
+
},
|
95
|
+
cryptoOrTokenCurrencies: {
|
96
|
+
bitcoin: { id: "bitcoin" },
|
97
|
+
ethereum: { id: "ethereum" },
|
98
|
+
},
|
99
|
+
interestRates: {},
|
100
|
+
markets: {},
|
101
|
+
currenciesOrder: {
|
102
|
+
currenciesIds: ["bitcoin", "ethereum"],
|
103
|
+
metaCurrencyIds: ["bitcoin", "ethereum"],
|
104
|
+
key: "marketCap",
|
105
|
+
order: "desc",
|
106
|
+
},
|
107
|
+
pagination: { nextCursor: undefined },
|
108
|
+
});
|
109
|
+
expect(result.current.isLoading).toBe(false);
|
110
|
+
});
|
111
|
+
|
112
|
+
it("should return error when API has error", () => {
|
113
|
+
const mockError = new Error("API Error");
|
114
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
115
|
+
...defaultMockValues,
|
116
|
+
data: undefined,
|
117
|
+
error: mockError,
|
118
|
+
isSuccess: false,
|
119
|
+
isError: true,
|
120
|
+
status: "error",
|
121
|
+
});
|
122
|
+
|
123
|
+
const { result } = renderHook(() => useAssetsData({}));
|
124
|
+
|
125
|
+
expect(result.current.error).toBe(mockError);
|
126
|
+
expect(result.current.isLoading).toBe(false);
|
127
|
+
});
|
128
|
+
|
129
|
+
it("should provide loadNext function when there's a nextCursor", () => {
|
130
|
+
const mockFetchNextPage = jest.fn();
|
131
|
+
const mockPages = [
|
132
|
+
{
|
133
|
+
cryptoAssets: {},
|
134
|
+
networks: {},
|
135
|
+
cryptoOrTokenCurrencies: {},
|
136
|
+
interestRates: {},
|
137
|
+
markets: {},
|
138
|
+
currenciesOrder: {
|
139
|
+
currenciesIds: [],
|
140
|
+
metaCurrencyIds: [],
|
141
|
+
key: "marketCap",
|
142
|
+
order: "desc",
|
143
|
+
},
|
144
|
+
pagination: { nextCursor: "next-cursor-456" },
|
145
|
+
},
|
146
|
+
];
|
147
|
+
|
148
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
149
|
+
...defaultMockValues,
|
150
|
+
data: { pages: mockPages, pageParams: [{ cursor: "" }] },
|
151
|
+
fetchNextPage: mockFetchNextPage,
|
152
|
+
});
|
153
|
+
|
154
|
+
const { result } = renderHook(() => useAssetsData({}));
|
155
|
+
|
156
|
+
expect(result.current.loadNext).toBeDefined();
|
157
|
+
result.current.loadNext?.();
|
158
|
+
|
159
|
+
expect(mockFetchNextPage).toHaveBeenCalled();
|
160
|
+
});
|
161
|
+
|
162
|
+
it("should not provide loadNext function when there's no nextCursor", () => {
|
163
|
+
const mockPages = [
|
164
|
+
{
|
165
|
+
cryptoAssets: {},
|
166
|
+
networks: {},
|
167
|
+
cryptoOrTokenCurrencies: {},
|
168
|
+
interestRates: {},
|
169
|
+
markets: {},
|
170
|
+
currenciesOrder: {
|
171
|
+
currenciesIds: [],
|
172
|
+
metaCurrencyIds: [],
|
173
|
+
key: "marketCap",
|
174
|
+
order: "desc",
|
175
|
+
},
|
176
|
+
pagination: { nextCursor: undefined },
|
177
|
+
},
|
178
|
+
];
|
179
|
+
|
180
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
181
|
+
...defaultMockValues,
|
182
|
+
data: { pages: mockPages, pageParams: [{ cursor: "" }] },
|
183
|
+
});
|
184
|
+
|
185
|
+
const { result } = renderHook(() => useAssetsData({}));
|
186
|
+
|
187
|
+
expect(result.current.loadNext).toBeUndefined();
|
188
|
+
});
|
189
|
+
|
190
|
+
it("should return undefined data when no pages exist", () => {
|
191
|
+
mockuseGetAssetsDataInfiniteQuery.mockReturnValue({
|
192
|
+
...defaultMockValues,
|
193
|
+
});
|
194
|
+
|
195
|
+
const { result } = renderHook(() => useAssetsData({}));
|
196
|
+
|
197
|
+
expect(result.current.data).toBeUndefined();
|
198
|
+
expect(result.current.loadNext).toBeUndefined();
|
199
|
+
});
|
200
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { Observable } from "rxjs";
|
2
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { getAccountTuplesForCurrency } from "../../../utils/getAccountTuplesForCurrency";
|
4
|
+
import type { Account } from "@ledgerhq/types-live";
|
5
|
+
import { WalletAPIAccount } from "../../../wallet-api/types";
|
6
|
+
|
7
|
+
type AccountModuleParams = {
|
8
|
+
assets: CryptoOrTokenCurrency[];
|
9
|
+
nestedAccounts: Account[];
|
10
|
+
accountIds: Map<string, boolean> | undefined;
|
11
|
+
formatLabel: (count: number) => string;
|
12
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
13
|
+
};
|
14
|
+
|
15
|
+
export type AssetCountItem = {
|
16
|
+
asset: CryptoOrTokenCurrency;
|
17
|
+
label: string;
|
18
|
+
count: number;
|
19
|
+
};
|
20
|
+
|
21
|
+
export const useAssetAccountCounts = ({
|
22
|
+
assets,
|
23
|
+
nestedAccounts,
|
24
|
+
accountIds,
|
25
|
+
formatLabel,
|
26
|
+
}: AccountModuleParams): AssetCountItem[] =>
|
27
|
+
assets
|
28
|
+
.map(asset => {
|
29
|
+
const { length } = getAccountTuplesForCurrency(asset, nestedAccounts, accountIds);
|
30
|
+
return {
|
31
|
+
asset,
|
32
|
+
label: formatLabel(length),
|
33
|
+
count: length,
|
34
|
+
};
|
35
|
+
})
|
36
|
+
.sort((a, b) => b.count - a.count);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { ApyType } from "../../types";
|
4
|
+
|
5
|
+
const createApyItem = ({
|
6
|
+
value,
|
7
|
+
type,
|
8
|
+
ApyIndicator,
|
9
|
+
}: {
|
10
|
+
value: number;
|
11
|
+
type: ApyType;
|
12
|
+
ApyIndicator: React.ComponentType<{ value: number; type: ApyType }>;
|
13
|
+
}) => <ApyIndicator value={value} type={type} />;
|
14
|
+
|
15
|
+
export const useLeftApyModule = (
|
16
|
+
assets: CryptoOrTokenCurrency[],
|
17
|
+
ApyIndicator: React.ComponentType<{ value: number; type: ApyType }>,
|
18
|
+
) => {
|
19
|
+
const value = 5.11; // TODO to be retrieved from DADA
|
20
|
+
const type = "APY"; // TODO to be retrieved from DADA
|
21
|
+
|
22
|
+
return assets.map(asset => ({
|
23
|
+
...asset,
|
24
|
+
leftElement: createApyItem({ value, type, ApyIndicator }),
|
25
|
+
}));
|
26
|
+
};
|