@ledgerhq/live-common 34.47.0 → 34.48.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/crypto-assets/cal-integration.d.ts +4 -0
- package/lib/bridge/crypto-assets/cal-integration.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.js +26 -0
- package/lib/bridge/crypto-assets/cal-integration.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts +2 -0
- package/lib/bridge/crypto-assets/cal-integration.test.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-integration.test.js +45 -0
- package/lib/bridge/crypto-assets/cal-integration.test.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.d.ts +14 -0
- package/lib/bridge/crypto-assets/cal-store.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.js +58 -0
- package/lib/bridge/crypto-assets/cal-store.js.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.test.d.ts +2 -0
- package/lib/bridge/crypto-assets/cal-store.test.d.ts.map +1 -0
- package/lib/bridge/crypto-assets/cal-store.test.js +70 -0
- package/lib/bridge/crypto-assets/cal-store.test.js.map +1 -0
- package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +4 -0
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +36 -0
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js +6 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js +89 -0
- package/lib/bridge/generic-alpaca/alpaca/index.unit.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +2 -3
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.js +4 -14
- package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +4 -4
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +0 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +14 -3
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +21 -5
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +6 -5
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/utils.test.js +123 -0
- package/lib/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib/e2e/enum/DeviceLabels.d.ts +9 -6
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +8 -5
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/families/tezos.d.ts.map +1 -1
- package/lib/e2e/families/tezos.js +2 -0
- package/lib/e2e/families/tezos.js.map +1 -1
- package/lib/e2e/index.d.ts +7 -6
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts +2 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +25 -17
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.js +3 -5
- package/lib/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +5 -2
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib/exchange/swap/initSwap.js +5 -2
- package/lib/exchange/swap/initSwap.js.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +4 -0
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/solana/setup.d.ts.map +1 -1
- package/lib/families/solana/setup.js +9 -0
- package/lib/families/solana/setup.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -2
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/dada.mock.d.ts +3336 -0
- package/lib/modularDrawer/__mocks__/dada.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/dada.mock.js +3879 -0
- package/lib/modularDrawer/__mocks__/dada.mock.js.map +1 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts +16 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.d.ts.map +1 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.js +21 -0
- package/lib/modularDrawer/data/entities/interestRateSelectors.js.map +1 -0
- package/lib/modularDrawer/data/state-manager/api.d.ts +727 -37
- package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib/modularDrawer/data/state-manager/api.js +38 -17
- package/lib/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib/modularDrawer/data/state-manager/types.d.ts +24 -0
- package/lib/modularDrawer/data/state-manager/types.d.ts.map +1 -0
- package/lib/modularDrawer/data/state-manager/types.js +13 -0
- package/lib/modularDrawer/data/state-manager/types.js.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js +134 -78
- package/lib/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +206 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js +43 -10
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useAssetsData.d.ts +10 -6
- package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.js +40 -17
- package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts +3 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.js +23 -0
- package/lib/modularDrawer/hooks/useInterestRatesByCurrencies.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js +15 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts +4 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js +30 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js +29 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +87 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +66 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js +41 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js +54 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js +36 -0
- package/lib/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js +17 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.d.ts +13 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.js +20 -0
- package/lib/modularDrawer/utils/getInterestRateForAsset.js.map +1 -0
- package/lib/modularDrawer/utils/getLoadingStatus.d.ts +9 -0
- package/lib/modularDrawer/utils/getLoadingStatus.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getLoadingStatus.js +18 -0
- package/lib/modularDrawer/utils/getLoadingStatus.js.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.js +32 -0
- package/lib/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +90 -1
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +2 -2
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/ModularDrawer/types.d.ts +6 -6
- package/lib/wallet-api/ModularDrawer/types.d.ts.map +1 -1
- package/lib/wallet-api/ModularDrawer/types.js +1 -1
- package/lib/wallet-api/ModularDrawer/types.js.map +1 -1
- package/lib/wallet-api/react.d.ts +2 -0
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +3 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts +4 -0
- package/lib-es/bridge/crypto-assets/cal-integration.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.js +21 -0
- package/lib-es/bridge/crypto-assets/cal-integration.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts +2 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.js +43 -0
- package/lib-es/bridge/crypto-assets/cal-integration.test.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.d.ts +14 -0
- package/lib-es/bridge/crypto-assets/cal-store.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.js +54 -0
- package/lib-es/bridge/crypto-assets/cal-store.js.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts +2 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.d.ts.map +1 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.js +68 -0
- package/lib-es/bridge/crypto-assets/cal-store.test.js.map +1 -0
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +4 -0
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +36 -0
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js +6 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js +64 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.unit.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +2 -3
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +4 -12
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +3 -3
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +0 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +14 -3
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +21 -5
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +6 -5
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js +118 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib-es/e2e/enum/DeviceLabels.d.ts +9 -6
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +8 -5
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/families/tezos.d.ts.map +1 -1
- package/lib-es/e2e/families/tezos.js +2 -0
- package/lib-es/e2e/families/tezos.js.map +1 -1
- package/lib-es/e2e/index.d.ts +7 -6
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts +2 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +23 -16
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/platform/transfer/completeExchange.js +3 -2
- package/lib-es/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/swap/completeExchange.js +5 -2
- package/lib-es/exchange/swap/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib-es/exchange/swap/initSwap.js +5 -2
- package/lib-es/exchange/swap/initSwap.js.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +4 -0
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/solana/setup.d.ts.map +1 -1
- package/lib-es/families/solana/setup.js +9 -0
- package/lib-es/families/solana/setup.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -2
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/dada.mock.d.ts +3336 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.js +3876 -0
- package/lib-es/modularDrawer/__mocks__/dada.mock.js.map +1 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts +16 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.js +18 -0
- package/lib-es/modularDrawer/data/entities/interestRateSelectors.js.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/api.d.ts +727 -37
- package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/api.js +35 -14
- package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/types.d.ts +24 -0
- package/lib-es/modularDrawer/data/state-manager/types.d.ts.map +1 -0
- package/lib-es/modularDrawer/data/state-manager/types.js +10 -0
- package/lib-es/modularDrawer/data/state-manager/types.js.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js +135 -79
- package/lib-es/modularDrawer/hooks/__test__/useAssetsData.test.js.map +1 -1
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +204 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +3 -3
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js +21 -8
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +10 -6
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.js +42 -19
- package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts +3 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.js +19 -0
- package/lib-es/modularDrawer/hooks/useInterestRatesByCurrencies.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js +11 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts +4 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js +26 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js +25 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +83 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +62 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js +39 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +48 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js +34 -0
- package/lib-es/modularDrawer/utils/__tests__/getInterestRateForAsset.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js +13 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.d.ts +13 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.js +16 -0
- package/lib-es/modularDrawer/utils/getInterestRateForAsset.js.map +1 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts +9 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.js +14 -0
- package/lib-es/modularDrawer/utils/getLoadingStatus.js.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js +25 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +90 -1
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +2 -2
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.d.ts +6 -6
- package/lib-es/wallet-api/ModularDrawer/types.d.ts.map +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.js +1 -1
- package/lib-es/wallet-api/ModularDrawer/types.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts +2 -0
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +3 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/package.json +51 -51
- package/src/bridge/crypto-assets/cal-integration.test.ts +53 -0
- package/src/bridge/crypto-assets/cal-integration.ts +23 -0
- package/src/bridge/crypto-assets/cal-store.test.ts +93 -0
- package/src/bridge/crypto-assets/cal-store.ts +63 -0
- package/src/bridge/crypto-assets/index.test.ts +47 -0
- package/src/bridge/crypto-assets/index.ts +5 -0
- package/src/bridge/generic-alpaca/alpaca/index.ts +14 -1
- package/src/bridge/generic-alpaca/alpaca/index.unit.test.ts +78 -0
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +5 -4
- package/src/bridge/generic-alpaca/buildSubAccounts.ts +5 -14
- package/src/bridge/generic-alpaca/getAccountShape.ts +3 -4
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +0 -1
- package/src/bridge/generic-alpaca/prepareTransaction.ts +44 -17
- package/src/bridge/generic-alpaca/signOperation.ts +1 -1
- package/src/bridge/generic-alpaca/utils.test.ts +133 -0
- package/src/bridge/generic-alpaca/utils.ts +7 -5
- package/src/e2e/enum/DeviceLabels.ts +8 -5
- package/src/e2e/families/tezos.ts +2 -0
- package/src/e2e/speculos.ts +24 -17
- package/src/exchange/platform/transfer/completeExchange.ts +3 -2
- package/src/exchange/swap/completeExchange.ts +5 -2
- package/src/exchange/swap/initSwap.ts +5 -4
- package/src/families/canton/config.ts +5 -0
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +27 -7
- package/src/families/solana/setup.ts +9 -0
- package/src/featureFlags/defaultFeatures.ts +1 -2
- package/src/modularDrawer/__mocks__/dada.mock.ts +3890 -0
- package/src/modularDrawer/data/entities/interestRateSelectors.ts +39 -0
- package/src/modularDrawer/data/state-manager/api.ts +42 -27
- package/src/modularDrawer/data/state-manager/types.ts +28 -0
- package/src/modularDrawer/hooks/__test__/useAssetsData.test.ts +141 -80
- package/src/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.ts +251 -0
- package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +27 -9
- package/src/modularDrawer/hooks/{modules/useAssetAccountCounts.tsx → useAssetAccountCounts.tsx} +2 -2
- package/src/modularDrawer/hooks/useAssetsData.ts +59 -22
- package/src/modularDrawer/hooks/useInterestRatesByCurrencies.ts +23 -0
- package/src/modularDrawer/hooks/useLeftAccounts.tsx +23 -0
- package/src/modularDrawer/hooks/useLeftAccountsApy.tsx +44 -0
- package/src/modularDrawer/hooks/useModularDrawerConfiguration.ts +33 -0
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +140 -0
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +116 -0
- package/src/modularDrawer/modules/createAssetConfiguration.ts +62 -0
- package/src/modularDrawer/modules/createNetworkConfiguration.ts +87 -0
- package/src/modularDrawer/utils/__tests__/getInterestRateForAsset.test.ts +58 -0
- package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +25 -0
- package/src/modularDrawer/utils/getInterestRateForAsset.ts +32 -0
- package/src/modularDrawer/utils/getLoadingStatus.ts +24 -0
- package/src/modularDrawer/utils/sortByBalance.tsx +32 -0
- package/src/modularDrawer/utils/type.ts +98 -0
- package/src/wallet-api/Exchange/server.ts +2 -2
- package/src/wallet-api/ModularDrawer/types.ts +1 -1
- package/src/wallet-api/react.ts +5 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.js +0 -20
- package/lib/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib/modularDrawer/types.d.ts +0 -2
- package/lib/modularDrawer/types.d.ts.map +0 -1
- package/lib/modularDrawer/types.js +0 -3
- package/lib/modularDrawer/types.js.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js +0 -18
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib-es/modularDrawer/types.d.ts +0 -2
- package/lib-es/modularDrawer/types.d.ts.map +0 -1
- package/lib-es/modularDrawer/types.js +0 -2
- package/lib-es/modularDrawer/types.js.map +0 -1
- package/src/bridge/generic-alpaca/tests/utils.test.ts +0 -19
- package/src/modularDrawer/types.ts +0 -1
- /package/lib/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
- /package/lib-es/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
2
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
|
4
|
+
// Coins with case-sensitive addresses (b58, ...)
|
5
|
+
const CASE_SENSITIVE_COINS = ["solana"];
|
6
|
+
|
7
|
+
export class CALStore implements CryptoAssetsStore {
|
8
|
+
private tokenCache = new Map<string, TokenCurrency>();
|
9
|
+
private addressCache = new Map<string, TokenCurrency>();
|
10
|
+
private tickerCache = new Map<string, TokenCurrency>();
|
11
|
+
|
12
|
+
addTokens(tokens: TokenCurrency[]) {
|
13
|
+
tokens.forEach(token => {
|
14
|
+
this.tokenCache.set(token.id, token);
|
15
|
+
if (token.contractAddress) {
|
16
|
+
const isCaseSensitive = CASE_SENSITIVE_COINS.includes(token.parentCurrency.id);
|
17
|
+
const normalizedAddress = isCaseSensitive
|
18
|
+
? token.contractAddress
|
19
|
+
: token.contractAddress.toLowerCase();
|
20
|
+
this.addressCache.set(normalizedAddress, token);
|
21
|
+
}
|
22
|
+
this.tickerCache.set(token.ticker, token);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
|
+
findTokenByAddress(address: string): TokenCurrency | undefined {
|
27
|
+
const exactMatch = this.addressCache.get(address);
|
28
|
+
if (exactMatch) return exactMatch;
|
29
|
+
|
30
|
+
const lowercaseMatch = this.addressCache.get(address.toLowerCase());
|
31
|
+
return lowercaseMatch;
|
32
|
+
}
|
33
|
+
|
34
|
+
getTokenById(id: string): TokenCurrency {
|
35
|
+
const token = this.tokenCache.get(id);
|
36
|
+
if (!token) {
|
37
|
+
throw new Error(`Token not found: ${id}`);
|
38
|
+
}
|
39
|
+
return token;
|
40
|
+
}
|
41
|
+
|
42
|
+
findTokenById(id: string): TokenCurrency | undefined {
|
43
|
+
return this.tokenCache.get(id);
|
44
|
+
}
|
45
|
+
|
46
|
+
findTokenByAddressInCurrency(address: string, currencyId: string): TokenCurrency | undefined {
|
47
|
+
const isCaseSensitive = CASE_SENSITIVE_COINS.includes(currencyId);
|
48
|
+
|
49
|
+
if (isCaseSensitive) {
|
50
|
+
const token = this.addressCache.get(address);
|
51
|
+
if (token && token.parentCurrency.id === currencyId) return token;
|
52
|
+
return undefined;
|
53
|
+
}
|
54
|
+
|
55
|
+
const token = this.addressCache.get(address.toLowerCase());
|
56
|
+
if (token && token.parentCurrency.id === currencyId) return token;
|
57
|
+
return undefined;
|
58
|
+
}
|
59
|
+
|
60
|
+
findTokenByTicker(ticker: string): TokenCurrency | undefined {
|
61
|
+
return this.tickerCache.get(ticker);
|
62
|
+
}
|
63
|
+
}
|
@@ -2,8 +2,22 @@ import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
2
2
|
import { getCryptoAssetsStore, setCryptoAssetsStore } from ".";
|
3
3
|
import * as legacy from "@ledgerhq/cryptoassets/tokens";
|
4
4
|
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
5
|
+
import * as calIntegration from "./cal-integration";
|
5
6
|
|
6
7
|
describe("Testing CryptoAssetStore", () => {
|
8
|
+
let isCALIntegrationEnabledSpy: jest.SpyInstance;
|
9
|
+
let getCALStoreSpy: jest.SpyInstance;
|
10
|
+
|
11
|
+
beforeEach(() => {
|
12
|
+
isCALIntegrationEnabledSpy = jest
|
13
|
+
.spyOn(calIntegration, "isCALIntegrationEnabled")
|
14
|
+
.mockReturnValue(false);
|
15
|
+
getCALStoreSpy = jest.spyOn(calIntegration, "getCALStore");
|
16
|
+
});
|
17
|
+
|
18
|
+
afterEach(() => {
|
19
|
+
jest.restoreAllMocks();
|
20
|
+
});
|
7
21
|
it("should return the default methods from cryptoassets libs when feature flag does not exists", () => {
|
8
22
|
LiveConfig.setConfig({
|
9
23
|
some_other_feature: {
|
@@ -68,4 +82,37 @@ describe("Testing CryptoAssetStore", () => {
|
|
68
82
|
const store = getCryptoAssetsStore();
|
69
83
|
expect(store).toBe(newStore);
|
70
84
|
});
|
85
|
+
|
86
|
+
it("should return CAL store when CAL integration is enabled", () => {
|
87
|
+
isCALIntegrationEnabledSpy.mockReturnValue(true);
|
88
|
+
|
89
|
+
const mockCALStore = {} as unknown as CryptoAssetsStore;
|
90
|
+
getCALStoreSpy.mockReturnValue(mockCALStore);
|
91
|
+
|
92
|
+
const store = getCryptoAssetsStore();
|
93
|
+
|
94
|
+
expect(isCALIntegrationEnabledSpy).toHaveBeenCalled();
|
95
|
+
expect(getCALStoreSpy).toHaveBeenCalled();
|
96
|
+
expect(store).toBe(mockCALStore);
|
97
|
+
});
|
98
|
+
|
99
|
+
it("should prioritize CAL integration over feature flags", () => {
|
100
|
+
isCALIntegrationEnabledSpy.mockReturnValue(true);
|
101
|
+
|
102
|
+
LiveConfig.setConfig({
|
103
|
+
feature_cal_lazy_loading: {
|
104
|
+
type: "boolean",
|
105
|
+
default: true,
|
106
|
+
},
|
107
|
+
});
|
108
|
+
|
109
|
+
const mockCALStore = {} as unknown as CryptoAssetsStore;
|
110
|
+
getCALStoreSpy.mockReturnValue(mockCALStore);
|
111
|
+
|
112
|
+
const store = getCryptoAssetsStore();
|
113
|
+
|
114
|
+
expect(store).toBe(mockCALStore);
|
115
|
+
expect(isCALIntegrationEnabledSpy).toHaveBeenCalled();
|
116
|
+
expect(getCALStoreSpy).toHaveBeenCalled();
|
117
|
+
});
|
71
118
|
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
2
2
|
import * as legacy from "@ledgerhq/cryptoassets/tokens";
|
3
3
|
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
4
|
+
import { isCALIntegrationEnabled, getCALStore } from "./cal-integration";
|
4
5
|
|
5
6
|
const legacyStore: CryptoAssetsStore = {
|
6
7
|
findTokenByAddress: legacy.findTokenByAddress,
|
@@ -17,6 +18,10 @@ export function setCryptoAssetsStore(store: CryptoAssetsStore) {
|
|
17
18
|
}
|
18
19
|
|
19
20
|
export function getCryptoAssetsStore(): CryptoAssetsStore {
|
21
|
+
if (isCALIntegrationEnabled()) {
|
22
|
+
return getCALStore();
|
23
|
+
}
|
24
|
+
|
20
25
|
const featureEnabled =
|
21
26
|
LiveConfig.isConfigSet() && LiveConfig.getValueByKey("feature_cal_lazy_loading");
|
22
27
|
if (!featureEnabled) {
|
@@ -1,16 +1,19 @@
|
|
1
1
|
import { createApi as createXrpApi } from "@ledgerhq/coin-xrp/api/index";
|
2
2
|
import { createApi as createStellarApi } from "@ledgerhq/coin-stellar/api/index";
|
3
|
+
import { createApi as createCantonApi } from "@ledgerhq/coin-canton/api/index";
|
4
|
+
import { createApi as createTronApi } from "@ledgerhq/coin-tron/api/index";
|
3
5
|
import { getCurrencyConfiguration } from "../../../config";
|
4
6
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
5
7
|
import { getNetworkAlpacaApi } from "./network/network-alpaca";
|
6
8
|
import { Api } from "@ledgerhq/coin-framework/api/types";
|
7
9
|
import { XrpCoinConfig } from "@ledgerhq/coin-xrp/config";
|
8
10
|
import { StellarCoinConfig } from "@ledgerhq/coin-stellar/config";
|
11
|
+
import { CantonCoinConfig } from "@ledgerhq/coin-canton/config";
|
12
|
+
import { TronCoinConfig } from "@ledgerhq/coin-tron/config";
|
9
13
|
|
10
14
|
export function getAlpacaApi(network, kind): Api<any> {
|
11
15
|
if (kind === "local") {
|
12
16
|
switch (network) {
|
13
|
-
case "ripple":
|
14
17
|
case "xrp":
|
15
18
|
return createXrpApi(
|
16
19
|
getCurrencyConfiguration<XrpCoinConfig>(getCryptoCurrencyById("ripple")),
|
@@ -19,6 +22,16 @@ export function getAlpacaApi(network, kind): Api<any> {
|
|
19
22
|
return createStellarApi(
|
20
23
|
getCurrencyConfiguration<StellarCoinConfig>(getCryptoCurrencyById("stellar")),
|
21
24
|
) as Api<any>;
|
25
|
+
case "canton":
|
26
|
+
return createCantonApi(
|
27
|
+
getCurrencyConfiguration<CantonCoinConfig>(
|
28
|
+
getCryptoCurrencyById("canton_network_devnet"),
|
29
|
+
),
|
30
|
+
) as Api<any>;
|
31
|
+
case "tron":
|
32
|
+
return createTronApi(
|
33
|
+
getCurrencyConfiguration<TronCoinConfig>(getCryptoCurrencyById("tron")),
|
34
|
+
) as Api<any>;
|
22
35
|
}
|
23
36
|
}
|
24
37
|
return getNetworkAlpacaApi(network) satisfies Partial<Api<any>> as Api<any>;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import { getAlpacaApi } from "./index";
|
2
|
+
import * as xrpModule from "@ledgerhq/coin-xrp/api/index";
|
3
|
+
import * as stellarModule from "@ledgerhq/coin-stellar/api/index";
|
4
|
+
import * as cantonModule from "@ledgerhq/coin-canton/api/index";
|
5
|
+
import * as tronModule from "@ledgerhq/coin-tron/api/index";
|
6
|
+
import * as config from "../../../config";
|
7
|
+
import * as networkApi from "./network/network-alpaca";
|
8
|
+
import * as cryptoAssets from "@ledgerhq/cryptoassets/currencies";
|
9
|
+
|
10
|
+
const mockApiInstance = { mock: "api" };
|
11
|
+
|
12
|
+
jest.mock("@ledgerhq/cryptoassets/currencies", () => ({
|
13
|
+
getCryptoCurrencyById: jest.fn(),
|
14
|
+
}));
|
15
|
+
|
16
|
+
jest.mock("../../../config", () => ({
|
17
|
+
getCurrencyConfiguration: jest.fn(),
|
18
|
+
}));
|
19
|
+
|
20
|
+
jest.mock("@ledgerhq/coin-xrp/api/index", () => ({
|
21
|
+
createApi: jest.fn(),
|
22
|
+
}));
|
23
|
+
|
24
|
+
jest.mock("@ledgerhq/coin-stellar/api/index", () => ({
|
25
|
+
createApi: jest.fn(),
|
26
|
+
}));
|
27
|
+
|
28
|
+
jest.mock("@ledgerhq/coin-canton/api/index", () => ({
|
29
|
+
createApi: jest.fn(),
|
30
|
+
}));
|
31
|
+
|
32
|
+
jest.mock("@ledgerhq/coin-tron/api/index", () => ({
|
33
|
+
createApi: jest.fn(),
|
34
|
+
}));
|
35
|
+
|
36
|
+
jest.mock("./network/network-alpaca", () => ({
|
37
|
+
getNetworkAlpacaApi: jest.fn(),
|
38
|
+
}));
|
39
|
+
|
40
|
+
describe("getAlpacaApi", () => {
|
41
|
+
const mockCurrency = { id: "mock-currency" };
|
42
|
+
|
43
|
+
beforeEach(() => {
|
44
|
+
jest.clearAllMocks();
|
45
|
+
|
46
|
+
// Common mocks
|
47
|
+
(cryptoAssets.getCryptoCurrencyById as jest.Mock).mockReturnValue(mockCurrency);
|
48
|
+
(config.getCurrencyConfiguration as jest.Mock).mockReturnValue({ config: true });
|
49
|
+
|
50
|
+
// API mocks
|
51
|
+
jest.spyOn(xrpModule, "createApi").mockReturnValue(mockApiInstance as any);
|
52
|
+
jest.spyOn(stellarModule, "createApi").mockReturnValue(mockApiInstance as any);
|
53
|
+
jest.spyOn(cantonModule, "createApi").mockReturnValue(mockApiInstance as any);
|
54
|
+
jest.spyOn(tronModule, "createApi").mockReturnValue(mockApiInstance as any);
|
55
|
+
jest.spyOn(networkApi, "getNetworkAlpacaApi").mockReturnValue(mockApiInstance as any);
|
56
|
+
});
|
57
|
+
|
58
|
+
const testCases = [
|
59
|
+
{ network: "xrp", module: xrpModule, label: "XRP" },
|
60
|
+
{ network: "stellar", module: stellarModule, label: "Stellar" },
|
61
|
+
{ network: "tron", module: tronModule, label: "Tron" },
|
62
|
+
{ network: "canton", module: cantonModule, label: "Canton" },
|
63
|
+
];
|
64
|
+
|
65
|
+
testCases.forEach(({ network, module, label }) => {
|
66
|
+
it(`should return ${label} API for network "${network}" and kind "local"`, () => {
|
67
|
+
const result = getAlpacaApi(network, "local");
|
68
|
+
expect(result).toEqual(mockApiInstance);
|
69
|
+
expect(module.createApi).toHaveBeenCalledWith({ config: true });
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
it("should return network API for kind !== 'local'", () => {
|
74
|
+
const result = getAlpacaApi("xrp", "remote");
|
75
|
+
expect(networkApi.getNetworkAlpacaApi).toHaveBeenCalledWith("xrp");
|
76
|
+
expect(result).toEqual(mockApiInstance);
|
77
|
+
});
|
78
|
+
});
|
@@ -13,6 +13,7 @@ import type {
|
|
13
13
|
Page,
|
14
14
|
Stake,
|
15
15
|
Reward,
|
16
|
+
CraftedTransaction,
|
16
17
|
} from "@ledgerhq/coin-framework/api/index";
|
17
18
|
import network from "@ledgerhq/live-network";
|
18
19
|
|
@@ -134,7 +135,7 @@ const buildGetSequence = (networkFamily: string) =>
|
|
134
135
|
const buildListOperations = networkFamily =>
|
135
136
|
async function listOperations(
|
136
137
|
address: string,
|
137
|
-
pagination: Pagination = { minHeight: 0 },
|
138
|
+
pagination: Pagination = { minHeight: 0, order: "asc" },
|
138
139
|
): Promise<[Operation<any>[], string]> {
|
139
140
|
const { data } = await network<{ operations: Operation<any>[] }, unknown>({
|
140
141
|
method: "GET",
|
@@ -160,8 +161,8 @@ const buildLastBlock = networkFamily =>
|
|
160
161
|
};
|
161
162
|
|
162
163
|
const buildCraftTransaction = networkFamily =>
|
163
|
-
async function craftTransaction(intent: TransactionIntent<any>): Promise<
|
164
|
-
const { data } = await network<
|
164
|
+
async function craftTransaction(intent: TransactionIntent<any>): Promise<CraftedTransaction> {
|
165
|
+
const { data } = await network<CraftedTransaction, unknown>({
|
165
166
|
method: "POST",
|
166
167
|
url: `${ALPACA_URL}/${networkFamily}/transaction/encode`,
|
167
168
|
data: {
|
@@ -171,7 +172,7 @@ const buildCraftTransaction = networkFamily =>
|
|
171
172
|
},
|
172
173
|
},
|
173
174
|
});
|
174
|
-
return data
|
175
|
+
return data;
|
175
176
|
};
|
176
177
|
|
177
178
|
export const getNetworkAlpacaApi = (networkFamily: string) =>
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import BigNumber from "bignumber.js";
|
2
|
-
import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
|
2
|
+
import { emptyHistoryCache, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
3
3
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
4
4
|
import type { Operation, SyncConfig, TokenAccount } from "@ledgerhq/types-live";
|
5
5
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
6
6
|
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets";
|
7
7
|
import { AssetInfo, Balance } from "@ledgerhq/coin-framework/api/types";
|
8
|
-
import { findTokenById } from "@ledgerhq/cryptoassets/tokens";
|
9
8
|
|
10
9
|
export interface OperationCommon extends Operation {
|
11
10
|
extra: Record<string, any>;
|
@@ -13,11 +12,6 @@ export interface OperationCommon extends Operation {
|
|
13
12
|
|
14
13
|
export const getAssetIdFromTokenId = (tokenId: string): string => tokenId.split("/")[2];
|
15
14
|
|
16
|
-
export const getAssetIdFromAsset = (asset: AssetInfo) =>
|
17
|
-
asset.type !== "native" && "assetReference" in asset && "assetOwner" in asset
|
18
|
-
? `${asset.assetReference}:${asset.assetOwner}`
|
19
|
-
: "";
|
20
|
-
|
21
15
|
function buildTokenAccount({
|
22
16
|
parentAccountId,
|
23
17
|
assetBalance,
|
@@ -29,8 +23,7 @@ function buildTokenAccount({
|
|
29
23
|
token: TokenCurrency;
|
30
24
|
operations: OperationCommon[];
|
31
25
|
}): TokenAccount {
|
32
|
-
const
|
33
|
-
const id = `${parentAccountId}+${assetId}`;
|
26
|
+
const id = encodeTokenAccountId(parentAccountId, token);
|
34
27
|
const balance = new BigNumber(assetBalance.value.toString() || "0");
|
35
28
|
|
36
29
|
// TODO: recheck this logic
|
@@ -68,12 +61,14 @@ export function buildSubAccounts({
|
|
68
61
|
assetsBalance,
|
69
62
|
syncConfig,
|
70
63
|
operations,
|
64
|
+
getTokenFromAsset,
|
71
65
|
}: {
|
72
66
|
currency: CryptoCurrency;
|
73
67
|
accountId: string;
|
74
68
|
assetsBalance: Balance[];
|
75
69
|
syncConfig: SyncConfig;
|
76
70
|
operations: OperationCommon[];
|
71
|
+
getTokenFromAsset?: (asset: AssetInfo) => TokenCurrency | undefined;
|
77
72
|
}): TokenAccount[] | undefined {
|
78
73
|
const { blacklistedTokenIds = [] } = syncConfig;
|
79
74
|
const allTokens = listTokensForCryptoCurrency(currency);
|
@@ -85,7 +80,7 @@ export function buildSubAccounts({
|
|
85
80
|
assetsBalance
|
86
81
|
.filter(b => b.asset.type !== "native") // NOTE: this could be removed, keeping here while fixing things up
|
87
82
|
.map(balance => {
|
88
|
-
const token =
|
83
|
+
const token = getTokenFromAsset && getTokenFromAsset(balance.asset);
|
89
84
|
// NOTE: for future tokens, will need to check over currencyName/standard(erc20,trc10,trc20, etc)/id
|
90
85
|
if (token && !blacklistedTokenIds.includes(token.id)) {
|
91
86
|
tokenAccounts.push(
|
@@ -104,7 +99,3 @@ export function buildSubAccounts({
|
|
104
99
|
});
|
105
100
|
return tokenAccounts;
|
106
101
|
}
|
107
|
-
|
108
|
-
export function findToken(currency: CryptoCurrency, balance: Balance): TokenCurrency | undefined {
|
109
|
-
return findTokenById(`${currency.family}/asset/${getAssetIdFromAsset(balance.asset)}`);
|
110
|
-
}
|
@@ -4,7 +4,6 @@ import BigNumber from "bignumber.js";
|
|
4
4
|
import { getAlpacaApi } from "./alpaca";
|
5
5
|
import { adaptCoreOperationToLiveOperation, extractBalance } from "./utils";
|
6
6
|
import { inferSubOperations } from "@ledgerhq/coin-framework/serialization";
|
7
|
-
import { findToken } from "./buildSubAccounts";
|
8
7
|
import { buildSubAccounts, OperationCommon } from "./buildSubAccounts";
|
9
8
|
|
10
9
|
export function genericGetAccountShape(network: string, kind: string): GetAccountShape {
|
@@ -33,8 +32,7 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
33
32
|
|
34
33
|
const assetsBalance = balanceRes
|
35
34
|
.filter(b => b.asset.type !== "native")
|
36
|
-
.filter(b =>
|
37
|
-
|
35
|
+
.filter(b => alpacaApi.getTokenFromAsset && alpacaApi.getTokenFromAsset(b.asset));
|
38
36
|
const nativeBalance = BigInt(nativeAsset?.value ?? "0");
|
39
37
|
|
40
38
|
const spendableBalance = BigInt(nativeBalance - BigInt(nativeAsset?.locked ?? "0"));
|
@@ -43,7 +41,7 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
43
41
|
const lastPagingToken = oldOps[0]?.extra?.pagingToken || "";
|
44
42
|
|
45
43
|
const blockHeight = oldOps.length ? (oldOps[0].blockHeight ?? 0) + 1 : 0;
|
46
|
-
const paginationParams: any = { minHeight: blockHeight };
|
44
|
+
const paginationParams: any = { minHeight: blockHeight, order: "asc" };
|
47
45
|
if (lastPagingToken) {
|
48
46
|
paginationParams.lastPagingToken = lastPagingToken;
|
49
47
|
}
|
@@ -72,6 +70,7 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
|
|
72
70
|
assetsBalance,
|
73
71
|
syncConfig,
|
74
72
|
operations: assetOperations,
|
73
|
+
getTokenFromAsset: alpacaApi.getTokenFromAsset,
|
75
74
|
}) || [];
|
76
75
|
|
77
76
|
const operationsWithSubs = mergedOps.map(op => {
|
@@ -3,7 +3,6 @@ import { AccountAwaitingSendPendingOperations } from "@ledgerhq/errors";
|
|
3
3
|
import BigNumber from "bignumber.js";
|
4
4
|
import { getAlpacaApi } from "./alpaca";
|
5
5
|
import { transactionToIntent } from "./utils";
|
6
|
-
// import { FeeEstimation } from "@ledgerhq/coin-framework/api/types";
|
7
6
|
|
8
7
|
// => alpaca validateIntent
|
9
8
|
export function genericGetTransactionStatus(
|
@@ -2,27 +2,41 @@ import { Account, AccountBridge, TransactionCommon } from "@ledgerhq/types-live"
|
|
2
2
|
import { getAlpacaApi } from "./alpaca";
|
3
3
|
import { transactionToIntent } from "./utils";
|
4
4
|
import BigNumber from "bignumber.js";
|
5
|
-
import { FeeEstimation } from "@ledgerhq/coin-framework/api/types";
|
5
|
+
import { AssetInfo, FeeEstimation } from "@ledgerhq/coin-framework/api/types";
|
6
|
+
import { decodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
7
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
6
8
|
|
7
9
|
function bnEq(a: BigNumber | null | undefined, b: BigNumber | null | undefined): boolean {
|
8
10
|
return !a && !b ? true : !a || !b ? false : a.eq(b);
|
9
11
|
}
|
10
12
|
|
13
|
+
type TransactionParam = TransactionCommon & {
|
14
|
+
fees: BigNumber | null | undefined;
|
15
|
+
customFees?: FeeEstimation;
|
16
|
+
assetReference?: string;
|
17
|
+
assetOwner?: string;
|
18
|
+
subAccountId?: string;
|
19
|
+
};
|
20
|
+
|
21
|
+
function assetInfosFallback(transaction: TransactionParam): {
|
22
|
+
assetReference: string;
|
23
|
+
assetOwner: string;
|
24
|
+
} {
|
25
|
+
return {
|
26
|
+
assetReference: transaction.assetReference ?? "",
|
27
|
+
assetOwner: transaction.assetOwner ?? "",
|
28
|
+
};
|
29
|
+
}
|
30
|
+
|
11
31
|
export function genericPrepareTransaction(
|
12
32
|
network: string,
|
13
33
|
kind,
|
14
34
|
): AccountBridge<TransactionCommon, Account, any, any>["prepareTransaction"] {
|
15
|
-
return async (
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
assetReference?: string;
|
21
|
-
assetOwner?: string;
|
22
|
-
subAccountId?: string;
|
23
|
-
},
|
24
|
-
) => {
|
25
|
-
const [assetReference, assetOwner] = getAssetInfos(transaction);
|
35
|
+
return async (account, transaction: TransactionParam) => {
|
36
|
+
const { getAssetFromToken } = getAlpacaApi(network, kind);
|
37
|
+
const { assetReference, assetOwner } = getAssetFromToken
|
38
|
+
? getAssetInfos(transaction, account.freshAddress, getAssetFromToken)
|
39
|
+
: assetInfosFallback(transaction);
|
26
40
|
|
27
41
|
let fees = transaction.customFees?.parameters?.fees || null;
|
28
42
|
if (fees === null) {
|
@@ -54,11 +68,24 @@ export function genericPrepareTransaction(
|
|
54
68
|
}
|
55
69
|
|
56
70
|
export function getAssetInfos(
|
57
|
-
tr:
|
58
|
-
|
71
|
+
tr: TransactionParam,
|
72
|
+
owner: string,
|
73
|
+
getAssetFromToken: (token: TokenCurrency, owner: string) => AssetInfo,
|
74
|
+
): {
|
75
|
+
assetReference: string;
|
76
|
+
assetOwner: string;
|
77
|
+
} {
|
59
78
|
if (tr.subAccountId) {
|
60
|
-
const
|
61
|
-
|
79
|
+
const { token } = decodeTokenAccountId(tr.subAccountId);
|
80
|
+
|
81
|
+
if (!token) return assetInfosFallback(tr);
|
82
|
+
|
83
|
+
const asset = getAssetFromToken(token, owner);
|
84
|
+
|
85
|
+
return {
|
86
|
+
assetOwner: ("assetOwner" in asset && asset.assetOwner) || "",
|
87
|
+
assetReference: ("assetReference" in asset && asset.assetReference) || "",
|
88
|
+
};
|
62
89
|
}
|
63
|
-
return
|
90
|
+
return assetInfosFallback(tr);
|
64
91
|
}
|
@@ -123,7 +123,7 @@ export const genericSignOperation =
|
|
123
123
|
transactionIntent.sequence = sequenceNumber;
|
124
124
|
|
125
125
|
/* Craft unsigned blob via Alpaca */
|
126
|
-
const
|
126
|
+
const { transaction: unsigned } = await getAlpacaApi(network, kind).craftTransaction(
|
127
127
|
transactionIntent,
|
128
128
|
{ value: fees },
|
129
129
|
);
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import { adaptCoreOperationToLiveOperation, extractBalance } from "./utils";
|
2
|
+
import BigNumber from "bignumber.js";
|
3
|
+
import { Operation as CoreOperation } from "@ledgerhq/coin-framework/api/types";
|
4
|
+
|
5
|
+
describe("Alpaca utils", () => {
|
6
|
+
describe("extractBalance", () => {
|
7
|
+
it("extracts an existing balance", () => {
|
8
|
+
expect(extractBalance([{ value: 4n, asset: { type: "type1" } }], "type1")).toEqual({
|
9
|
+
value: 4n,
|
10
|
+
asset: { type: "type1" },
|
11
|
+
});
|
12
|
+
});
|
13
|
+
|
14
|
+
it("generates an empty balance for a missing type", () => {
|
15
|
+
expect(extractBalance([{ value: 4n, asset: { type: "type1" } }], "type2")).toEqual({
|
16
|
+
value: 0n,
|
17
|
+
asset: { type: "type2" },
|
18
|
+
});
|
19
|
+
});
|
20
|
+
});
|
21
|
+
|
22
|
+
jest.mock("@ledgerhq/coin-framework/operation", () => ({
|
23
|
+
encodeOperationId: jest.fn((accountId, txHash, opType) => `${accountId}-${txHash}-${opType}`),
|
24
|
+
}));
|
25
|
+
|
26
|
+
describe("adaptCoreOperationToLiveOperation", () => {
|
27
|
+
const accountId = "acc_123";
|
28
|
+
const baseOp: CoreOperation = {
|
29
|
+
id: "op_123",
|
30
|
+
asset: { type: "native" },
|
31
|
+
type: "OUT",
|
32
|
+
value: BigInt(100),
|
33
|
+
tx: {
|
34
|
+
hash: "txhash123",
|
35
|
+
fees: BigInt(10),
|
36
|
+
block: {
|
37
|
+
hash: "blockhash123",
|
38
|
+
height: 123456,
|
39
|
+
},
|
40
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
41
|
+
},
|
42
|
+
senders: ["sender1"],
|
43
|
+
recipients: ["recipient1"],
|
44
|
+
};
|
45
|
+
|
46
|
+
it("does not include fees in non native asset value", () => {
|
47
|
+
expect(
|
48
|
+
adaptCoreOperationToLiveOperation("account", {
|
49
|
+
id: "operation",
|
50
|
+
asset: { type: "token", assetOwner: "owner", assetReference: "reference" },
|
51
|
+
type: "OUT",
|
52
|
+
value: BigInt(100),
|
53
|
+
tx: {
|
54
|
+
hash: "hash",
|
55
|
+
fees: BigInt(10),
|
56
|
+
block: {
|
57
|
+
hash: "block_hash",
|
58
|
+
height: 123456,
|
59
|
+
},
|
60
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
61
|
+
},
|
62
|
+
senders: ["sender"],
|
63
|
+
recipients: ["recipient"],
|
64
|
+
}),
|
65
|
+
).toEqual({
|
66
|
+
id: "account-hash-OUT",
|
67
|
+
hash: "hash",
|
68
|
+
accountId: "account",
|
69
|
+
type: "OUT",
|
70
|
+
value: new BigNumber(100), // value only
|
71
|
+
fee: new BigNumber(10),
|
72
|
+
extra: {
|
73
|
+
assetOwner: "owner",
|
74
|
+
assetReference: "reference",
|
75
|
+
},
|
76
|
+
blockHash: "block_hash",
|
77
|
+
blockHeight: 123456,
|
78
|
+
senders: ["sender"],
|
79
|
+
recipients: ["recipient"],
|
80
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
81
|
+
transactionSequenceNumber: undefined,
|
82
|
+
hasFailed: false,
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
it("adapts a basic OUT operation", () => {
|
87
|
+
const result = adaptCoreOperationToLiveOperation(accountId, baseOp);
|
88
|
+
|
89
|
+
expect(result).toEqual({
|
90
|
+
id: "acc_123-txhash123-OUT",
|
91
|
+
hash: "txhash123",
|
92
|
+
accountId,
|
93
|
+
type: "OUT",
|
94
|
+
value: new BigNumber(110), // value + fee
|
95
|
+
fee: new BigNumber(10),
|
96
|
+
blockHash: "blockhash123",
|
97
|
+
blockHeight: 123456,
|
98
|
+
senders: ["sender1"],
|
99
|
+
recipients: ["recipient1"],
|
100
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
101
|
+
transactionSequenceNumber: undefined,
|
102
|
+
hasFailed: false,
|
103
|
+
extra: {},
|
104
|
+
});
|
105
|
+
});
|
106
|
+
|
107
|
+
it("handles FEES operation where value = value + fees", () => {
|
108
|
+
const op = {
|
109
|
+
...baseOp,
|
110
|
+
type: "FEES",
|
111
|
+
value: BigInt(5),
|
112
|
+
tx: { ...baseOp.tx, fees: BigInt(2) },
|
113
|
+
};
|
114
|
+
|
115
|
+
const result = adaptCoreOperationToLiveOperation(accountId, op);
|
116
|
+
|
117
|
+
expect(result.value.toString()).toEqual("7");
|
118
|
+
});
|
119
|
+
|
120
|
+
it("handles non-FEES/OUT operation where value = value only", () => {
|
121
|
+
const op = {
|
122
|
+
...baseOp,
|
123
|
+
type: "IN",
|
124
|
+
value: BigInt(50),
|
125
|
+
tx: { ...baseOp.tx, fees: BigInt(2) },
|
126
|
+
};
|
127
|
+
|
128
|
+
const result = adaptCoreOperationToLiveOperation(accountId, op);
|
129
|
+
|
130
|
+
expect(result.value.toString()).toEqual("50");
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
@@ -44,15 +44,17 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
|
|
44
44
|
if (op.details?.memo) {
|
45
45
|
extra.memo = op.details.memo as string;
|
46
46
|
}
|
47
|
+
const bnFees = new BigNumber(op.tx.fees.toString());
|
47
48
|
const res = {
|
48
|
-
id:
|
49
|
-
? encodeOperationId(accountId, op.tx.hash, extra.ledgerOpType)
|
50
|
-
: encodeOperationId(accountId, op.tx.hash, op.type),
|
49
|
+
id: encodeOperationId(accountId, op.tx.hash, op.type),
|
51
50
|
hash: op.tx.hash,
|
52
51
|
accountId,
|
53
52
|
type: opType,
|
54
|
-
value:
|
55
|
-
|
53
|
+
value:
|
54
|
+
op.asset.type === "native" && ["OUT", "FEES"].includes(opType)
|
55
|
+
? new BigNumber(op.value.toString()).plus(bnFees)
|
56
|
+
: new BigNumber(op.value.toString()),
|
57
|
+
fee: bnFees,
|
56
58
|
blockHash: op.tx.block.hash,
|
57
59
|
blockHeight: op.tx.block.height,
|
58
60
|
senders: op.senders,
|