@ledgerhq/live-common 34.50.0-nightly.4 → 34.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/test-helpers/bridge.js +1 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js +0 -3
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +4 -4
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.js +9 -7
- package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/createTransaction.js +0 -11
- package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +9 -15
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +2 -30
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.js +0 -37
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -2
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.js +1 -8
- package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +1 -15
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js +3 -5
- package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js +1 -1
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/types.d.ts +1 -1
- package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +2 -5
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +0 -1
- package/lib/bridge/impl.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +0 -6
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +0 -8
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +0 -2
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/AppInfos.js +0 -2
- package/lib/e2e/enum/AppInfos.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +0 -4
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +0 -6
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Network.d.ts +1 -3
- package/lib/e2e/enum/Network.d.ts.map +1 -1
- package/lib/e2e/enum/Network.js +0 -2
- package/lib/e2e/enum/Network.js.map +1 -1
- package/lib/e2e/enum/TokenType.d.ts +1 -2
- package/lib/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib/e2e/enum/TokenType.js +0 -1
- package/lib/e2e/enum/TokenType.js.map +1 -1
- package/lib/e2e/enum/TransactionStatus.d.ts +1 -4
- package/lib/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib/e2e/enum/TransactionStatus.js +0 -3
- package/lib/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib/e2e/speculos.d.ts +0 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +1 -35
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/exchange/platform/types.d.ts +0 -2
- package/lib/exchange/platform/types.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +1 -22
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js +0 -8
- package/lib/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib/families/tezos/react.d.ts +1 -2
- package/lib/families/tezos/react.d.ts.map +1 -1
- package/lib/families/tezos/react.js +1 -19
- package/lib/families/tezos/react.js.map +1 -1
- package/lib/families/tezos/setup.d.ts +4 -1
- package/lib/families/tezos/setup.d.ts.map +1 -1
- package/lib/families/tezos/setup.js +11 -3
- package/lib/families/tezos/setup.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 +12 -10
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/hw/actions/completeExchange.d.ts +0 -2
- package/lib/hw/actions/completeExchange.d.ts.map +1 -1
- package/lib/hw/actions/completeExchange.js +0 -1
- package/lib/hw/actions/completeExchange.js.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +3 -4
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +47 -13
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +5 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +55 -15
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -1
- package/lib/modularDrawer/modules/createAssetConfiguration.js +2 -2
- package/lib/modularDrawer/modules/createAssetConfiguration.js.map +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.js +3 -1
- package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +28 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.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/currencyUtils.d.ts.map +1 -1
- package/lib/modularDrawer/utils/currencyUtils.js.map +1 -1
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
- package/lib/modularDrawer/utils/getProviderCurrency.js +14 -0
- package/lib/modularDrawer/utils/getProviderCurrency.js.map +1 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.js +29 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
- package/lib/modularDrawer/utils/index.d.ts +6 -3
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +12 -3
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/modularDrawer/utils/index.test.js +26 -0
- package/lib/modularDrawer/utils/index.test.js.map +1 -1
- package/lib/modularDrawer/utils/type.d.ts +6 -0
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/wallet-api/constants.d.ts +1 -1
- package/lib/wallet-api/constants.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +1 -1
- package/lib-es/__tests__/test-helpers/bridge.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 +0 -3
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +4 -4
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +9 -7
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/createTransaction.js +0 -11
- package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +9 -15
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +2 -30
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.js +1 -38
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -2
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +0 -6
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +1 -15
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js +3 -5
- package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +1 -1
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/types.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +2 -5
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +0 -1
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +0 -6
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +0 -8
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +0 -2
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/AppInfos.js +0 -2
- package/lib-es/e2e/enum/AppInfos.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +0 -4
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +0 -6
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Network.d.ts +1 -3
- package/lib-es/e2e/enum/Network.d.ts.map +1 -1
- package/lib-es/e2e/enum/Network.js +0 -2
- package/lib-es/e2e/enum/Network.js.map +1 -1
- package/lib-es/e2e/enum/TokenType.d.ts +1 -2
- package/lib-es/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib-es/e2e/enum/TokenType.js +0 -1
- package/lib-es/e2e/enum/TokenType.js.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.d.ts +1 -4
- package/lib-es/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.js +0 -3
- package/lib-es/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts +0 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +0 -33
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/exchange/platform/types.d.ts +0 -2
- package/lib-es/exchange/platform/types.d.ts.map +1 -1
- package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/swap/completeExchange.js +1 -22
- package/lib-es/exchange/swap/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js +0 -8
- package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
- package/lib-es/families/tezos/react.d.ts +1 -2
- package/lib-es/families/tezos/react.d.ts.map +1 -1
- package/lib-es/families/tezos/react.js +0 -17
- package/lib-es/families/tezos/react.js.map +1 -1
- package/lib-es/families/tezos/setup.d.ts +4 -1
- package/lib-es/families/tezos/setup.d.ts.map +1 -1
- package/lib-es/families/tezos/setup.js +9 -2
- package/lib-es/families/tezos/setup.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/hw/actions/completeExchange.d.ts +0 -2
- package/lib-es/hw/actions/completeExchange.d.ts.map +1 -1
- package/lib-es/hw/actions/completeExchange.js +0 -1
- package/lib-es/hw/actions/completeExchange.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +3 -4
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +47 -13
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +5 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +55 -15
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -1
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js +2 -2
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +3 -1
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +26 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.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/currencyUtils.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -1
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +3 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.js +10 -0
- package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +1 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.js +25 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts +6 -3
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +10 -3
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/utils/index.test.js +27 -1
- package/lib-es/modularDrawer/utils/index.test.js.map +1 -1
- package/lib-es/modularDrawer/utils/type.d.ts +6 -0
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/wallet-api/constants.d.ts +1 -1
- package/lib-es/wallet-api/constants.d.ts.map +1 -1
- package/package.json +73 -75
- package/src/__tests__/test-helpers/bridge.ts +1 -1
- package/src/bridge/generic-alpaca/alpaca/index.ts +0 -4
- package/src/bridge/generic-alpaca/buildSubAccounts.ts +28 -28
- package/src/bridge/generic-alpaca/createTransaction.ts +0 -11
- package/src/bridge/generic-alpaca/getAccountShape.ts +15 -22
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +1 -1
- package/src/bridge/generic-alpaca/prepareTransaction.ts +2 -48
- package/src/bridge/generic-alpaca/signer/index.ts +1 -44
- package/src/bridge/generic-alpaca/signer/signTransaction.ts +0 -10
- package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +1 -15
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +3 -5
- package/src/bridge/generic-alpaca/tests/signOperation.test.ts +1 -1
- package/src/bridge/generic-alpaca/types.ts +1 -9
- package/src/bridge/generic-alpaca/utils.ts +2 -5
- package/src/bridge/impl.ts +0 -1
- package/src/e2e/enum/Account.ts +0 -41
- package/src/e2e/enum/AppInfos.ts +0 -4
- package/src/e2e/enum/Currency.ts +0 -21
- package/src/e2e/enum/Network.ts +0 -2
- package/src/e2e/enum/TokenType.ts +0 -1
- package/src/e2e/enum/TransactionStatus.ts +0 -3
- package/src/e2e/speculos.ts +0 -34
- package/src/exchange/platform/types.ts +0 -2
- package/src/exchange/swap/completeExchange.ts +2 -32
- package/src/exchange/swap/getIncompatibleCurrencyKeys.ts +0 -8
- package/src/families/tezos/react.ts +1 -20
- package/src/families/tezos/setup.ts +22 -3
- package/src/generated/bridge/js.ts +2 -0
- package/src/hw/actions/completeExchange.ts +0 -3
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +76 -16
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +95 -25
- package/src/modularDrawer/modules/createAssetConfiguration.ts +11 -3
- package/src/modularDrawer/modules/createNetworkConfiguration.ts +8 -1
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
- package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +34 -0
- package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +25 -0
- package/src/modularDrawer/utils/currencyUtils.ts +1 -0
- package/src/modularDrawer/utils/getProviderCurrency.ts +13 -0
- package/src/modularDrawer/utils/haveOneCommonProvider.ts +31 -0
- package/src/modularDrawer/utils/index.test.ts +32 -1
- package/src/modularDrawer/utils/index.ts +23 -4
- package/src/modularDrawer/utils/type.ts +6 -0
- package/lib/e2e/families/hedera.d.ts +0 -2
- package/lib/e2e/families/hedera.d.ts.map +0 -1
- package/lib/e2e/families/hedera.js +0 -11
- package/lib/e2e/families/hedera.js.map +0 -1
- package/lib/e2e/families/sui.d.ts +0 -2
- package/lib/e2e/families/sui.d.ts.map +0 -1
- package/lib/e2e/families/sui.js +0 -11
- package/lib/e2e/families/sui.js.map +0 -1
- package/lib/families/hedera/exchange.d.ts +0 -9
- package/lib/families/hedera/exchange.d.ts.map +0 -1
- package/lib/families/hedera/exchange.js +0 -36
- package/lib/families/hedera/exchange.js.map +0 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +0 -7
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +0 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -224
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +0 -1
- package/lib-es/e2e/families/hedera.d.ts +0 -2
- package/lib-es/e2e/families/hedera.d.ts.map +0 -1
- package/lib-es/e2e/families/hedera.js +0 -7
- package/lib-es/e2e/families/hedera.js.map +0 -1
- package/lib-es/e2e/families/sui.d.ts +0 -2
- package/lib-es/e2e/families/sui.d.ts.map +0 -1
- package/lib-es/e2e/families/sui.js +0 -7
- package/lib-es/e2e/families/sui.js.map +0 -1
- package/lib-es/families/hedera/exchange.d.ts +0 -9
- package/lib-es/families/hedera/exchange.d.ts.map +0 -1
- package/lib-es/families/hedera/exchange.js +0 -29
- package/lib-es/families/hedera/exchange.js.map +0 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +0 -7
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +0 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +0 -217
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +0 -1
- package/src/e2e/families/hedera.ts +0 -7
- package/src/e2e/families/sui.ts +0 -7
- package/src/families/hedera/exchange.ts +0 -48
- package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +0 -231
package/src/e2e/speculos.ts
CHANGED
@@ -28,7 +28,6 @@ import { sendStellar } from "./families/stellar";
|
|
28
28
|
import { delegateCardano, sendCardano } from "./families/cardano";
|
29
29
|
import { sendXRP } from "./families/xrp";
|
30
30
|
import { delegateAptos, sendAptos } from "./families/aptos";
|
31
|
-
import { sendHedera } from "./families/hedera";
|
32
31
|
import { delegateNear } from "./families/near";
|
33
32
|
import { delegateCosmos, sendCosmos } from "./families/cosmos";
|
34
33
|
import { sendKaspa } from "./families/kaspa";
|
@@ -42,7 +41,6 @@ import { Swap } from "./models/Swap";
|
|
42
41
|
import { delegateOsmosis } from "./families/osmosis";
|
43
42
|
import { AppInfos } from "./enum/AppInfos";
|
44
43
|
import { DEVICE_LABELS_CONFIG } from "./data/deviceLabelsData";
|
45
|
-
import { sendSui } from "./families/sui";
|
46
44
|
|
47
45
|
const isSpeculosRemote = process.env.REMOTE_SPECULOS === "true";
|
48
46
|
|
@@ -224,14 +222,6 @@ export const specs: Specs = {
|
|
224
222
|
},
|
225
223
|
dependency: "",
|
226
224
|
},
|
227
|
-
Sui: {
|
228
|
-
currency: getCryptoCurrencyById("sui"),
|
229
|
-
appQuery: {
|
230
|
-
model: getSpeculosModel(),
|
231
|
-
appName: "Sui",
|
232
|
-
},
|
233
|
-
dependency: "",
|
234
|
-
},
|
235
225
|
Bitcoin_Cash: {
|
236
226
|
currency: getCryptoCurrencyById("bitcoin_cash"),
|
237
227
|
appQuery: {
|
@@ -345,14 +335,6 @@ export const specs: Specs = {
|
|
345
335
|
},
|
346
336
|
dependency: "",
|
347
337
|
},
|
348
|
-
Hedera: {
|
349
|
-
currency: getCryptoCurrencyById("hedera"),
|
350
|
-
appQuery: {
|
351
|
-
model: getSpeculosModel(),
|
352
|
-
appName: "Hedera",
|
353
|
-
},
|
354
|
-
dependency: "",
|
355
|
-
},
|
356
338
|
};
|
357
339
|
|
358
340
|
export async function startSpeculos(
|
@@ -641,10 +623,6 @@ export async function goToSettings() {
|
|
641
623
|
await pressBoth();
|
642
624
|
}
|
643
625
|
|
644
|
-
export async function providePublicKey() {
|
645
|
-
await pressRightButton();
|
646
|
-
}
|
647
|
-
|
648
626
|
type DeviceLabelsReturn = {
|
649
627
|
delegateConfirmLabel: string;
|
650
628
|
delegateVerifyLabel: string;
|
@@ -673,9 +651,6 @@ export function getDeviceLabels(appInfo: AppInfos): DeviceLabelsReturn {
|
|
673
651
|
}
|
674
652
|
|
675
653
|
export async function expectValidAddressDevice(account: Account, addressDisplayed: string) {
|
676
|
-
if (account.currency === Currency.SUI_USDC) {
|
677
|
-
providePublicKey();
|
678
|
-
}
|
679
654
|
const { receiveVerifyLabel, receiveConfirmLabel } = getDeviceLabels(account.currency.speculosApp);
|
680
655
|
|
681
656
|
await waitFor(receiveVerifyLabel);
|
@@ -734,15 +709,6 @@ export async function signSendTransaction(tx: Transaction) {
|
|
734
709
|
case Currency.KAS:
|
735
710
|
await sendKaspa();
|
736
711
|
break;
|
737
|
-
case Currency.HBAR:
|
738
|
-
await sendHedera();
|
739
|
-
break;
|
740
|
-
case Currency.SUI:
|
741
|
-
await sendSui();
|
742
|
-
break;
|
743
|
-
case Currency.SUI_USDC:
|
744
|
-
await sendSui();
|
745
|
-
break;
|
746
712
|
default:
|
747
713
|
throw new Error(`Unsupported currency: ${currencyName.ticker}`);
|
748
714
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { DeviceModelId } from "@ledgerhq/devices";
|
2
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
2
|
import type { Account, AccountLike, AccountRaw, AccountRawLike } from "@ledgerhq/types-live";
|
4
3
|
import type { ExchangeTypes, RateTypes } from "@ledgerhq/hw-app-exchange";
|
@@ -43,7 +42,6 @@ export type StartExchangeInput = {
|
|
43
42
|
|
44
43
|
interface CompleteExchangeInputCommon {
|
45
44
|
rateType?: RateTypes;
|
46
|
-
deviceModelId?: DeviceModelId;
|
47
45
|
deviceId?: string;
|
48
46
|
provider: string;
|
49
47
|
binaryPayload: string;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { Account } from "@ledgerhq/types-live";
|
2
1
|
import {
|
3
2
|
DisconnectedDeviceDuringOperation,
|
4
3
|
TransportStatusError,
|
@@ -14,14 +13,12 @@ import {
|
|
14
13
|
import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName";
|
15
14
|
import { log } from "@ledgerhq/logs";
|
16
15
|
import BigNumber from "bignumber.js";
|
17
|
-
import invariant from "invariant";
|
18
16
|
import { Observable } from "rxjs";
|
19
17
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
20
18
|
import { getCurrencyExchangeConfig } from "../";
|
21
19
|
import { getAccountCurrency, getMainAccount } from "../../account";
|
22
20
|
import { getAccountBridge } from "../../bridge";
|
23
21
|
import { TransactionRefusedOnDevice } from "../../errors";
|
24
|
-
import { handleHederaTrustedFlow } from "../../families/hedera/exchange";
|
25
22
|
import { withDevicePromise } from "../../hw/deviceAccess";
|
26
23
|
import { delay } from "../../promise";
|
27
24
|
import { CompleteExchangeStep, convertTransportError } from "../error";
|
@@ -30,7 +27,6 @@ import { convertToAppExchangePartnerKey, getSwapProvider } from "../providers";
|
|
30
27
|
import { CEXProviderConfig } from "../providers/swap";
|
31
28
|
import { isAddressSanctioned } from "@ledgerhq/coin-framework/sanction/index";
|
32
29
|
import { AddressesSanctionedError } from "@ledgerhq/coin-framework/sanction/errors";
|
33
|
-
import { getCryptoCurrencyById } from "../../currencies";
|
34
30
|
|
35
31
|
const COMPLETE_EXCHANGE_LOG = "SWAP-CompleteExchange";
|
36
32
|
|
@@ -38,16 +34,8 @@ const completeExchange = (
|
|
38
34
|
input: CompleteExchangeInputSwap,
|
39
35
|
): Observable<CompleteExchangeRequestEvent> => {
|
40
36
|
let { transaction } = input; // TODO build a tx from the data
|
41
|
-
|
42
|
-
|
43
|
-
deviceModelId,
|
44
|
-
exchange,
|
45
|
-
provider,
|
46
|
-
binaryPayload,
|
47
|
-
signature,
|
48
|
-
rateType,
|
49
|
-
exchangeType,
|
50
|
-
} = input;
|
37
|
+
|
38
|
+
const { deviceId, exchange, provider, binaryPayload, signature, rateType, exchangeType } = input;
|
51
39
|
|
52
40
|
const { fromAccount, fromParentAccount } = exchange;
|
53
41
|
const { toAccount, toParentAccount } = exchange;
|
@@ -164,24 +152,6 @@ const completeExchange = (
|
|
164
152
|
await exchange.checkTransactionSignature(goodSign);
|
165
153
|
if (unsubscribed) return;
|
166
154
|
|
167
|
-
// Hedera swap payload is filled with user account address,
|
168
|
-
// but the device app requires the related public key for verification.
|
169
|
-
// Since this key is stored on-chain, we use the TrustedService
|
170
|
-
// to fetch a signed descriptor linking the address to its public key.
|
171
|
-
const hederaCurrency = getCryptoCurrencyById("hedera");
|
172
|
-
let hederaAccount: Account | null = null;
|
173
|
-
if (payoutAccount.currency.family === hederaCurrency.family) {
|
174
|
-
hederaAccount = payoutAccount;
|
175
|
-
} else if (refundAccount.currency.family === hederaCurrency.family) {
|
176
|
-
hederaAccount = refundAccount;
|
177
|
-
}
|
178
|
-
|
179
|
-
if (hederaAccount) {
|
180
|
-
invariant(deviceModelId, "hedera: deviceModelId is not available");
|
181
|
-
await handleHederaTrustedFlow({ exchange, hederaAccount, deviceModelId });
|
182
|
-
if (unsubscribed) return;
|
183
|
-
}
|
184
|
-
|
185
155
|
const payoutAddressParameters = payoutAccountBridge.getSerializedAddressParameters(
|
186
156
|
payoutAccount,
|
187
157
|
mainPayoutCurrency.id,
|
@@ -59,10 +59,6 @@ const INCOMPATIBLE_NANO_S_CURRENCY_KEYS: Keys = {
|
|
59
59
|
title: "swap.incompatibility.cosmos_title",
|
60
60
|
description: "swap.incompatibility.cosmos_description",
|
61
61
|
},
|
62
|
-
hedera: {
|
63
|
-
title: "swap.incompatibility.hedera_title",
|
64
|
-
description: "swap.incompatibility.hedera_description",
|
65
|
-
},
|
66
62
|
osmo: {
|
67
63
|
title: "swap.incompatibility.osmo_title",
|
68
64
|
description: "swap.incompatibility.osmo_description",
|
@@ -75,10 +71,6 @@ const INCOMPATIBLE_NANO_S_CURRENCY_KEYS: Keys = {
|
|
75
71
|
title: "swap.incompatibility.sui_title",
|
76
72
|
description: "swap.incompatibility.sui_description",
|
77
73
|
},
|
78
|
-
kaspa: {
|
79
|
-
title: "swap.incompatibility.kaspa_title",
|
80
|
-
description: "swap.incompatibility.kaspa_description",
|
81
|
-
},
|
82
74
|
};
|
83
75
|
|
84
76
|
export const getIncompatibleCurrencyKeys = (exchange: ExchangeSwap) => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AccountLike } from "@ledgerhq/types-live";
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
3
|
-
import { Baker, Delegation
|
3
|
+
import { Baker, Delegation } from "@ledgerhq/coin-tezos/types/index";
|
4
4
|
import { bakers } from "@ledgerhq/coin-tezos/network/index";
|
5
5
|
|
6
6
|
export function useBakers(whitelistAddresses: string[]): Baker[] {
|
@@ -55,22 +55,3 @@ export function useRandomBaker(bakers: Baker[]): Baker {
|
|
55
55
|
}, [bakers.length]);
|
56
56
|
return bakers[randomBakerIndex];
|
57
57
|
}
|
58
|
-
|
59
|
-
export function useStakingPositions(account: AccountLike): StakingPosition[] {
|
60
|
-
const delegation = useDelegation(account);
|
61
|
-
|
62
|
-
return useMemo(() => {
|
63
|
-
if (account.type !== "Account" || !delegation?.address) return [];
|
64
|
-
|
65
|
-
return [
|
66
|
-
{
|
67
|
-
uid: account.freshAddress,
|
68
|
-
address: account.freshAddress,
|
69
|
-
delegate: delegation.address,
|
70
|
-
state: "active" as const,
|
71
|
-
asset: { type: "native" as const },
|
72
|
-
amount: BigInt(account.balance.toString()),
|
73
|
-
},
|
74
|
-
];
|
75
|
-
}, [account, delegation]);
|
76
|
-
}
|
@@ -1,14 +1,24 @@
|
|
1
1
|
// Goal of this file is to inject all necessary device/signer dependency to coin-modules
|
2
2
|
|
3
3
|
import { DerivationType, LedgerSigner } from "@taquito/ledger-signer";
|
4
|
-
import
|
4
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
5
|
+
import { TezosCoinConfig } from "@ledgerhq/coin-tezos/config";
|
6
|
+
import { createBridges } from "@ledgerhq/coin-tezos/bridge/index";
|
7
|
+
import type {
|
8
|
+
Transaction,
|
9
|
+
TezosSigner,
|
10
|
+
TransactionStatus,
|
11
|
+
TezosAccount,
|
12
|
+
} from "@ledgerhq/coin-tezos/types/index";
|
5
13
|
import makeCliTools from "@ledgerhq/coin-tezos/test/cli";
|
6
14
|
import type { CliTools } from "@ledgerhq/coin-tezos/test/cli";
|
7
15
|
import tezosResolver from "@ledgerhq/coin-tezos/signer/index";
|
8
16
|
import Xtz, { Curve } from "@ledgerhq/hw-app-tezos";
|
9
17
|
import Transport from "@ledgerhq/hw-transport";
|
10
|
-
import {
|
18
|
+
import type { Bridge } from "@ledgerhq/types-live";
|
19
|
+
import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/setup";
|
11
20
|
import { Resolver } from "../../hw/getAddress/types";
|
21
|
+
import { getCurrencyConfiguration } from "../../config";
|
12
22
|
|
13
23
|
const createSigner: CreateSigner<TezosSigner> = (transport: Transport) => {
|
14
24
|
const xtz = new Xtz(transport);
|
@@ -36,8 +46,17 @@ const createSigner: CreateSigner<TezosSigner> = (transport: Transport) => {
|
|
36
46
|
};
|
37
47
|
};
|
38
48
|
|
49
|
+
const getCurrencyConfig = (): TezosCoinConfig => {
|
50
|
+
return getCurrencyConfiguration(getCryptoCurrencyById("tezos"));
|
51
|
+
};
|
52
|
+
|
53
|
+
const bridge: Bridge<Transaction, TezosAccount, TransactionStatus> = createBridges(
|
54
|
+
executeWithSigner(createSigner),
|
55
|
+
getCurrencyConfig,
|
56
|
+
);
|
57
|
+
|
39
58
|
const resolver: Resolver = createResolver(createSigner, tezosResolver);
|
40
59
|
|
41
60
|
const cliTools: CliTools = makeCliTools();
|
42
61
|
|
43
|
-
export { cliTools, resolver };
|
62
|
+
export { bridge, cliTools, resolver };
|
@@ -17,6 +17,7 @@ import { bridge as near } from "../../families/near/setup";
|
|
17
17
|
import { bridge as polkadot } from "../../families/polkadot/setup";
|
18
18
|
import { bridge as solana } from "../../families/solana/setup";
|
19
19
|
import { bridge as stacks } from "../../families/stacks/setup";
|
20
|
+
import { bridge as tezos } from "../../families/tezos/setup";
|
20
21
|
import { bridge as ton } from "../../families/ton/setup";
|
21
22
|
import { bridge as tron } from "../../families/tron/setup";
|
22
23
|
import { bridge as vechain } from "../../families/vechain/setup";
|
@@ -43,6 +44,7 @@ export default {
|
|
43
44
|
polkadot,
|
44
45
|
solana,
|
45
46
|
stacks,
|
47
|
+
tezos,
|
46
48
|
ton,
|
47
49
|
tron,
|
48
50
|
vechain,
|
@@ -3,7 +3,6 @@ import { scan, tap } from "rxjs/operators";
|
|
3
3
|
import { useEffect, useState } from "react";
|
4
4
|
import type { Action, Device } from "./types";
|
5
5
|
import type { AppState } from "./app";
|
6
|
-
import type { DeviceModelId } from "@ledgerhq/devices";
|
7
6
|
import { log } from "@ledgerhq/logs";
|
8
7
|
import { Exchange } from "../../exchange/types";
|
9
8
|
import { Transaction } from "../../generated/types";
|
@@ -19,7 +18,6 @@ type State = {
|
|
19
18
|
|
20
19
|
type CompleteExchangeState = AppState & State;
|
21
20
|
type CompleteExchangeRequest = {
|
22
|
-
deviceModelId?: DeviceModelId;
|
23
21
|
deviceId?: string;
|
24
22
|
provider: string;
|
25
23
|
transaction: Transaction;
|
@@ -132,7 +130,6 @@ export const createAction = (
|
|
132
130
|
}),
|
133
131
|
completeExchangeExec({
|
134
132
|
deviceId: reduxDeviceFrozen?.deviceId,
|
135
|
-
deviceModelId: reduxDeviceFrozen?.modelId,
|
136
133
|
provider,
|
137
134
|
transaction,
|
138
135
|
binaryPayload,
|
@@ -1,11 +1,15 @@
|
|
1
|
-
import { useMemo
|
1
|
+
import { useMemo } from "react";
|
2
|
+
import type { ReactNode } from "react";
|
2
3
|
import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
|
3
4
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
|
4
5
|
import BigNumber from "bignumber.js";
|
5
6
|
import { counterValueFormatter } from "../utils/counterValueFormatter";
|
6
7
|
import { compareByBalanceThenFiat } from "../utils/sortByBalance";
|
7
8
|
import { UseBalanceDeps } from "../utils/type";
|
9
|
+
import { buildProviderCurrenciesMap } from "../utils/buildProviderCurrenciesMap";
|
10
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
8
11
|
import { calculateProviderTotals } from "../utils/calculateProviderTotal";
|
12
|
+
import { getProviderCurrency } from "../utils/getProviderCurrency";
|
9
13
|
import { groupAccountsByAsset } from "../utils/groupAccountsByAsset";
|
10
14
|
|
11
15
|
export type AssetDeps = {
|
@@ -39,7 +43,10 @@ export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem, assets
|
|
39
43
|
return { balance, fiatValue };
|
40
44
|
};
|
41
45
|
|
42
|
-
return function useRightBalanceAsset(
|
46
|
+
return function useRightBalanceAsset(
|
47
|
+
assets: CryptoOrTokenCurrency[],
|
48
|
+
currenciesByProvider: CurrenciesByProviderId[],
|
49
|
+
) {
|
43
50
|
const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
|
44
51
|
|
45
52
|
const grouped = useMemo(
|
@@ -47,39 +54,92 @@ export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem, assets
|
|
47
54
|
[flattenedAccounts, state, counterValueCurrency, discreet],
|
48
55
|
);
|
49
56
|
|
57
|
+
const providerMap = useMemo(
|
58
|
+
() => buildProviderCurrenciesMap(currenciesByProvider),
|
59
|
+
[currenciesByProvider],
|
60
|
+
);
|
61
|
+
|
50
62
|
return useMemo(() => {
|
51
|
-
|
63
|
+
if (!providerMap) {
|
64
|
+
const balanceMap = new Map();
|
65
|
+
|
66
|
+
for (const [, { currencies, mainCurrency }] of assetsMap) {
|
67
|
+
const { totalBalance, totalFiatValue } = calculateProviderTotals(currencies, grouped);
|
52
68
|
|
53
|
-
|
54
|
-
|
69
|
+
const { balance, fiatValue } = formatProviderResult(
|
70
|
+
mainCurrency,
|
71
|
+
totalBalance,
|
72
|
+
totalFiatValue,
|
73
|
+
counterValueCurrency,
|
74
|
+
locale,
|
75
|
+
discreet,
|
76
|
+
);
|
77
|
+
|
78
|
+
balanceMap.set(mainCurrency.id, {
|
79
|
+
balance: balance,
|
80
|
+
fiatValue: fiatValue,
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
const assetsWithBalanceData = assets.map(asset => {
|
85
|
+
const balanceData = balanceMap.get(asset.id) || {};
|
86
|
+
return {
|
87
|
+
asset,
|
88
|
+
balanceData,
|
89
|
+
};
|
90
|
+
});
|
91
|
+
|
92
|
+
assetsWithBalanceData.sort((a, b) =>
|
93
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
94
|
+
);
|
95
|
+
|
96
|
+
return assetsWithBalanceData.map(({ asset, balanceData }) => ({
|
97
|
+
...asset,
|
98
|
+
rightElement: balanceItem(balanceData),
|
99
|
+
}));
|
100
|
+
}
|
101
|
+
|
102
|
+
const assetsSet = new Set(assets.map(a => a.id));
|
103
|
+
const providerResultsMap = new Map<string, { balance?: string; fiatValue?: string }>();
|
104
|
+
|
105
|
+
for (const [, { currencies, mainCurrency }] of providerMap) {
|
106
|
+
if (!assetsSet.has(mainCurrency.id)) continue;
|
107
|
+
const providerCurrency = getProviderCurrency(mainCurrency, currencies);
|
108
|
+
if (!providerCurrency) continue;
|
109
|
+
|
110
|
+
const { totalBalance, totalFiatValue, hasAccounts } = calculateProviderTotals(
|
111
|
+
currencies,
|
112
|
+
grouped,
|
113
|
+
);
|
114
|
+
if (!hasAccounts) continue;
|
55
115
|
|
56
116
|
const { balance, fiatValue } = formatProviderResult(
|
57
|
-
|
117
|
+
providerCurrency,
|
58
118
|
totalBalance,
|
59
119
|
totalFiatValue,
|
60
120
|
counterValueCurrency,
|
61
121
|
locale,
|
62
122
|
discreet,
|
63
123
|
);
|
64
|
-
|
65
|
-
balanceMap.set(mainCurrency.id, {
|
66
|
-
balance: balance,
|
67
|
-
fiatValue: fiatValue,
|
68
|
-
});
|
124
|
+
providerResultsMap.set(mainCurrency.id, { balance, fiatValue });
|
69
125
|
}
|
70
126
|
|
71
127
|
const assetsWithBalanceData = assets.map(asset => {
|
72
|
-
const balanceData =
|
128
|
+
const balanceData = providerResultsMap.get(asset.id) || {};
|
73
129
|
return {
|
74
|
-
|
130
|
+
asset,
|
75
131
|
balanceData,
|
76
|
-
rightElement: balanceItem(balanceData),
|
77
132
|
};
|
78
133
|
});
|
79
134
|
|
80
|
-
|
135
|
+
assetsWithBalanceData.sort((a, b) =>
|
81
136
|
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
82
137
|
);
|
83
|
-
|
138
|
+
|
139
|
+
return assetsWithBalanceData.map(({ asset, balanceData }) => ({
|
140
|
+
...asset,
|
141
|
+
rightElement: balanceItem(balanceData),
|
142
|
+
}));
|
143
|
+
}, [providerMap, assets, grouped, counterValueCurrency, locale, discreet]);
|
84
144
|
};
|
85
145
|
}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import { type ReactNode } from "react";
|
1
|
+
import { useMemo, type ReactNode } from "react";
|
2
2
|
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
3
|
import { compareByBalanceThenFiat } from "../utils/sortByBalance";
|
4
|
-
import { UseBalanceDeps } from "../utils/type";
|
4
|
+
import { BalanceUI, UseBalanceDeps } from "../utils/type";
|
5
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
5
6
|
import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
|
6
7
|
|
7
8
|
export type NetworkDeps = {
|
@@ -10,39 +11,108 @@ export type NetworkDeps = {
|
|
10
11
|
};
|
11
12
|
|
12
13
|
type Params = {
|
14
|
+
assets: CryptoOrTokenCurrency[];
|
13
15
|
networks: CryptoOrTokenCurrency[];
|
16
|
+
selectedAssetId: string;
|
17
|
+
currenciesByProvider: CurrenciesByProviderId[];
|
14
18
|
};
|
15
19
|
|
16
20
|
export function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }: NetworkDeps) {
|
17
|
-
return function useRightBalanceNetwork({
|
21
|
+
return function useRightBalanceNetwork({
|
22
|
+
assets: networks,
|
23
|
+
selectedAssetId,
|
24
|
+
currenciesByProvider,
|
25
|
+
networks: actualNetworks,
|
26
|
+
}: Params) {
|
18
27
|
const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
|
19
28
|
|
20
|
-
|
21
|
-
|
29
|
+
return useMemo(() => {
|
30
|
+
if (currenciesByProvider && currenciesByProvider.length > 0) {
|
31
|
+
const providerOfSelectedAsset = currenciesByProvider.find(provider =>
|
32
|
+
provider.currenciesByNetwork.some(currency => currency.id === selectedAssetId),
|
33
|
+
);
|
34
|
+
|
35
|
+
if (providerOfSelectedAsset) {
|
36
|
+
const pairs = networks.map(network => ({
|
37
|
+
network,
|
38
|
+
asset: providerOfSelectedAsset.currenciesByNetwork.find(currency =>
|
39
|
+
currency.type === "TokenCurrency"
|
40
|
+
? currency.parentCurrency.id === network.id
|
41
|
+
: currency.id === network.id,
|
42
|
+
),
|
43
|
+
}));
|
44
|
+
|
45
|
+
const validAssets = pairs.filter(p => p.asset).map(p => p.asset!);
|
46
|
+
|
47
|
+
const allBalanceData =
|
48
|
+
validAssets.length > 0
|
49
|
+
? getBalanceAndFiatValueByAssets(
|
50
|
+
flattenedAccounts,
|
51
|
+
validAssets,
|
52
|
+
state,
|
53
|
+
counterValueCurrency,
|
54
|
+
discreet,
|
55
|
+
locale,
|
56
|
+
)
|
57
|
+
: [];
|
58
|
+
|
59
|
+
const balanceMap = new Map(allBalanceData.map(b => [b.id, b]));
|
60
|
+
|
61
|
+
const networkWithBalanceData = pairs.map(({ network, asset }) => {
|
62
|
+
const balanceData: BalanceUI = asset ? balanceMap.get(asset.id) || {} : {};
|
63
|
+
return {
|
64
|
+
network,
|
65
|
+
balanceData,
|
66
|
+
};
|
67
|
+
});
|
68
|
+
|
69
|
+
networkWithBalanceData.sort((a, b) =>
|
70
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
71
|
+
);
|
72
|
+
|
73
|
+
return networkWithBalanceData.map(({ network, balanceData }) => ({
|
74
|
+
...network,
|
75
|
+
rightElement: balanceItem(balanceData),
|
76
|
+
}));
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
const networkBalanceData = getBalanceAndFiatValueByAssets(
|
81
|
+
flattenedAccounts,
|
82
|
+
actualNetworks,
|
83
|
+
state,
|
84
|
+
counterValueCurrency,
|
85
|
+
discreet,
|
86
|
+
locale,
|
87
|
+
);
|
88
|
+
|
89
|
+
const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
|
90
|
+
|
91
|
+
const networksWithBalance = actualNetworks.map(network => {
|
92
|
+
const balanceData = balanceMap.get(network.id) || {};
|
93
|
+
return {
|
94
|
+
network,
|
95
|
+
balanceData,
|
96
|
+
};
|
97
|
+
});
|
98
|
+
|
99
|
+
networksWithBalance.sort((a, b) =>
|
100
|
+
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
101
|
+
);
|
102
|
+
|
103
|
+
return networksWithBalance.map(({ network, balanceData }) => ({
|
104
|
+
...network,
|
105
|
+
rightElement: balanceItem(balanceData),
|
106
|
+
}));
|
107
|
+
}, [
|
22
108
|
networks,
|
109
|
+
selectedAssetId,
|
110
|
+
currenciesByProvider,
|
111
|
+
flattenedAccounts,
|
23
112
|
state,
|
24
113
|
counterValueCurrency,
|
25
114
|
discreet,
|
26
115
|
locale,
|
27
|
-
);
|
28
|
-
|
29
|
-
const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
|
30
|
-
|
31
|
-
const networksWithBalance = networks.map(network => {
|
32
|
-
const balanceData = balanceMap.get(network.id) || {};
|
33
|
-
return {
|
34
|
-
network,
|
35
|
-
balanceData,
|
36
|
-
};
|
37
|
-
});
|
38
|
-
|
39
|
-
networksWithBalance.sort((a, b) =>
|
40
|
-
compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
|
41
|
-
);
|
42
|
-
|
43
|
-
return networksWithBalance.map(({ network, balanceData }) => ({
|
44
|
-
...network,
|
45
|
-
rightElement: balanceItem(balanceData),
|
46
|
-
}));
|
116
|
+
]);
|
47
117
|
};
|
48
118
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
2
|
import { AssetType, CreateAssetConfigurationHook, AssetConfigurationDeps } from "../utils/type";
|
3
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
3
4
|
import { composeHooks } from "../../utils/composeHooks";
|
4
5
|
import { useLeftApyModule } from "../hooks/modules/useLeftApyModule";
|
5
6
|
import { createUseRightBalanceAsset } from "../hooks/useRightBalanceAsset";
|
@@ -45,7 +46,7 @@ const getLeftElement =
|
|
45
46
|
|
46
47
|
const createAssetConfigurationHook: CreateAssetConfigurationHook =
|
47
48
|
deps =>
|
48
|
-
({ assetsConfiguration }) => {
|
49
|
+
({ assetsConfiguration, currenciesByProvider }) => {
|
49
50
|
const { rightElement, leftElement } = assetsConfiguration ?? {};
|
50
51
|
|
51
52
|
const rightHook = getRightElement(deps)(rightElement);
|
@@ -53,11 +54,18 @@ const createAssetConfigurationHook: CreateAssetConfigurationHook =
|
|
53
54
|
|
54
55
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
55
56
|
const hooks = [rightHook, leftHook].filter(Boolean) as Array<
|
56
|
-
(
|
57
|
+
(
|
58
|
+
assets: CryptoOrTokenCurrency[],
|
59
|
+
currenciesByProvider?: CurrenciesByProviderId[],
|
60
|
+
) => AssetType[]
|
57
61
|
>;
|
58
62
|
|
59
63
|
return (assets: CryptoOrTokenCurrency[]) => {
|
60
|
-
const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(
|
64
|
+
const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(
|
65
|
+
...hooks.map(
|
66
|
+
hook => (assets: CryptoOrTokenCurrency[]) => hook(assets, currenciesByProvider),
|
67
|
+
),
|
68
|
+
);
|
61
69
|
return composedHook(assets);
|
62
70
|
};
|
63
71
|
};
|
@@ -53,7 +53,12 @@ export const getRightElement =
|
|
53
53
|
|
54
54
|
export const createNetworkConfigurationHook =
|
55
55
|
(NetworkConfigurationDeps: NetworkConfigurationDeps) =>
|
56
|
-
({
|
56
|
+
({
|
57
|
+
networksConfig,
|
58
|
+
selectedAssetId,
|
59
|
+
currenciesByProvider,
|
60
|
+
accounts$,
|
61
|
+
}: CreateNetworkConfigurationHookProps) => {
|
57
62
|
const { leftElement, rightElement } = networksConfig ?? {};
|
58
63
|
const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
|
59
64
|
const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
|
@@ -70,6 +75,8 @@ export const createNetworkConfigurationHook =
|
|
70
75
|
hook => () =>
|
71
76
|
hook({
|
72
77
|
assets,
|
78
|
+
selectedAssetId,
|
79
|
+
currenciesByProvider: currenciesByProvider || [],
|
73
80
|
accounts$,
|
74
81
|
networks,
|
75
82
|
}),
|
@@ -10,10 +10,10 @@ import {
|
|
10
10
|
safeCurrencyLookup,
|
11
11
|
} from "../currencyUtils";
|
12
12
|
import {
|
13
|
+
usdcToken,
|
13
14
|
mockBaseCryptoCurrency,
|
14
15
|
mockBtcCryptoCurrency,
|
15
16
|
mockEthCryptoCurrency,
|
16
|
-
usdcToken,
|
17
17
|
} from "../../__mocks__/currencies.mock";
|
18
18
|
|
19
19
|
describe("safeCurrencyLookup", () => {
|