@ledgerhq/live-common 34.43.0 → 34.44.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/DataModel.test.js +6 -0
- package/lib/DataModel.test.js.map +1 -1
- package/lib/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
- package/lib/__tests__/accounts/groupPerDay.js +10 -0
- package/lib/__tests__/accounts/groupPerDay.js.map +1 -1
- package/lib/__tests__/test-helpers/environment.js +1 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/setup.js +6 -0
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/serialization.test.js +17 -1
- package/lib/account/serialization.test.js.map +1 -1
- package/lib/appSupportsQuitApp.d.ts +1 -0
- package/lib/appSupportsQuitApp.d.ts.map +1 -1
- package/lib/appSupportsQuitApp.js +1 -0
- package/lib/appSupportsQuitApp.js.map +1 -1
- package/lib/appSupportsQuitApp.test.js +28 -3
- package/lib/appSupportsQuitApp.test.js.map +1 -1
- package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +5 -5
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +5 -6
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts +3 -2
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +6 -2
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/utils.test.js +20 -0
- package/lib/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib/currencies/sortByMarketcap.test.js +5 -0
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/e2e/enum/Currency.js +1 -1
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Provider.d.ts +1 -0
- package/lib/e2e/enum/Provider.d.ts.map +1 -1
- package/lib/e2e/enum/Provider.js +1 -0
- package/lib/e2e/enum/Provider.js.map +1 -1
- package/lib/e2e/index.d.ts +3 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +45 -15
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosCI.d.ts.map +1 -1
- package/lib/e2e/speculosCI.js +22 -4
- 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/families/bitcoin/satstack.test.js +6 -0
- package/lib/families/bitcoin/satstack.test.js.map +1 -1
- package/lib/families/canton/bridge.integration.test.d.ts +2 -0
- package/lib/families/canton/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/canton/bridge.integration.test.js +7 -0
- package/lib/families/canton/bridge.integration.test.js.map +1 -0
- package/lib/families/canton/config.d.ts +3 -0
- package/lib/families/canton/config.d.ts.map +1 -0
- package/lib/families/canton/config.js +14 -0
- package/lib/families/canton/config.js.map +1 -0
- package/lib/families/canton/logic.d.ts +2 -0
- package/lib/families/canton/logic.d.ts.map +1 -0
- package/lib/families/canton/logic.js +19 -0
- package/lib/families/canton/logic.js.map +1 -0
- package/lib/families/canton/setup.d.ts +27 -0
- package/lib/families/canton/setup.d.ts.map +1 -0
- package/lib/families/canton/setup.js +27 -0
- package/lib/families/canton/setup.js.map +1 -0
- package/lib/families/canton/types.d.ts +2 -0
- package/lib/families/canton/types.d.ts.map +1 -0
- package/lib/families/canton/types.js +19 -0
- package/lib/families/canton/types.js.map +1 -0
- package/lib/families/solana/bridge/mock-data.d.ts.map +1 -1
- package/lib/families/solana/bridge/mock-data.js +46 -316
- package/lib/families/solana/bridge/mock-data.js.map +1 -1
- package/lib/families/solana/bridge/mock.js +2 -2
- package/lib/families/solana/bridge/mock.js.map +1 -1
- package/lib/families/stellar/ui.d.ts +6 -0
- package/lib/families/stellar/ui.d.ts.map +1 -0
- package/lib/families/stellar/ui.js +18 -0
- package/lib/families/stellar/ui.js.map +1 -0
- package/lib/families/tron/data.mock.d.ts.map +1 -1
- package/lib/families/tron/data.mock.js +6 -0
- package/lib/families/tron/data.mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +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/generated/bridge/js.d.ts +1 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +40 -38
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +20 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/cli-transaction.js +42 -40
- package/lib/generated/cli-transaction.js.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +2 -0
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +38 -36
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/generated/hw-getAddress.d.ts +1 -0
- package/lib/generated/hw-getAddress.d.ts.map +1 -1
- package/lib/generated/hw-getAddress.js +42 -40
- package/lib/generated/hw-getAddress.js.map +1 -1
- package/lib/generated/specs.d.ts +2 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/generated/specs.js +40 -38
- package/lib/generated/specs.js.map +1 -1
- package/lib/generated/transaction.d.ts +8 -0
- package/lib/generated/transaction.d.ts.map +1 -1
- package/lib/generated/transaction.js +42 -40
- package/lib/generated/transaction.js.map +1 -1
- package/lib/generated/types.d.ts +5 -4
- package/lib/generated/types.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
- package/lib/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/accounts.mock.js +48 -0
- package/lib/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js +100 -0
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -0
- package/lib/modularDrawer/utils/currencyUtils.d.ts +10 -0
- package/lib/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
- package/lib/modularDrawer/utils/currencyUtils.js +74 -0
- package/lib/modularDrawer/utils/currencyUtils.js.map +1 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts +1 -1
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -1
- package/lib/utils/__tests__/composeHooks.test.d.ts +2 -0
- package/lib/utils/__tests__/composeHooks.test.d.ts.map +1 -0
- package/lib/utils/__tests__/composeHooks.test.js +35 -0
- package/lib/utils/__tests__/composeHooks.test.js.map +1 -0
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +104 -0
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
- package/lib/utils/composeHooks.d.ts +11 -0
- package/lib/utils/composeHooks.d.ts.map +1 -0
- package/lib/utils/composeHooks.js +25 -0
- package/lib/utils/composeHooks.js.map +1 -0
- package/lib/utils/getAccountTuplesForCurrency.d.ts +8 -0
- package/lib/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
- package/lib/utils/getAccountTuplesForCurrency.js +19 -0
- package/lib/utils/getAccountTuplesForCurrency.js.map +1 -0
- package/lib/wallet-api/helpers.d.ts +1 -0
- package/lib/wallet-api/helpers.d.ts.map +1 -1
- package/lib/wallet-api/helpers.js +16 -1
- package/lib/wallet-api/helpers.js.map +1 -1
- package/lib-es/DataModel.test.js +6 -0
- package/lib-es/DataModel.test.js.map +1 -1
- package/lib-es/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
- package/lib-es/__tests__/accounts/groupPerDay.js +10 -0
- package/lib-es/__tests__/accounts/groupPerDay.js.map +1 -1
- package/lib-es/__tests__/test-helpers/environment.js +1 -0
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/__tests__/test-helpers/setup.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/setup.js +6 -0
- package/lib-es/__tests__/test-helpers/setup.js.map +1 -1
- package/lib-es/account/serialization.test.js +15 -2
- package/lib-es/account/serialization.test.js.map +1 -1
- package/lib-es/appSupportsQuitApp.d.ts +1 -0
- package/lib-es/appSupportsQuitApp.d.ts.map +1 -1
- package/lib-es/appSupportsQuitApp.js +1 -0
- package/lib-es/appSupportsQuitApp.js.map +1 -1
- package/lib-es/appSupportsQuitApp.test.js +6 -1
- package/lib-es/appSupportsQuitApp.test.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +4 -4
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +6 -7
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts +3 -2
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +4 -1
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js +18 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib-es/currencies/sortByMarketcap.test.js +5 -0
- package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib-es/e2e/enum/Currency.js +1 -1
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Provider.d.ts +1 -0
- package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
- package/lib-es/e2e/enum/Provider.js +1 -0
- package/lib-es/e2e/enum/Provider.js.map +1 -1
- package/lib-es/e2e/index.d.ts +3 -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 +45 -15
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosCI.d.ts.map +1 -1
- package/lib-es/e2e/speculosCI.js +22 -4
- 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/families/bitcoin/satstack.test.js +6 -0
- package/lib-es/families/bitcoin/satstack.test.js.map +1 -1
- package/lib-es/families/canton/bridge.integration.test.d.ts +2 -0
- package/lib-es/families/canton/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/families/canton/bridge.integration.test.js +5 -0
- package/lib-es/families/canton/bridge.integration.test.js.map +1 -0
- package/lib-es/families/canton/config.d.ts +3 -0
- package/lib-es/families/canton/config.d.ts.map +1 -0
- package/lib-es/families/canton/config.js +11 -0
- package/lib-es/families/canton/config.js.map +1 -0
- package/lib-es/families/canton/logic.d.ts +2 -0
- package/lib-es/families/canton/logic.d.ts.map +1 -0
- package/lib-es/families/canton/logic.js +3 -0
- package/lib-es/families/canton/logic.js.map +1 -0
- package/lib-es/families/canton/setup.d.ts +27 -0
- package/lib-es/families/canton/setup.d.ts.map +1 -0
- package/lib-es/families/canton/setup.js +19 -0
- package/lib-es/families/canton/setup.js.map +1 -0
- package/lib-es/families/canton/types.d.ts +2 -0
- package/lib-es/families/canton/types.d.ts.map +1 -0
- package/lib-es/families/canton/types.js +3 -0
- package/lib-es/families/canton/types.js.map +1 -0
- package/lib-es/families/solana/bridge/mock-data.d.ts.map +1 -1
- package/lib-es/families/solana/bridge/mock-data.js +46 -316
- package/lib-es/families/solana/bridge/mock-data.js.map +1 -1
- package/lib-es/families/solana/bridge/mock.js +3 -3
- package/lib-es/families/solana/bridge/mock.js.map +1 -1
- package/lib-es/families/stellar/ui.d.ts +6 -0
- package/lib-es/families/stellar/ui.d.ts.map +1 -0
- package/lib-es/families/stellar/ui.js +14 -0
- package/lib-es/families/stellar/ui.js.map +1 -0
- package/lib-es/families/tron/data.mock.d.ts.map +1 -1
- package/lib-es/families/tron/data.mock.js +6 -0
- package/lib-es/families/tron/data.mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +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/generated/bridge/js.d.ts +1 -0
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +2 -0
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/generated/cli-transaction.d.ts +20 -0
- package/lib-es/generated/cli-transaction.d.ts.map +1 -1
- package/lib-es/generated/cli-transaction.js +2 -0
- package/lib-es/generated/cli-transaction.js.map +1 -1
- package/lib-es/generated/deviceTransactionConfig.d.ts +2 -0
- package/lib-es/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/generated/deviceTransactionConfig.js +2 -0
- package/lib-es/generated/deviceTransactionConfig.js.map +1 -1
- package/lib-es/generated/hw-getAddress.d.ts +1 -0
- package/lib-es/generated/hw-getAddress.d.ts.map +1 -1
- package/lib-es/generated/hw-getAddress.js +2 -0
- package/lib-es/generated/hw-getAddress.js.map +1 -1
- package/lib-es/generated/specs.d.ts +2 -0
- package/lib-es/generated/specs.d.ts.map +1 -1
- package/lib-es/generated/specs.js +2 -0
- package/lib-es/generated/specs.js.map +1 -1
- package/lib-es/generated/transaction.d.ts +8 -0
- package/lib-es/generated/transaction.d.ts.map +1 -1
- package/lib-es/generated/transaction.js +2 -0
- package/lib-es/generated/transaction.js.map +1 -1
- package/lib-es/generated/types.d.ts +5 -4
- package/lib-es/generated/types.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
- package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/accounts.mock.js +42 -0
- package/lib-es/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +98 -0
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts +10 -0
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/currencyUtils.js +65 -0
- package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts +1 -1
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -1
- package/lib-es/utils/__tests__/composeHooks.test.d.ts +2 -0
- package/lib-es/utils/__tests__/composeHooks.test.d.ts.map +1 -0
- package/lib-es/utils/__tests__/composeHooks.test.js +33 -0
- package/lib-es/utils/__tests__/composeHooks.test.js.map +1 -0
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +102 -0
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
- package/lib-es/utils/composeHooks.d.ts +11 -0
- package/lib-es/utils/composeHooks.d.ts.map +1 -0
- package/lib-es/utils/composeHooks.js +21 -0
- package/lib-es/utils/composeHooks.js.map +1 -0
- package/lib-es/utils/getAccountTuplesForCurrency.d.ts +8 -0
- package/lib-es/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
- package/lib-es/utils/getAccountTuplesForCurrency.js +15 -0
- package/lib-es/utils/getAccountTuplesForCurrency.js.map +1 -0
- package/lib-es/wallet-api/helpers.d.ts +1 -0
- package/lib-es/wallet-api/helpers.d.ts.map +1 -1
- package/lib-es/wallet-api/helpers.js +14 -0
- package/lib-es/wallet-api/helpers.js.map +1 -1
- package/package.json +40 -38
- package/src/DataModel.test.ts +8 -0
- package/src/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
- package/src/__tests__/accounts/groupPerDay.ts +13 -0
- package/src/__tests__/test-helpers/environment.ts +1 -0
- package/src/__tests__/test-helpers/setup.ts +8 -0
- package/src/account/serialization.test.ts +20 -2
- package/src/appSupportsQuitApp.test.ts +7 -1
- package/src/appSupportsQuitApp.ts +1 -0
- package/src/bridge/crypto-assets/index.ts +6 -6
- package/src/bridge/generic-alpaca/alpaca/index.ts +3 -3
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +3 -8
- package/src/bridge/generic-alpaca/getAccountShape.ts +6 -7
- package/src/bridge/generic-alpaca/signOperation.ts +1 -1
- package/src/bridge/generic-alpaca/utils.test.ts +19 -0
- package/src/bridge/generic-alpaca/utils.ts +7 -6
- package/src/currencies/sortByMarketcap.test.ts +7 -0
- package/src/e2e/enum/Currency.ts +1 -1
- package/src/e2e/enum/Provider.ts +1 -0
- package/src/e2e/speculos.ts +77 -21
- package/src/e2e/speculosCI.ts +32 -10
- package/src/families/bitcoin/satstack.test.ts +7 -0
- package/src/families/canton/bridge.integration.test.ts +6 -0
- package/src/families/canton/config.ts +12 -0
- package/src/families/canton/logic.ts +2 -0
- package/src/families/canton/setup.ts +34 -0
- package/src/families/canton/types.ts +2 -0
- package/src/families/solana/bridge/mock-data.ts +52 -316
- package/src/families/solana/bridge/mock.ts +3 -3
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +1930 -94
- package/src/families/stellar/ui.ts +15 -0
- package/src/families/tron/data.mock.ts +8 -0
- package/src/featureFlags/defaultFeatures.ts +1 -0
- package/src/generated/bridge/js.ts +2 -0
- package/src/generated/cli-transaction.ts +2 -0
- package/src/generated/deviceTransactionConfig.ts +2 -0
- package/src/generated/hw-getAddress.ts +2 -0
- package/src/generated/specs.ts +2 -0
- package/src/generated/transaction.ts +2 -0
- package/src/generated/types.ts +10 -0
- package/src/modularDrawer/__mocks__/accounts.mock.ts +43 -0
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +126 -0
- package/src/modularDrawer/utils/currencyUtils.ts +95 -0
- package/src/modularDrawer/utils/haveOneCommonProvider.ts +1 -1
- package/src/utils/__tests__/composeHooks.test.ts +46 -0
- package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +138 -0
- package/src/utils/composeHooks.ts +26 -0
- package/src/utils/getAccountTuplesForCurrency.ts +34 -0
- package/src/wallet-api/helpers.ts +16 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
import { StellarOperationExtra } from "./types";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Format stellar memo value for display.
|
5
|
+
*/
|
6
|
+
export const formatMemo = (extra: StellarOperationExtra): string | undefined => {
|
7
|
+
switch (extra?.memo?.type) {
|
8
|
+
case "MEMO_ID":
|
9
|
+
case "MEMO_TEXT":
|
10
|
+
case "MEMO_HASH":
|
11
|
+
case "MEMO_RETURN":
|
12
|
+
return extra?.memo.value;
|
13
|
+
}
|
14
|
+
return undefined;
|
15
|
+
};
|
@@ -1,10 +1,18 @@
|
|
1
1
|
import { fromAccountRaw } from "../../account/serialization";
|
2
2
|
import { TronAccount } from "@ledgerhq/coin-tron/types/index";
|
3
|
+
import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
|
4
|
+
import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
|
3
5
|
|
4
6
|
export const __NEXT_REWARD_DATE__ = new Date(Date.now() - 6 * 60 * 60 * 1000);
|
5
7
|
|
6
8
|
export const __LAST_VOTING_DATE__ = new Date(Date.now() - 6 * 60 * 60 * 1000);
|
7
9
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
11
|
+
setCryptoAssetsStoreForCoinFramework({
|
12
|
+
findTokenById: (_: string) => undefined,
|
13
|
+
findTokenByAddressInCurrency: (_: string, __: string) => undefined,
|
14
|
+
} as unknown as CryptoAssetsStore);
|
15
|
+
|
8
16
|
export const mockAccount = fromAccountRaw({
|
9
17
|
id: "js:2:tron:TRON_ID:",
|
10
18
|
seedIdentifier: "TRON_ID",
|
@@ -3,6 +3,7 @@ import { bridge as aptos } from "../../families/aptos/setup";
|
|
3
3
|
import { bridge as bitcoin } from "../../families/bitcoin/setup";
|
4
4
|
import { bridge as cardano } from "../../families/cardano/setup";
|
5
5
|
import { bridge as casper } from "../../families/casper/setup";
|
6
|
+
import { bridge as canton } from "../../families/canton/setup";
|
6
7
|
import { bridge as celo } from "../../families/celo/setup";
|
7
8
|
import { bridge as cosmos } from "../../families/cosmos/setup";
|
8
9
|
import { bridge as evm } from "../../families/evm/setup";
|
@@ -29,6 +30,7 @@ export default {
|
|
29
30
|
bitcoin,
|
30
31
|
cardano,
|
31
32
|
casper,
|
33
|
+
canton,
|
32
34
|
celo,
|
33
35
|
cosmos,
|
34
36
|
evm,
|
@@ -3,6 +3,7 @@ import { cliTools as aptos } from "../families/aptos/setup";
|
|
3
3
|
import { cliTools as bitcoin } from "../families/bitcoin/setup";
|
4
4
|
import { cliTools as cardano } from "../families/cardano/setup";
|
5
5
|
import { cliTools as casper } from "../families/casper/setup";
|
6
|
+
import { cliTools as canton } from "../families/canton/setup";
|
6
7
|
import { cliTools as celo } from "../families/celo/setup";
|
7
8
|
import { cliTools as cosmos } from "../families/cosmos/setup";
|
8
9
|
import { cliTools as evm } from "../families/evm/setup";
|
@@ -30,6 +31,7 @@ export default {
|
|
30
31
|
bitcoin,
|
31
32
|
cardano,
|
32
33
|
casper,
|
34
|
+
canton,
|
33
35
|
celo,
|
34
36
|
cosmos,
|
35
37
|
evm,
|
@@ -3,6 +3,7 @@ import aptos from "@ledgerhq/coin-aptos/deviceTransactionConfig";
|
|
3
3
|
import bitcoin from "@ledgerhq/coin-bitcoin/deviceTransactionConfig";
|
4
4
|
import cardano from "@ledgerhq/coin-cardano/deviceTransactionConfig";
|
5
5
|
import casper from "@ledgerhq/coin-casper/deviceTransactionConfig";
|
6
|
+
import canton from "@ledgerhq/coin-canton/deviceTransactionConfig";
|
6
7
|
import celo from "@ledgerhq/coin-celo/deviceTransactionConfig";
|
7
8
|
import cosmos from "@ledgerhq/coin-cosmos/deviceTransactionConfig";
|
8
9
|
import evm from "@ledgerhq/coin-evm/deviceTransactionConfig";
|
@@ -28,6 +29,7 @@ export default {
|
|
28
29
|
bitcoin,
|
29
30
|
cardano,
|
30
31
|
casper,
|
32
|
+
canton,
|
31
33
|
celo,
|
32
34
|
cosmos,
|
33
35
|
evm,
|
@@ -3,6 +3,7 @@ import { resolver as aptos } from "../families/aptos/setup";
|
|
3
3
|
import { resolver as bitcoin } from "../families/bitcoin/setup";
|
4
4
|
import { resolver as cardano } from "../families/cardano/setup";
|
5
5
|
import { resolver as casper } from "../families/casper/setup";
|
6
|
+
import { resolver as canton } from "../families/canton/setup";
|
6
7
|
import { resolver as celo } from "../families/celo/setup";
|
7
8
|
import { resolver as cosmos } from "../families/cosmos/setup";
|
8
9
|
import { resolver as evm } from "../families/evm/setup";
|
@@ -30,6 +31,7 @@ export default {
|
|
30
31
|
bitcoin,
|
31
32
|
cardano,
|
32
33
|
casper,
|
34
|
+
canton,
|
33
35
|
celo,
|
34
36
|
cosmos,
|
35
37
|
evm,
|
package/src/generated/specs.ts
CHANGED
@@ -3,6 +3,7 @@ import aptos from "@ledgerhq/coin-aptos/specs";
|
|
3
3
|
import bitcoin from "@ledgerhq/coin-bitcoin/specs";
|
4
4
|
import cardano from "@ledgerhq/coin-cardano/specs";
|
5
5
|
import casper from "@ledgerhq/coin-casper/specs";
|
6
|
+
import canton from "@ledgerhq/coin-canton/specs";
|
6
7
|
import celo from "@ledgerhq/coin-celo/specs";
|
7
8
|
import cosmos from "@ledgerhq/coin-cosmos/specs";
|
8
9
|
import evm from "@ledgerhq/coin-evm/specs";
|
@@ -29,6 +30,7 @@ export default {
|
|
29
30
|
bitcoin,
|
30
31
|
cardano,
|
31
32
|
casper,
|
33
|
+
canton,
|
32
34
|
celo,
|
33
35
|
cosmos,
|
34
36
|
evm,
|
@@ -3,6 +3,7 @@ import aptos from "@ledgerhq/coin-aptos/transaction";
|
|
3
3
|
import bitcoin from "@ledgerhq/coin-bitcoin/transaction";
|
4
4
|
import cardano from "@ledgerhq/coin-cardano/transaction";
|
5
5
|
import casper from "@ledgerhq/coin-casper/transaction";
|
6
|
+
import canton from "@ledgerhq/coin-canton/transaction";
|
6
7
|
import celo from "@ledgerhq/coin-celo/transaction";
|
7
8
|
import cosmos from "@ledgerhq/coin-cosmos/transaction";
|
8
9
|
import evm from "@ledgerhq/coin-evm/transaction";
|
@@ -30,6 +31,7 @@ export default {
|
|
30
31
|
bitcoin,
|
31
32
|
cardano,
|
32
33
|
casper,
|
34
|
+
canton,
|
33
35
|
celo,
|
34
36
|
cosmos,
|
35
37
|
evm,
|
package/src/generated/types.ts
CHANGED
@@ -16,6 +16,12 @@ import type {
|
|
16
16
|
TransactionStatus as bitcoinTransactionStatus,
|
17
17
|
TransactionStatusRaw as bitcoinTransactionStatusRaw,
|
18
18
|
} from "@ledgerhq/coin-bitcoin/types";
|
19
|
+
import type {
|
20
|
+
Transaction as cantonTransaction,
|
21
|
+
TransactionRaw as cantonTransactionRaw,
|
22
|
+
TransactionStatus as cantonTransactionStatus,
|
23
|
+
TransactionStatusRaw as cantonTransactionStatusRaw,
|
24
|
+
} from "@ledgerhq/coin-canton/types/index";
|
19
25
|
import type {
|
20
26
|
Transaction as cardanoTransaction,
|
21
27
|
TransactionRaw as cardanoTransactionRaw,
|
@@ -153,6 +159,7 @@ export type Transaction =
|
|
153
159
|
| algorandTransaction
|
154
160
|
| aptosTransaction
|
155
161
|
| bitcoinTransaction
|
162
|
+
| cantonTransaction
|
156
163
|
| cardanoTransaction
|
157
164
|
| casperTransaction
|
158
165
|
| celoTransaction
|
@@ -180,6 +187,7 @@ export type TransactionRaw =
|
|
180
187
|
| algorandTransactionRaw
|
181
188
|
| aptosTransactionRaw
|
182
189
|
| bitcoinTransactionRaw
|
190
|
+
| cantonTransactionRaw
|
183
191
|
| cardanoTransactionRaw
|
184
192
|
| casperTransactionRaw
|
185
193
|
| celoTransactionRaw
|
@@ -207,6 +215,7 @@ export type TransactionStatus =
|
|
207
215
|
| algorandTransactionStatus
|
208
216
|
| aptosTransactionStatus
|
209
217
|
| bitcoinTransactionStatus
|
218
|
+
| cantonTransactionStatus
|
210
219
|
| cardanoTransactionStatus
|
211
220
|
| casperTransactionStatus
|
212
221
|
| celoTransactionStatus
|
@@ -234,6 +243,7 @@ export type TransactionStatusRaw =
|
|
234
243
|
| algorandTransactionStatusRaw
|
235
244
|
| aptosTransactionStatusRaw
|
236
245
|
| bitcoinTransactionStatusRaw
|
246
|
+
| cantonTransactionStatusRaw
|
237
247
|
| cardanoTransactionStatusRaw
|
238
248
|
| casperTransactionStatusRaw
|
239
249
|
| celoTransactionStatusRaw
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { genAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
|
2
|
+
import BigNumber from "bignumber.js";
|
3
|
+
import { mockBtcCryptoCurrency } from "./currencies.mock";
|
4
|
+
import { mockArbitrumCryptoCurrency } from "./currencies.mock";
|
5
|
+
import { mockEthCryptoCurrency } from "./currencies.mock";
|
6
|
+
import { mockBaseCryptoCurrency } from "./currencies.mock";
|
7
|
+
import { mockScrollCryptoCurrency } from "./currencies.mock";
|
8
|
+
|
9
|
+
export const MOCKED_ARB_ACCOUNT = {
|
10
|
+
type: "Account",
|
11
|
+
id: "arbitrum1",
|
12
|
+
balance: new BigNumber(34455),
|
13
|
+
creationDate: "2024-12-10T09:27:22.000Z",
|
14
|
+
currency: mockArbitrumCryptoCurrency,
|
15
|
+
derivationMode: "",
|
16
|
+
freshAddress: "s37rhmi7hsm3i73hsm7i3hm83m8h87hsm87h3s8h33",
|
17
|
+
};
|
18
|
+
|
19
|
+
export const ETH_ACCOUNT = genAccount("ethereum-1", {
|
20
|
+
currency: mockEthCryptoCurrency,
|
21
|
+
});
|
22
|
+
export const ETH_ACCOUNT_2 = genAccount("ethereum-2", {
|
23
|
+
currency: mockEthCryptoCurrency,
|
24
|
+
});
|
25
|
+
export const BTC_ACCOUNT = genAccount("bitcoin-1", {
|
26
|
+
currency: mockBtcCryptoCurrency,
|
27
|
+
});
|
28
|
+
export const ARB_ACCOUNT = genAccount("arbitrum-1", {
|
29
|
+
currency: mockArbitrumCryptoCurrency,
|
30
|
+
tokenIds: ["arbitrum/erc20/arbitrum"],
|
31
|
+
});
|
32
|
+
export const ETH_ACCOUNT_WITH_USDC = genAccount("ethereum-usdc", {
|
33
|
+
currency: mockEthCryptoCurrency,
|
34
|
+
tokenIds: ["ethereum/erc20/usdc"],
|
35
|
+
});
|
36
|
+
export const BASE_ACCOUNT = genAccount("base-1", {
|
37
|
+
currency: mockBaseCryptoCurrency,
|
38
|
+
operationsSize: 100,
|
39
|
+
});
|
40
|
+
export const SCROLL_ACCOUNT = genAccount("scroll-1", {
|
41
|
+
currency: mockScrollCryptoCurrency,
|
42
|
+
operationsSize: 100,
|
43
|
+
});
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import { useGroupedCurrenciesByProvider } from "@ledgerhq/live-common/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock";
|
2
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
|
4
|
+
import {
|
5
|
+
buildProviderCoverageMap,
|
6
|
+
extractProviderCurrencies,
|
7
|
+
filterProvidersByIds,
|
8
|
+
getProviderCurrency,
|
9
|
+
isProviderToken,
|
10
|
+
safeCurrencyLookup,
|
11
|
+
} from "../currencyUtils";
|
12
|
+
import {
|
13
|
+
usdcToken,
|
14
|
+
mockBaseCryptoCurrency,
|
15
|
+
mockBtcCryptoCurrency,
|
16
|
+
mockEthCryptoCurrency,
|
17
|
+
} from "../../__mocks__/currencies.mock";
|
18
|
+
|
19
|
+
describe("safeCurrencyLookup", () => {
|
20
|
+
it("should return the currency if it is found", () => {
|
21
|
+
const currency = safeCurrencyLookup("ethereum");
|
22
|
+
expect(currency).toBeDefined();
|
23
|
+
});
|
24
|
+
it("should return null if the currency is not found", () => {
|
25
|
+
const currency = safeCurrencyLookup("not-a-currency");
|
26
|
+
expect(currency).toBeNull();
|
27
|
+
});
|
28
|
+
});
|
29
|
+
|
30
|
+
describe("isProviderToken", () => {
|
31
|
+
it("should return true if the currency is a provider token", () => {
|
32
|
+
const baseToken: TokenCurrency = {
|
33
|
+
type: "TokenCurrency",
|
34
|
+
id: "base/erc20/base",
|
35
|
+
contractAddress: "0x0000000000000000000000000000000000000000",
|
36
|
+
parentCurrency: mockBaseCryptoCurrency,
|
37
|
+
tokenType: "erc20",
|
38
|
+
name: "Base",
|
39
|
+
ticker: "BASE",
|
40
|
+
units: [
|
41
|
+
{
|
42
|
+
name: "Base",
|
43
|
+
code: "BASE",
|
44
|
+
magnitude: 18,
|
45
|
+
},
|
46
|
+
],
|
47
|
+
};
|
48
|
+
const currency = isProviderToken(baseToken, "base");
|
49
|
+
expect(currency).toBe(true);
|
50
|
+
});
|
51
|
+
it("should return false if the currency is not a provider token", () => {
|
52
|
+
const currency = isProviderToken(mockEthCryptoCurrency, "ethereum");
|
53
|
+
expect(currency).toBe(false);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
describe("getProviderCurrency", () => {
|
58
|
+
it("should return the currency if it is a provider currency", () => {
|
59
|
+
const { result } = useGroupedCurrenciesByProvider();
|
60
|
+
const currency = getProviderCurrency(result.currenciesByProvider[0]);
|
61
|
+
expect(currency).toEqual(mockBtcCryptoCurrency);
|
62
|
+
});
|
63
|
+
it("should return the currency if it is a provider token", () => {
|
64
|
+
const { result } = useGroupedCurrenciesByProvider();
|
65
|
+
const currency = getProviderCurrency(result.currenciesByProvider[3]);
|
66
|
+
expect(currency).toEqual(usdcToken);
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
70
|
+
describe("buildProviderCoverageMap", () => {
|
71
|
+
it("should build a map of provider coverage correctly", () => {
|
72
|
+
const { result } = useGroupedCurrenciesByProvider();
|
73
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
74
|
+
|
75
|
+
expect(coverageMap).toBeInstanceOf(Map);
|
76
|
+
expect(coverageMap.get("bitcoin")).toEqual(new Set(["bitcoin"]));
|
77
|
+
expect(coverageMap.get("ethereum")).toEqual(new Set(["ethereum"]));
|
78
|
+
expect(coverageMap.get("arbitrum")).toEqual(new Set(["ethereum"]));
|
79
|
+
expect(coverageMap.get("base")).toEqual(new Set(["ethereum"]));
|
80
|
+
expect(coverageMap.get("scroll")).toEqual(new Set(["ethereum"]));
|
81
|
+
expect(coverageMap.get("arbitrum/erc20/arbitrum")).toEqual(new Set(["arbitrum"]));
|
82
|
+
expect(coverageMap.get("ethereum/erc20/usd__coin")).toEqual(new Set(["usd-coin"]));
|
83
|
+
expect(coverageMap.get("injective")).toEqual(new Set(["injective-protocol"]));
|
84
|
+
});
|
85
|
+
it("should handle empty input", () => {
|
86
|
+
const coverageMap = buildProviderCoverageMap([]);
|
87
|
+
expect(coverageMap).toBeInstanceOf(Map);
|
88
|
+
expect(coverageMap.size).toBe(0);
|
89
|
+
});
|
90
|
+
});
|
91
|
+
|
92
|
+
describe("filterProvidersByIds", () => {
|
93
|
+
it("should filter providers by ids correctly #evm", () => {
|
94
|
+
const { result } = useGroupedCurrenciesByProvider();
|
95
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
96
|
+
const filteredProviders = filterProvidersByIds(
|
97
|
+
result.currenciesByProvider,
|
98
|
+
new Set(["base"]),
|
99
|
+
coverageMap,
|
100
|
+
);
|
101
|
+
expect(filteredProviders).toHaveLength(1);
|
102
|
+
expect(filteredProviders[0].providerId).toBe("ethereum");
|
103
|
+
});
|
104
|
+
it("should filter providers by ids correctly #bitcoin", () => {
|
105
|
+
const { result } = useGroupedCurrenciesByProvider();
|
106
|
+
const coverageMap = buildProviderCoverageMap(result.currenciesByProvider);
|
107
|
+
const filteredProviders = filterProvidersByIds(
|
108
|
+
result.currenciesByProvider,
|
109
|
+
new Set(["bitcoin"]),
|
110
|
+
coverageMap,
|
111
|
+
);
|
112
|
+
expect(filteredProviders).toHaveLength(1);
|
113
|
+
expect(filteredProviders[0].providerId).toBe("bitcoin");
|
114
|
+
});
|
115
|
+
});
|
116
|
+
|
117
|
+
describe("extractProviderCurrencies", () => {
|
118
|
+
it("should extract provider currencies correctly", () => {
|
119
|
+
const { result } = useGroupedCurrenciesByProvider();
|
120
|
+
const providerCurrencies = extractProviderCurrencies(result.currenciesByProvider);
|
121
|
+
expect(providerCurrencies).toHaveLength(5);
|
122
|
+
expect(providerCurrencies[0]).toEqual(mockBtcCryptoCurrency);
|
123
|
+
expect(providerCurrencies[1].id).toBe("ethereum");
|
124
|
+
expect(providerCurrencies[2].id).toBe("arbitrum/erc20/arbitrum");
|
125
|
+
});
|
126
|
+
});
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { getTokenOrCryptoCurrencyById } from "../../deposit/helper";
|
3
|
+
import { isTokenCurrency } from "../../currencies";
|
4
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
5
|
+
|
6
|
+
export type ProviderCoverageMap = Map<string, Set<string>>;
|
7
|
+
|
8
|
+
export const safeCurrencyLookup = (id: string): CryptoOrTokenCurrency | null => {
|
9
|
+
try {
|
10
|
+
return getTokenOrCryptoCurrencyById(id);
|
11
|
+
} catch {
|
12
|
+
return null;
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
export const isProviderToken = (currency: CryptoOrTokenCurrency, providerId: string): boolean => {
|
17
|
+
return isTokenCurrency(currency) && currency.id.toLowerCase().includes(providerId.toLowerCase());
|
18
|
+
};
|
19
|
+
|
20
|
+
export const getProviderCurrency = (
|
21
|
+
provider: CurrenciesByProviderId,
|
22
|
+
): CryptoOrTokenCurrency | null => {
|
23
|
+
const providerToken = provider.currenciesByNetwork.find(currency => {
|
24
|
+
return isProviderToken(currency, provider.providerId);
|
25
|
+
});
|
26
|
+
|
27
|
+
if (providerToken) {
|
28
|
+
return providerToken;
|
29
|
+
}
|
30
|
+
|
31
|
+
return safeCurrencyLookup(provider.providerId) ?? provider.currenciesByNetwork[0];
|
32
|
+
};
|
33
|
+
|
34
|
+
export const buildProviderCoverageMap = (
|
35
|
+
providers: CurrenciesByProviderId[],
|
36
|
+
): ProviderCoverageMap => {
|
37
|
+
const providerIdToCoveringProviders = new Map<string, Set<string>>();
|
38
|
+
|
39
|
+
for (const { providerId, currenciesByNetwork } of providers) {
|
40
|
+
for (const { id } of currenciesByNetwork) {
|
41
|
+
if (!providerIdToCoveringProviders.has(id)) {
|
42
|
+
providerIdToCoveringProviders.set(id, new Set());
|
43
|
+
}
|
44
|
+
providerIdToCoveringProviders.get(id)!.add(providerId);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return providerIdToCoveringProviders;
|
49
|
+
};
|
50
|
+
|
51
|
+
export const filterProvidersByIds = (
|
52
|
+
providers: CurrenciesByProviderId[],
|
53
|
+
currencyIdsSet: Set<string>,
|
54
|
+
providerCoverageMap: ProviderCoverageMap,
|
55
|
+
): CurrenciesByProviderId[] => {
|
56
|
+
const filtered: CurrenciesByProviderId[] = [];
|
57
|
+
|
58
|
+
for (const provider of providers) {
|
59
|
+
const filteredCurrencies = provider.currenciesByNetwork.filter(currency =>
|
60
|
+
currencyIdsSet.has(currency.id),
|
61
|
+
);
|
62
|
+
|
63
|
+
if (filteredCurrencies.length === 0) continue;
|
64
|
+
|
65
|
+
const providerHasOwnCurrency = provider.currenciesByNetwork.some(
|
66
|
+
currency => currency.id === provider.providerId,
|
67
|
+
);
|
68
|
+
|
69
|
+
if (!providerHasOwnCurrency) {
|
70
|
+
const coveringProviders = providerCoverageMap.get(provider.providerId);
|
71
|
+
const isProviderIdCoveredElsewhere = coveringProviders && coveringProviders.size > 1;
|
72
|
+
|
73
|
+
if (isProviderIdCoveredElsewhere) continue;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (filteredCurrencies.length === provider.currenciesByNetwork.length) {
|
77
|
+
filtered.push(provider);
|
78
|
+
} else {
|
79
|
+
filtered.push({
|
80
|
+
...provider,
|
81
|
+
currenciesByNetwork: filteredCurrencies,
|
82
|
+
});
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return filtered;
|
87
|
+
};
|
88
|
+
|
89
|
+
export const extractProviderCurrencies = (
|
90
|
+
providers: CurrenciesByProviderId[],
|
91
|
+
): CryptoOrTokenCurrency[] => {
|
92
|
+
return providers
|
93
|
+
.map(provider => getProviderCurrency(provider))
|
94
|
+
.filter((currency): currency is CryptoOrTokenCurrency => currency !== null);
|
95
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { composeHooks } from "../composeHooks";
|
2
|
+
|
3
|
+
describe("composeHooks", () => {
|
4
|
+
it("should compose hooks and merge their results", () => {
|
5
|
+
const hook1 = (items: Array<{ id: number }>) =>
|
6
|
+
items.map(item => ({ id: item.id, extra: item.id * 2 }));
|
7
|
+
const hook2 = (items: Array<{ id: number; extra: number }>) =>
|
8
|
+
items.map(item => ({ ...item, final: item.extra + 1 }));
|
9
|
+
|
10
|
+
const composed = composeHooks(hook1, hook2);
|
11
|
+
|
12
|
+
const input: Array<{ id: number }> = [{ id: 1 }, { id: 2 }];
|
13
|
+
const processedInput = input.map(item => ({ id: item.id, extra: item.id * 2 }));
|
14
|
+
const result = composed(processedInput);
|
15
|
+
|
16
|
+
expect(result).toEqual([
|
17
|
+
{ id: 1, extra: 2, final: 3 },
|
18
|
+
{ id: 2, extra: 4, final: 5 },
|
19
|
+
]);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("should handle hooks that return undefined", () => {
|
23
|
+
const hook1 = (items: Array<{ id: number }>) =>
|
24
|
+
items.map(item => ({ id: item.id, extra: item.id * 2 }));
|
25
|
+
const hook2 = () => undefined;
|
26
|
+
|
27
|
+
const composed = composeHooks(hook1, hook2);
|
28
|
+
|
29
|
+
const input = [{ id: 1 }, { id: 2 }];
|
30
|
+
const result = composed(input);
|
31
|
+
|
32
|
+
expect(result).toEqual([
|
33
|
+
{ id: 1, extra: 2 },
|
34
|
+
{ id: 2, extra: 4 },
|
35
|
+
]);
|
36
|
+
});
|
37
|
+
|
38
|
+
it("should return the original items if no hooks are provided", () => {
|
39
|
+
const composed = composeHooks();
|
40
|
+
|
41
|
+
const input = [{ id: 1 }, { id: 2 }];
|
42
|
+
const result = composed(input);
|
43
|
+
|
44
|
+
expect(result).toEqual(input);
|
45
|
+
});
|
46
|
+
});
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
2
|
+
import { genAccount } from "@ledgerhq/live-common/mock/account";
|
3
|
+
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
4
|
+
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
5
|
+
import { getAccountTuplesForCurrency } from "../getAccountTuplesForCurrency";
|
6
|
+
|
7
|
+
function* accountGenerator(currency: CryptoCurrency): Generator<Account> {
|
8
|
+
let id = 0;
|
9
|
+
while (true) {
|
10
|
+
id += 1;
|
11
|
+
yield genAccount(`mocked-account-${id}`, { currency, operationsSize: 0 });
|
12
|
+
}
|
13
|
+
}
|
14
|
+
const getAccountCreator = (currencyId: string) => {
|
15
|
+
const generator = accountGenerator(getCryptoCurrencyById(currencyId));
|
16
|
+
return () => generator.next().value;
|
17
|
+
};
|
18
|
+
|
19
|
+
describe("getAccountTuplesForCurrency", () => {
|
20
|
+
const getEthAccount = getAccountCreator("ethereum");
|
21
|
+
const getBtcAccount = getAccountCreator("bitcoin");
|
22
|
+
const getPolkadotAccount = getAccountCreator("polkadot");
|
23
|
+
const getCosmosAccount = getAccountCreator("cosmos");
|
24
|
+
|
25
|
+
describe("CryptoCurrency", () => {
|
26
|
+
test("returns all accounts associated to the CryptoCurrency", () => {
|
27
|
+
const ethCurrency = getCryptoCurrencyById("ethereum");
|
28
|
+
const ethAccounts = [getEthAccount(), getEthAccount()];
|
29
|
+
const allAccounts: Account[] = [
|
30
|
+
getCosmosAccount(),
|
31
|
+
...ethAccounts,
|
32
|
+
getBtcAccount(),
|
33
|
+
getPolkadotAccount(),
|
34
|
+
];
|
35
|
+
|
36
|
+
const results = getAccountTuplesForCurrency(ethCurrency, allAccounts);
|
37
|
+
|
38
|
+
expect(results).toHaveLength(2);
|
39
|
+
results.forEach((result, index) => {
|
40
|
+
expect(result.account).toEqual(ethAccounts[index]);
|
41
|
+
expect(result.subAccount).toBeNull();
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
test("returns an empty array if the CryptoCurrency passed has no associated account", () => {
|
46
|
+
const ethCurrency = getCryptoCurrencyById("ethereum");
|
47
|
+
const allAccounts: Account[] = [getCosmosAccount(), getBtcAccount(), getPolkadotAccount()];
|
48
|
+
|
49
|
+
const results = getAccountTuplesForCurrency(ethCurrency, allAccounts);
|
50
|
+
|
51
|
+
expect(results).toHaveLength(0);
|
52
|
+
});
|
53
|
+
|
54
|
+
test("filters based on the accountId map", () => {
|
55
|
+
const ethCurrency = getCryptoCurrencyById("ethereum");
|
56
|
+
const ethAccounts = [getEthAccount(), getEthAccount(), getEthAccount(), getEthAccount()];
|
57
|
+
|
58
|
+
const results = getAccountTuplesForCurrency(
|
59
|
+
ethCurrency,
|
60
|
+
ethAccounts,
|
61
|
+
new Map([[ethAccounts[0].id, true]]),
|
62
|
+
);
|
63
|
+
|
64
|
+
expect(results).toHaveLength(1);
|
65
|
+
});
|
66
|
+
});
|
67
|
+
|
68
|
+
describe("TokenCurrency", () => {
|
69
|
+
const aaveToken = getTokenById("ethereum/erc20/aave");
|
70
|
+
|
71
|
+
test("returns correct parent accounts including a new subAccount when a TokenCurrency is provided", () => {
|
72
|
+
const ethAccounts = [
|
73
|
+
{ ...getEthAccount(), subAccounts: [] },
|
74
|
+
{ ...getEthAccount(), subAccounts: [] },
|
75
|
+
];
|
76
|
+
const allAccounts: Account[] = [
|
77
|
+
getCosmosAccount(),
|
78
|
+
...ethAccounts,
|
79
|
+
getBtcAccount(),
|
80
|
+
getPolkadotAccount(),
|
81
|
+
];
|
82
|
+
|
83
|
+
const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
|
84
|
+
|
85
|
+
expect(results).toHaveLength(ethAccounts.length);
|
86
|
+
results.forEach((result, index) => {
|
87
|
+
expect(result.account).toEqual(ethAccounts[index]);
|
88
|
+
expect((result.subAccount as TokenAccount & { token: TokenCurrency }).token).toEqual(
|
89
|
+
aaveToken,
|
90
|
+
);
|
91
|
+
});
|
92
|
+
});
|
93
|
+
|
94
|
+
test("returns correct parent accounts including already existing subAccounts when a TokenCurrency is provided", () => {
|
95
|
+
const ethAccounts = [{ ...getEthAccount(), subAccounts: [aaveToken] }];
|
96
|
+
const allAccounts: Account[] = [
|
97
|
+
getCosmosAccount(),
|
98
|
+
...ethAccounts,
|
99
|
+
getBtcAccount(),
|
100
|
+
getPolkadotAccount(),
|
101
|
+
];
|
102
|
+
|
103
|
+
const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
|
104
|
+
|
105
|
+
expect(results).toHaveLength(ethAccounts.length);
|
106
|
+
results.forEach((result, index) => {
|
107
|
+
expect(result.account).toEqual(ethAccounts[index]);
|
108
|
+
expect((result.subAccount as TokenAccount & { token: TokenCurrency }).token).toEqual(
|
109
|
+
aaveToken,
|
110
|
+
);
|
111
|
+
});
|
112
|
+
});
|
113
|
+
|
114
|
+
test("returns an empty array when a TokenCurrency is provided but the accounts list is empty", () => {
|
115
|
+
const allAccounts: Account[] = [];
|
116
|
+
|
117
|
+
const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
|
118
|
+
expect(results).toHaveLength(0);
|
119
|
+
});
|
120
|
+
|
121
|
+
test("does not filter based on the accountId map", () => {
|
122
|
+
const aaveAccounts = [
|
123
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
124
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
125
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
126
|
+
{ ...getEthAccount(), subAccounts: [aaveToken] },
|
127
|
+
];
|
128
|
+
|
129
|
+
const results = getAccountTuplesForCurrency(
|
130
|
+
aaveToken,
|
131
|
+
aaveAccounts,
|
132
|
+
new Map([[aaveAccounts[0].id, true]]),
|
133
|
+
);
|
134
|
+
|
135
|
+
expect(results).toHaveLength(4);
|
136
|
+
});
|
137
|
+
});
|
138
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* @param hooks - An array of functions that take an array of items of type T and return an array of items of type U or undefined.
|
4
|
+
* @template T - The type of the items in the input array.
|
5
|
+
* @template U - The type of the items in the output array.
|
6
|
+
* @description This function composes multiple hooks into a single hook that processes an array of items of type T and returns an array of items of type T & U.
|
7
|
+
* @returns A function that takes an array of items of type T and returns an array of items of type T & U.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
export function composeHooks<T, U>(
|
12
|
+
...hooks: Array<(items: T[]) => U[] | undefined>
|
13
|
+
): (items: T[]) => (T & U)[] {
|
14
|
+
return (items: T[]): (T & U)[] => {
|
15
|
+
return hooks.reduce<(T & U)[]>(
|
16
|
+
(acc, hook) => {
|
17
|
+
const result = hook?.(acc as T[]) ?? [];
|
18
|
+
return acc.map((item, i) => ({
|
19
|
+
...item,
|
20
|
+
...result[i],
|
21
|
+
}));
|
22
|
+
},
|
23
|
+
items as (T & U)[],
|
24
|
+
);
|
25
|
+
};
|
26
|
+
}
|