@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
@@ -0,0 +1,165 @@
|
|
1
|
+
import { rangeDataTable } from "../../market/utils/rangeDataTable";
|
2
|
+
import { TFunction } from "i18next";
|
3
|
+
|
4
|
+
export const RANGES = Object.keys(rangeDataTable).filter(key => key !== "1h");
|
5
|
+
|
6
|
+
const indexes: [string, number][] = [
|
7
|
+
["d", 1],
|
8
|
+
["K", 1000],
|
9
|
+
["M", 1000000],
|
10
|
+
["B", 1000000000],
|
11
|
+
["T", 1000000000000],
|
12
|
+
["Q", 1000000000000000],
|
13
|
+
["Qn", 1000000000000000000],
|
14
|
+
];
|
15
|
+
|
16
|
+
const formatters: Record<string, { [key: string]: Intl.NumberFormat }> = {};
|
17
|
+
|
18
|
+
const getSanitizedValue = (currency: string | undefined, locale: string): string => {
|
19
|
+
if (currency) {
|
20
|
+
return `${formatters[locale][currency]
|
21
|
+
?.format(0)
|
22
|
+
.replace(/[0-9,.]+/, "***")
|
23
|
+
.trim()}`;
|
24
|
+
}
|
25
|
+
return "***";
|
26
|
+
};
|
27
|
+
|
28
|
+
const shouldReturnDash = (
|
29
|
+
value: number,
|
30
|
+
allowZeroValue: boolean,
|
31
|
+
discreetMode: boolean,
|
32
|
+
): boolean => {
|
33
|
+
return !discreetMode && (isNaN(value) || (!value && !allowZeroValue));
|
34
|
+
};
|
35
|
+
|
36
|
+
const ensureFormatterExists = (
|
37
|
+
locale: string,
|
38
|
+
currency: string | undefined,
|
39
|
+
decimalPlaces: number,
|
40
|
+
): void => {
|
41
|
+
if (!formatters[locale]) formatters[locale] = {};
|
42
|
+
|
43
|
+
if (currency && !formatters[locale]?.[currency]) {
|
44
|
+
createCurrencyFormatter(locale, currency, decimalPlaces);
|
45
|
+
} else if (!currency && !formatters[locale]?.[`decimal_${decimalPlaces}`]) {
|
46
|
+
createDecimalFormatter(locale, decimalPlaces);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
const createCurrencyFormatter = (locale: string, currency: string, decimalPlaces: number): void => {
|
51
|
+
try {
|
52
|
+
formatters[locale][currency] = new Intl.NumberFormat(locale, {
|
53
|
+
style: "currency",
|
54
|
+
currency,
|
55
|
+
});
|
56
|
+
} catch {
|
57
|
+
formatters[locale][currency] = new Intl.NumberFormat(locale, {
|
58
|
+
style: "decimal",
|
59
|
+
minimumFractionDigits: decimalPlaces,
|
60
|
+
maximumFractionDigits: 8,
|
61
|
+
});
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
const createDecimalFormatter = (locale: string, decimalPlaces: number): void => {
|
66
|
+
formatters[locale][`decimal_${decimalPlaces}`] = new Intl.NumberFormat(locale, {
|
67
|
+
style: "decimal",
|
68
|
+
minimumFractionDigits: decimalPlaces,
|
69
|
+
maximumFractionDigits: decimalPlaces,
|
70
|
+
});
|
71
|
+
};
|
72
|
+
|
73
|
+
const getFormatter = (
|
74
|
+
currency: string | undefined,
|
75
|
+
locale: string,
|
76
|
+
shorten: boolean | undefined,
|
77
|
+
decimalPlaces: number,
|
78
|
+
): Intl.NumberFormat | undefined => {
|
79
|
+
if (currency) {
|
80
|
+
return formatters[locale][currency];
|
81
|
+
}
|
82
|
+
|
83
|
+
if (shorten) {
|
84
|
+
return new Intl.NumberFormat(locale, {
|
85
|
+
notation: "compact",
|
86
|
+
maximumFractionDigits: 3,
|
87
|
+
minimumFractionDigits: Math.min(decimalPlaces, 3),
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
return formatters[locale][`decimal_${decimalPlaces}`];
|
92
|
+
};
|
93
|
+
|
94
|
+
const formatShortenedValue = (
|
95
|
+
value: number,
|
96
|
+
formatter: Intl.NumberFormat,
|
97
|
+
t: TFunction,
|
98
|
+
): string => {
|
99
|
+
const sign = value > 0 ? "" : "-";
|
100
|
+
const v = Math.abs(value);
|
101
|
+
const index = Math.floor(Math.log10(v) / 3) || 0;
|
102
|
+
const [i, n] = indexes[index] || ["", 1];
|
103
|
+
const roundedValue = Math.round((v / n) * 1000) / 1000;
|
104
|
+
const number = formatter.format(roundedValue);
|
105
|
+
const I = t(`numberCompactNotation.${i}`);
|
106
|
+
const formattedNumber = number.replace(/([0-9,. ]+)/, `${sign}$1 ${I}`);
|
107
|
+
return formattedNumber.trim();
|
108
|
+
};
|
109
|
+
|
110
|
+
const formatRegularValue = (
|
111
|
+
value: number,
|
112
|
+
formatter: Intl.NumberFormat,
|
113
|
+
ticker: string,
|
114
|
+
currency: string | undefined,
|
115
|
+
locale: string,
|
116
|
+
discreetMode: boolean,
|
117
|
+
): string => {
|
118
|
+
if (discreetMode) {
|
119
|
+
return getSanitizedValue(currency, locale);
|
120
|
+
}
|
121
|
+
|
122
|
+
const formattedValue = formatter.format(value);
|
123
|
+
const upperCaseTicker = ticker?.trim()?.toLocaleUpperCase();
|
124
|
+
return `${formattedValue} ${upperCaseTicker}`.trim();
|
125
|
+
};
|
126
|
+
|
127
|
+
export const counterValueFormatter = ({
|
128
|
+
currency,
|
129
|
+
value,
|
130
|
+
shorten,
|
131
|
+
locale,
|
132
|
+
t,
|
133
|
+
allowZeroValue = false,
|
134
|
+
ticker = "",
|
135
|
+
discreetMode = false,
|
136
|
+
decimalPlaces = 2,
|
137
|
+
}: {
|
138
|
+
currency?: string;
|
139
|
+
value: number;
|
140
|
+
shorten?: boolean;
|
141
|
+
locale: string;
|
142
|
+
t?: TFunction;
|
143
|
+
allowZeroValue?: boolean;
|
144
|
+
ticker?: string;
|
145
|
+
discreetMode?: boolean;
|
146
|
+
decimalPlaces?: number;
|
147
|
+
}): string => {
|
148
|
+
if (shouldReturnDash(value, allowZeroValue, discreetMode)) {
|
149
|
+
return "-";
|
150
|
+
}
|
151
|
+
|
152
|
+
ensureFormatterExists(locale, currency, decimalPlaces);
|
153
|
+
|
154
|
+
const formatter = getFormatter(currency, locale, shorten, decimalPlaces);
|
155
|
+
|
156
|
+
if (!formatter) {
|
157
|
+
return String(value);
|
158
|
+
}
|
159
|
+
|
160
|
+
if (shorten && t) {
|
161
|
+
return formatShortenedValue(value, formatter, t);
|
162
|
+
}
|
163
|
+
|
164
|
+
return formatRegularValue(value, formatter, ticker, currency, locale, discreetMode);
|
165
|
+
};
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/lib-es/currencies/formatCurrencyUnit";
|
2
|
+
import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
|
3
|
+
import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
|
4
|
+
import { groupAccountsByAsset, type GroupedAccount } from "./groupAccountsByAsset";
|
5
|
+
import { AssetType } from "./type";
|
6
|
+
import { AccountLike } from "@ledgerhq/types-live";
|
7
|
+
import { counterValueFormatter } from "./counterValueFormatter";
|
8
|
+
|
9
|
+
interface ExtendedAssetType extends AssetType {
|
10
|
+
balance?: string;
|
11
|
+
fiatValue?: string;
|
12
|
+
}
|
13
|
+
|
14
|
+
export const getBalanceAndFiatValueByAssets = (
|
15
|
+
accounts: AccountLike[],
|
16
|
+
assets: CryptoOrTokenCurrency[],
|
17
|
+
counterValuesState: CounterValuesState,
|
18
|
+
targetCurrency: Currency,
|
19
|
+
isDiscreetMode: boolean = false,
|
20
|
+
userLocale: string,
|
21
|
+
): ExtendedAssetType[] => {
|
22
|
+
const groupedAccountsByAsset = groupAccountsByAsset(
|
23
|
+
accounts,
|
24
|
+
counterValuesState,
|
25
|
+
targetCurrency,
|
26
|
+
isDiscreetMode,
|
27
|
+
);
|
28
|
+
|
29
|
+
return assets.map(asset => {
|
30
|
+
const assetGroup = groupedAccountsByAsset[asset.id];
|
31
|
+
|
32
|
+
if (assetGroup) {
|
33
|
+
return formatAssetDetails(assetGroup, asset, targetCurrency, isDiscreetMode, userLocale);
|
34
|
+
}
|
35
|
+
|
36
|
+
return {
|
37
|
+
id: asset.id,
|
38
|
+
name: asset.name,
|
39
|
+
ticker: asset.ticker,
|
40
|
+
};
|
41
|
+
});
|
42
|
+
};
|
43
|
+
|
44
|
+
const formatAssetDetails = (
|
45
|
+
assetGroup: GroupedAccount,
|
46
|
+
asset: CryptoOrTokenCurrency,
|
47
|
+
targetCurrency: Currency,
|
48
|
+
isDiscreetMode: boolean,
|
49
|
+
userLocale: string,
|
50
|
+
): ExtendedAssetType => {
|
51
|
+
const assetDetails =
|
52
|
+
assetGroup.accounts[0].type === "Account"
|
53
|
+
? assetGroup.accounts[0].currency
|
54
|
+
: assetGroup.accounts[0].token;
|
55
|
+
|
56
|
+
const formattedBalance = formatCurrencyUnit(assetDetails.units[0], assetGroup.totalBalance, {
|
57
|
+
showCode: true,
|
58
|
+
discreet: isDiscreetMode,
|
59
|
+
});
|
60
|
+
|
61
|
+
const formattedFiatValue = counterValueFormatter({
|
62
|
+
currency: targetCurrency.ticker,
|
63
|
+
value: assetGroup.totalFiatValue.toNumber(),
|
64
|
+
locale: userLocale,
|
65
|
+
allowZeroValue: true,
|
66
|
+
discreetMode: isDiscreetMode,
|
67
|
+
});
|
68
|
+
|
69
|
+
return {
|
70
|
+
id: asset.id,
|
71
|
+
name: asset.name,
|
72
|
+
ticker: asset.ticker,
|
73
|
+
balance: formattedBalance,
|
74
|
+
fiatValue: formattedFiatValue,
|
75
|
+
};
|
76
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { getTokenOrCryptoCurrencyById } from "../../deposit/helper";
|
3
|
+
|
4
|
+
export const getProviderCurrency = (
|
5
|
+
mainCurrency: CryptoOrTokenCurrency,
|
6
|
+
currencies: CryptoOrTokenCurrency[],
|
7
|
+
) => {
|
8
|
+
try {
|
9
|
+
return getTokenOrCryptoCurrencyById(mainCurrency.id);
|
10
|
+
} catch {
|
11
|
+
return getTokenOrCryptoCurrencyById(currencies[0].id);
|
12
|
+
}
|
13
|
+
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { getBalanceAndFiatValue } from "./getBalanceAndFiatValue";
|
2
|
+
import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
|
3
|
+
import { Currency } from "@ledgerhq/types-cryptoassets";
|
4
|
+
import { AccountLike } from "@ledgerhq/types-live";
|
5
|
+
import BigNumber from "bignumber.js";
|
6
|
+
import { parseToBigNumber } from "./parseToBigNumber";
|
7
|
+
|
8
|
+
export type GroupedAccount = {
|
9
|
+
totalBalance: BigNumber;
|
10
|
+
totalFiatValue: BigNumber;
|
11
|
+
accounts: AccountLike[];
|
12
|
+
};
|
13
|
+
|
14
|
+
export const groupAccountsByAsset = (
|
15
|
+
accounts: AccountLike[],
|
16
|
+
counterValuesState: CounterValuesState,
|
17
|
+
targetCurrency: Currency,
|
18
|
+
isDiscreetMode: boolean,
|
19
|
+
): Record<string, GroupedAccount> => {
|
20
|
+
const initialGroupedAccounts: Record<string, GroupedAccount> = {};
|
21
|
+
|
22
|
+
return accounts.reduce((groupedAccounts, account) => {
|
23
|
+
const assetId = account.type === "Account" ? account.currency.id : account.token.id;
|
24
|
+
|
25
|
+
if (!groupedAccounts[assetId]) {
|
26
|
+
groupedAccounts[assetId] = {
|
27
|
+
totalBalance: new BigNumber(0),
|
28
|
+
totalFiatValue: new BigNumber(0),
|
29
|
+
accounts: [],
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
const { fiatValue } = getBalanceAndFiatValue(
|
34
|
+
account,
|
35
|
+
counterValuesState,
|
36
|
+
targetCurrency,
|
37
|
+
isDiscreetMode,
|
38
|
+
false,
|
39
|
+
);
|
40
|
+
const balance = account.balance;
|
41
|
+
|
42
|
+
const parsedFiatValue = parseToBigNumber(fiatValue ?? "0");
|
43
|
+
|
44
|
+
groupedAccounts[assetId].totalBalance = groupedAccounts[assetId].totalBalance.plus(balance);
|
45
|
+
groupedAccounts[assetId].totalFiatValue =
|
46
|
+
groupedAccounts[assetId].totalFiatValue.plus(parsedFiatValue);
|
47
|
+
groupedAccounts[assetId].accounts.push(account);
|
48
|
+
|
49
|
+
return groupedAccounts;
|
50
|
+
}, initialGroupedAccounts);
|
51
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
*
|
5
|
+
* @param value - The value to parse into a BigNumber. It can be a string, number, or an existing BigNumber instance.
|
6
|
+
* @template T - The type of the value, which can be string, number, or BigNumber.
|
7
|
+
* @returns A BigNumber instance representing the parsed value.
|
8
|
+
*/
|
9
|
+
export const parseToBigNumber = <T extends string | number | BigNumber>(value: T): BigNumber => {
|
10
|
+
if (value instanceof BigNumber) {
|
11
|
+
return value;
|
12
|
+
}
|
13
|
+
if (typeof value === "string") {
|
14
|
+
return new BigNumber(value.replace(/,/g, ""));
|
15
|
+
}
|
16
|
+
return new BigNumber(value);
|
17
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export type AssetType = {
|
2
|
+
name: string;
|
3
|
+
ticker: string;
|
4
|
+
id: string;
|
5
|
+
leftElement?: React.ReactNode;
|
6
|
+
rightElement?: React.ReactNode;
|
7
|
+
};
|
8
|
+
|
9
|
+
export type ProviderBalanceAsset = {
|
10
|
+
id: string;
|
11
|
+
name: string;
|
12
|
+
ticker: string;
|
13
|
+
balance: string;
|
14
|
+
fiatValue: string;
|
15
|
+
sortValue: number;
|
16
|
+
};
|
17
|
+
|
18
|
+
export type ProviderBalanceResultsMap = Map<string, ProviderBalanceAsset>;
|
19
|
+
|
20
|
+
export type AssetWithBalance = AssetType & {
|
21
|
+
sortValue?: number;
|
22
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
2
|
-
import { genAccount } from "
|
2
|
+
import { genAccount } from "../../mock/account";
|
3
3
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
4
4
|
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
5
5
|
import { getAccountTuplesForCurrency } from "../getAccountTuplesForCurrency";
|
@@ -24,6 +24,16 @@ export function createWrongSellParams(params: unknown): ExchangeErrorData {
|
|
24
24
|
};
|
25
25
|
}
|
26
26
|
|
27
|
+
export function createWrongFundParams(params: unknown): ExchangeErrorData {
|
28
|
+
return {
|
29
|
+
code: "WRONG_FUND_PARAMS",
|
30
|
+
message: "fund params are not correctly set",
|
31
|
+
data: {
|
32
|
+
params,
|
33
|
+
},
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
27
37
|
export function createAccounIdNotFound(accountId: string): ExchangeErrorData {
|
28
38
|
return {
|
29
39
|
code: "ACCOUNT_ID_NOT_FOUND",
|
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
ExchangeStartParams,
|
4
4
|
ExchangeStartSellParams,
|
5
5
|
ExchangeStartSwapParams,
|
6
|
+
ExchangeStartFundParams,
|
6
7
|
} from "@ledgerhq/wallet-api-exchange-module";
|
7
8
|
import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
|
8
9
|
import { of } from "rxjs";
|
@@ -153,8 +154,10 @@ describe("handlers", () => {
|
|
153
154
|
uiHooks: mockUiHooks,
|
154
155
|
});
|
155
156
|
|
156
|
-
const params:
|
157
|
+
const params: ExchangeStartFundParams = {
|
157
158
|
exchangeType: "FUND",
|
159
|
+
provider: "TestFundProvider",
|
160
|
+
fromAccountId: accounts[0].id,
|
158
161
|
};
|
159
162
|
const { request, context, walletHandlers } = prepareSellRequest(params);
|
160
163
|
|
@@ -170,6 +173,7 @@ describe("handlers", () => {
|
|
170
173
|
expect(mockUiStartExchange).toHaveBeenCalledTimes(1);
|
171
174
|
const receivedParams = mockUiStartExchange.mock.calls[0][0].exchangeParams;
|
172
175
|
expect(receivedParams.exchangeType).toBe("FUND");
|
176
|
+
expect(receivedParams.provider).toBe("TestFundProvider");
|
173
177
|
expect(mockUiCompleteExchange).not.toHaveBeenCalled();
|
174
178
|
});
|
175
179
|
});
|
@@ -22,6 +22,7 @@ import {
|
|
22
22
|
ExchangeStartResult,
|
23
23
|
ExchangeStartSellParams,
|
24
24
|
ExchangeStartSwapParams,
|
25
|
+
ExchangeStartFundParams,
|
25
26
|
ExchangeSwapParams,
|
26
27
|
ExchangeType,
|
27
28
|
SwapLiveError,
|
@@ -44,6 +45,7 @@ import {
|
|
44
45
|
createAccounIdNotFound,
|
45
46
|
createWrongSellParams,
|
46
47
|
createWrongSwapParams,
|
48
|
+
createWrongFundParams,
|
47
49
|
ExchangeError,
|
48
50
|
} from "./error";
|
49
51
|
import { TrackingAPI } from "./tracking";
|
@@ -82,6 +84,8 @@ export type CompleteExchangeUiRequest = {
|
|
82
84
|
};
|
83
85
|
type FundStartParamsUiRequest = {
|
84
86
|
exchangeType: "FUND";
|
87
|
+
provider: string;
|
88
|
+
exchange: Partial<Exchange> | undefined;
|
85
89
|
};
|
86
90
|
|
87
91
|
type SellStartParamsUiRequest = {
|
@@ -158,8 +162,6 @@ export const handlers = ({
|
|
158
162
|
}
|
159
163
|
|
160
164
|
const trackingParams = {
|
161
|
-
// @ts-expect-error ExchangeStartFundParams does not yet have the provider. Will be added in another iteration after a bugfix is confirmed
|
162
|
-
// TODO: expect-error to be deleted after
|
163
165
|
provider: params.provider,
|
164
166
|
exchangeType: params.exchangeType,
|
165
167
|
};
|
@@ -174,9 +176,7 @@ export const handlers = ({
|
|
174
176
|
} else if (params.exchangeType == "SELL") {
|
175
177
|
exchangeParams = extractSellStartParam(params, accounts);
|
176
178
|
} else {
|
177
|
-
exchangeParams =
|
178
|
-
exchangeType: params.exchangeType,
|
179
|
-
};
|
179
|
+
exchangeParams = extractFundStartParam(params, accounts);
|
180
180
|
}
|
181
181
|
|
182
182
|
return new Promise((resolve, reject) =>
|
@@ -711,6 +711,45 @@ function extractSellStartParam(
|
|
711
711
|
};
|
712
712
|
}
|
713
713
|
|
714
|
+
function extractFundStartParam(
|
715
|
+
params: ExchangeStartFundParams,
|
716
|
+
accounts: AccountLike[],
|
717
|
+
): ExchangeStartParamsUiRequest {
|
718
|
+
if (!("provider" in params)) {
|
719
|
+
throw new ExchangeError(createWrongFundParams(params));
|
720
|
+
}
|
721
|
+
|
722
|
+
if (!params.fromAccountId) {
|
723
|
+
return {
|
724
|
+
exchangeType: params.exchangeType,
|
725
|
+
provider: params.provider,
|
726
|
+
} as ExchangeStartParamsUiRequest;
|
727
|
+
}
|
728
|
+
|
729
|
+
const realFromAccountId = getAccountIdFromWalletAccountId(params?.fromAccountId);
|
730
|
+
|
731
|
+
if (!realFromAccountId) {
|
732
|
+
throw new ExchangeError(createAccounIdNotFound(params.fromAccountId));
|
733
|
+
}
|
734
|
+
|
735
|
+
const fromAccount = accounts?.find(acc => acc.id === realFromAccountId);
|
736
|
+
|
737
|
+
if (!fromAccount) {
|
738
|
+
throw new ServerError(createAccountNotFound(params.fromAccountId));
|
739
|
+
}
|
740
|
+
|
741
|
+
const fromParentAccount = getParentAccount(fromAccount, accounts);
|
742
|
+
|
743
|
+
return {
|
744
|
+
exchangeType: params.exchangeType,
|
745
|
+
provider: params.provider,
|
746
|
+
exchange: {
|
747
|
+
fromAccount,
|
748
|
+
fromParentAccount,
|
749
|
+
},
|
750
|
+
};
|
751
|
+
}
|
752
|
+
|
714
753
|
async function getToCurrency(
|
715
754
|
binaryPayload: string,
|
716
755
|
toAccount: AccountLike,
|