@ledgerhq/live-common 34.51.0-nightly.2 → 34.51.0-nightly.3
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/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +0 -2
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +0 -4
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/currencies/index.d.ts +1 -1
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +2 -3
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +1 -3
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +4 -0
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +4 -0
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +1 -0
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/AppInfos.js +1 -0
- package/lib/e2e/enum/AppInfos.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +2 -0
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +2 -0
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Network.d.ts +2 -1
- package/lib/e2e/enum/Network.d.ts.map +1 -1
- package/lib/e2e/enum/Network.js +1 -0
- package/lib/e2e/enum/Network.js.map +1 -1
- package/lib/e2e/enum/TokenType.d.ts +2 -1
- package/lib/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib/e2e/enum/TokenType.js +1 -0
- package/lib/e2e/enum/TokenType.js.map +1 -1
- package/lib/e2e/enum/TransactionStatus.d.ts +4 -1
- package/lib/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib/e2e/enum/TransactionStatus.js +3 -0
- package/lib/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib/e2e/families/sui.d.ts +2 -0
- package/lib/e2e/families/sui.d.ts.map +1 -0
- package/lib/e2e/families/sui.js +11 -0
- package/lib/e2e/families/sui.js.map +1 -0
- package/lib/e2e/index.d.ts +3 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts +1 -0
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +23 -1
- 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/providers/swap.js +4 -4
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.d.ts.map +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js.map +1 -1
- package/lib/exchange/swap/mock.js +1 -1
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +4 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/hooks/useManifestWithSessionId.d.ts +12 -0
- package/lib/hooks/useManifestWithSessionId.d.ts.map +1 -0
- package/lib/hooks/useManifestWithSessionId.js +67 -0
- package/lib/hooks/useManifestWithSessionId.js.map +1 -0
- package/lib/hooks/useManifestWithSessionId.test.d.ts +2 -0
- package/lib/hooks/useManifestWithSessionId.test.d.ts.map +1 -0
- package/lib/hooks/useManifestWithSessionId.test.js +71 -0
- package/lib/hooks/useManifestWithSessionId.test.js.map +1 -0
- package/lib/market/utils/index.d.ts +1 -0
- package/lib/market/utils/index.d.ts.map +1 -1
- package/lib/market/utils/index.js +16 -0
- package/lib/market/utils/index.js.map +1 -1
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js +350 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js.map +1 -0
- package/lib/modularDrawer/hooks/index.d.ts +2 -0
- package/lib/modularDrawer/hooks/index.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/index.js +6 -0
- package/lib/modularDrawer/hooks/index.js.map +1 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.d.ts +14 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.js +119 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +9 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +12 -4
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib/modularDrawer/index.d.ts +4 -0
- package/lib/modularDrawer/index.d.ts.map +1 -0
- package/lib/modularDrawer/index.js +20 -0
- package/lib/modularDrawer/index.js.map +1 -0
- package/lib/modularDrawer/types/detailedAccount.d.ts +46 -0
- package/lib/modularDrawer/types/detailedAccount.d.ts.map +1 -0
- package/lib/modularDrawer/types/detailedAccount.js +3 -0
- package/lib/modularDrawer/types/detailedAccount.js.map +1 -0
- package/lib/modularDrawer/types/index.d.ts +2 -0
- package/lib/modularDrawer/types/index.d.ts.map +1 -0
- package/lib/modularDrawer/types/index.js +18 -0
- package/lib/modularDrawer/types/index.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js +106 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js.map +1 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +3 -4
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +7 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
- package/lib/modularDrawer/utils/index.d.ts +1 -0
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +3 -1
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.d.ts +8 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.d.ts.map +1 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.js +17 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +2 -2
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/lib/wallet-api/useDappLogic.js +1 -1
- package/lib/wallet-api/useDappLogic.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +0 -2
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +0 -4
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/currencies/index.d.ts +1 -1
- package/lib-es/currencies/index.d.ts.map +1 -1
- package/lib-es/currencies/index.js +1 -1
- package/lib-es/currencies/index.js.map +1 -1
- package/lib-es/currencies/sortByMarketcap.test.js +1 -3
- package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +4 -0
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +4 -0
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +1 -0
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/AppInfos.js +1 -0
- package/lib-es/e2e/enum/AppInfos.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +2 -0
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +2 -0
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Network.d.ts +2 -1
- package/lib-es/e2e/enum/Network.d.ts.map +1 -1
- package/lib-es/e2e/enum/Network.js +1 -0
- package/lib-es/e2e/enum/Network.js.map +1 -1
- package/lib-es/e2e/enum/TokenType.d.ts +2 -1
- package/lib-es/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib-es/e2e/enum/TokenType.js +1 -0
- package/lib-es/e2e/enum/TokenType.js.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.d.ts +4 -1
- package/lib-es/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.js +3 -0
- package/lib-es/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib-es/e2e/families/sui.d.ts +2 -0
- package/lib-es/e2e/families/sui.d.ts.map +1 -0
- package/lib-es/e2e/families/sui.js +7 -0
- package/lib-es/e2e/families/sui.js.map +1 -0
- package/lib-es/e2e/index.d.ts +3 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts +1 -0
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +21 -0
- 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/providers/swap.js +4 -4
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.d.ts.map +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js.map +1 -1
- package/lib-es/exchange/swap/mock.js +1 -1
- package/lib-es/exchange/swap/mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +4 -0
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/hooks/useManifestWithSessionId.d.ts +12 -0
- package/lib-es/hooks/useManifestWithSessionId.d.ts.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.js +60 -0
- package/lib-es/hooks/useManifestWithSessionId.js.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.test.d.ts +2 -0
- package/lib-es/hooks/useManifestWithSessionId.test.d.ts.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.test.js +69 -0
- package/lib-es/hooks/useManifestWithSessionId.test.js.map +1 -0
- package/lib-es/market/utils/index.d.ts +1 -0
- package/lib-es/market/utils/index.d.ts.map +1 -1
- package/lib-es/market/utils/index.js +2 -0
- package/lib-es/market/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js +345 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/index.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/index.js +2 -0
- package/lib-es/modularDrawer/hooks/index.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.d.ts +14 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.js +115 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +6 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +9 -4
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib-es/modularDrawer/index.d.ts +4 -0
- package/lib-es/modularDrawer/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/index.js +4 -0
- package/lib-es/modularDrawer/index.js.map +1 -0
- package/lib-es/modularDrawer/types/detailedAccount.d.ts +46 -0
- package/lib-es/modularDrawer/types/detailedAccount.d.ts.map +1 -0
- package/lib-es/modularDrawer/types/detailedAccount.js +2 -0
- package/lib-es/modularDrawer/types/detailedAccount.js.map +1 -0
- package/lib-es/modularDrawer/types/index.d.ts +2 -0
- package/lib-es/modularDrawer/types/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/types/index.js +2 -0
- package/lib-es/modularDrawer/types/index.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js +101 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +3 -4
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +4 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
- package/lib-es/modularDrawer/utils/index.d.ts +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +1 -0
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.d.ts +8 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.js +13 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +2 -2
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/lib-es/wallet-api/useDappLogic.js +2 -2
- package/lib-es/wallet-api/useDappLogic.js.map +1 -1
- package/package.json +51 -51
- package/src/bridge/crypto-assets/index.test.ts +0 -4
- package/src/bridge/crypto-assets/index.ts +0 -2
- package/src/currencies/index.ts +1 -2
- package/src/currencies/sortByMarketcap.test.ts +1 -3
- package/src/e2e/enum/Account.ts +31 -0
- package/src/e2e/enum/AppInfos.ts +2 -0
- package/src/e2e/enum/Currency.ts +11 -0
- package/src/e2e/enum/Network.ts +1 -0
- package/src/e2e/enum/TokenType.ts +1 -0
- package/src/e2e/enum/TransactionStatus.ts +3 -0
- package/src/e2e/families/sui.ts +7 -0
- package/src/e2e/speculos.ts +23 -0
- package/src/exchange/providers/swap.ts +4 -4
- package/src/exchange/swap/api/v5/__mocks__/fetchRates.mocks.ts +1 -2
- package/src/exchange/swap/mock.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +5 -0
- package/src/hooks/useManifestWithSessionId.test.ts +105 -0
- package/src/hooks/useManifestWithSessionId.ts +83 -0
- package/src/market/utils/index.ts +3 -0
- package/src/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.ts +472 -0
- package/src/modularDrawer/hooks/index.ts +1 -0
- package/src/modularDrawer/hooks/useDetailedAccountsCore.ts +146 -0
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +5 -1
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +10 -4
- package/src/modularDrawer/index.ts +3 -0
- package/src/modularDrawer/types/detailedAccount.ts +49 -0
- package/src/modularDrawer/types/index.ts +1 -0
- package/src/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.ts +117 -0
- package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +6 -3
- package/src/modularDrawer/utils/index.ts +1 -0
- package/src/modularDrawer/utils/sortAccountsByFiatValue.ts +14 -0
- package/src/modularDrawer/utils/type.ts +3 -2
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/src/wallet-api/useDappLogic.ts +3 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { AccountLike } from "@ledgerhq/types-live";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base raw detailed account with unformatted values for UI formatting
|
|
7
|
+
* This is the shared interface that both mobile and desktop can extend
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseRawDetailedAccount {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
ticker: string;
|
|
13
|
+
balance: BigNumber;
|
|
14
|
+
balanceUnit: Unit;
|
|
15
|
+
fiatValue: number;
|
|
16
|
+
address: string;
|
|
17
|
+
cryptoId: string;
|
|
18
|
+
parentId?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extended detailed account that includes the original account references
|
|
23
|
+
* Used by mobile implementation that needs access to the full account objects
|
|
24
|
+
*/
|
|
25
|
+
export interface ExtendedRawDetailedAccount extends BaseRawDetailedAccount {
|
|
26
|
+
account: AccountLike;
|
|
27
|
+
parentAccount?: AccountLike;
|
|
28
|
+
protocol?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for formatting detailed accounts
|
|
33
|
+
*/
|
|
34
|
+
export interface DetailedAccountFormatConfig {
|
|
35
|
+
discreet?: boolean;
|
|
36
|
+
locale?: string;
|
|
37
|
+
showCode?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Parameters for creating detailed accounts
|
|
42
|
+
*/
|
|
43
|
+
export interface CreateDetailedAccountsParams {
|
|
44
|
+
asset: any; // CryptoOrTokenCurrency - avoiding import to keep this generic
|
|
45
|
+
accountTuples: any[]; // AccountTuple[] - avoiding import to keep this generic
|
|
46
|
+
accountNameMap: Record<string, string>;
|
|
47
|
+
isTokenCurrency: boolean;
|
|
48
|
+
formatConfig?: DetailedAccountFormatConfig;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./detailedAccount";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { sortAccountsByFiatValue } from "../sortAccountsByFiatValue";
|
|
2
|
+
import { BaseRawDetailedAccount } from "../../types/detailedAccount";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
|
|
5
|
+
const mockBalanceUnit = { name: "Ethereum", code: "ETH", magnitude: 18 };
|
|
6
|
+
|
|
7
|
+
const mockAccounts: BaseRawDetailedAccount[] = [
|
|
8
|
+
{
|
|
9
|
+
name: "Ethereum 1",
|
|
10
|
+
id: "js:2:ethereum:0xaDf49b9f133fb137e82b24F06D23E49c51f586C7:",
|
|
11
|
+
ticker: "ETH",
|
|
12
|
+
balance: new BigNumber("1.55699"),
|
|
13
|
+
balanceUnit: mockBalanceUnit,
|
|
14
|
+
fiatValue: 4149.62,
|
|
15
|
+
address: "0xaDf...586C7",
|
|
16
|
+
cryptoId: "ethereum",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "Ethereum 2",
|
|
20
|
+
id: "js:2:ethereum:0xd4b6595ff5f3c21E0b00edB8947A31110a9c4B8f:",
|
|
21
|
+
ticker: "ETH",
|
|
22
|
+
balance: new BigNumber("0.178403"),
|
|
23
|
+
balanceUnit: mockBalanceUnit,
|
|
24
|
+
fiatValue: 475.47,
|
|
25
|
+
address: "0xd4b...c4B8f",
|
|
26
|
+
cryptoId: "ethereum",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "Ethereum 3",
|
|
30
|
+
id: "js:2:ethereum:0x833eBB4bDa11da33a7F1C907C8171e5995Fe33c7:",
|
|
31
|
+
ticker: "ETH",
|
|
32
|
+
balance: new BigNumber("5.10589"),
|
|
33
|
+
balanceUnit: mockBalanceUnit,
|
|
34
|
+
fiatValue: 13607.93,
|
|
35
|
+
address: "0x833...e33c7",
|
|
36
|
+
cryptoId: "ethereum",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "Ethereum 4",
|
|
40
|
+
id: "js:2:ethereum:0xDbD543b0e80e0E73FbD49FDEe902FC59652753B9:",
|
|
41
|
+
ticker: "ETH",
|
|
42
|
+
balance: new BigNumber("0.00148572"),
|
|
43
|
+
balanceUnit: mockBalanceUnit,
|
|
44
|
+
fiatValue: 3.96,
|
|
45
|
+
address: "0xDbD...753B9",
|
|
46
|
+
cryptoId: "ethereum",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const expectedSortedAccounts = [
|
|
51
|
+
mockAccounts[2], // 13607.93
|
|
52
|
+
mockAccounts[0], // 4149.62
|
|
53
|
+
mockAccounts[1], // 475.47
|
|
54
|
+
mockAccounts[3], // 3.96
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
describe("sortAccountsByFiatValue", () => {
|
|
58
|
+
it("should sort accounts by fiat value in descending order", () => {
|
|
59
|
+
const sortedAccounts = sortAccountsByFiatValue(mockAccounts);
|
|
60
|
+
expect(sortedAccounts).toEqual(expectedSortedAccounts);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should handle empty accounts array", () => {
|
|
64
|
+
const sortedAccounts = sortAccountsByFiatValue([]);
|
|
65
|
+
expect(sortedAccounts).toEqual([]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should handle accounts with identical fiat values", () => {
|
|
69
|
+
const identicalAccounts = [
|
|
70
|
+
{ ...mockAccounts[0], fiatValue: 1000 },
|
|
71
|
+
{ ...mockAccounts[1], fiatValue: 1000 },
|
|
72
|
+
];
|
|
73
|
+
const sortedAccounts = sortAccountsByFiatValue(identicalAccounts);
|
|
74
|
+
expect(sortedAccounts).toEqual(identicalAccounts);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should handle accounts with zero fiat value", () => {
|
|
78
|
+
const zeroBalanceAccounts = [
|
|
79
|
+
{ ...mockAccounts[0], fiatValue: 0 },
|
|
80
|
+
{ ...mockAccounts[1], fiatValue: 10000 },
|
|
81
|
+
];
|
|
82
|
+
const sortedAccounts = sortAccountsByFiatValue(zeroBalanceAccounts);
|
|
83
|
+
expect(sortedAccounts).toEqual([zeroBalanceAccounts[1], zeroBalanceAccounts[0]]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should handle accounts with undefined fiat value", () => {
|
|
87
|
+
const undefinedFiatAccounts = [
|
|
88
|
+
{ ...mockAccounts[0], fiatValue: undefined as any },
|
|
89
|
+
{ ...mockAccounts[1], fiatValue: 5000 },
|
|
90
|
+
];
|
|
91
|
+
const sortedAccounts = sortAccountsByFiatValue(undefinedFiatAccounts);
|
|
92
|
+
expect(sortedAccounts).toEqual([undefinedFiatAccounts[1], undefinedFiatAccounts[0]]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should not mutate the original array", () => {
|
|
96
|
+
const originalAccounts = [...mockAccounts];
|
|
97
|
+
const sortedAccounts = sortAccountsByFiatValue(mockAccounts);
|
|
98
|
+
|
|
99
|
+
expect(mockAccounts).toEqual(originalAccounts);
|
|
100
|
+
expect(sortedAccounts).not.toBe(mockAccounts);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("should work with extended account types", () => {
|
|
104
|
+
interface ExtendedAccount extends BaseRawDetailedAccount {
|
|
105
|
+
customField: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const extendedAccounts: ExtendedAccount[] = [
|
|
109
|
+
{ ...mockAccounts[0], customField: "test1" },
|
|
110
|
+
{ ...mockAccounts[2], customField: "test2" },
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
const sortedAccounts = sortAccountsByFiatValue(extendedAccounts);
|
|
114
|
+
expect(sortedAccounts[0].customField).toBe("test2"); // Higher fiat value
|
|
115
|
+
expect(sortedAccounts[1].customField).toBe("test1"); // Lower fiat value
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -5,9 +5,9 @@ import { AccountLike } from "@ledgerhq/types-live";
|
|
|
5
5
|
import BigNumber from "bignumber.js";
|
|
6
6
|
import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
|
|
7
7
|
|
|
8
|
-
interface ExtendedAssetType extends AssetType {
|
|
9
|
-
currency
|
|
10
|
-
balance
|
|
8
|
+
export interface ExtendedAssetType extends AssetType {
|
|
9
|
+
currency: CryptoOrTokenCurrency;
|
|
10
|
+
balance: BigNumber;
|
|
11
11
|
fiatValue?: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -30,6 +30,9 @@ export const getBalanceAndFiatValueByAssets = (
|
|
|
30
30
|
id: asset.id,
|
|
31
31
|
name: asset.name,
|
|
32
32
|
ticker: asset.ticker,
|
|
33
|
+
currency: asset,
|
|
34
|
+
balance: new BigNumber(0),
|
|
35
|
+
fiatValue: 0,
|
|
33
36
|
};
|
|
34
37
|
});
|
|
35
38
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
export { groupCurrenciesByProvider } from "./groupCurrenciesByProvider";
|
|
3
|
+
export { sortAccountsByFiatValue } from "./sortAccountsByFiatValue";
|
|
3
4
|
|
|
4
5
|
function isCorrespondingCurrency(
|
|
5
6
|
elem: CryptoOrTokenCurrency,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseRawDetailedAccount } from "../types/detailedAccount";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sorts accounts by their fiat value in descending order
|
|
5
|
+
* @param accounts - List of accounts with fiat values to sort
|
|
6
|
+
* @returns Sorted list of accounts by fiat value balance in descending order
|
|
7
|
+
*/
|
|
8
|
+
export function sortAccountsByFiatValue<T extends BaseRawDetailedAccount>(accounts: T[]): T[] {
|
|
9
|
+
return [...accounts].sort((a, b) => {
|
|
10
|
+
const fiatValueA = a.fiatValue ?? 0;
|
|
11
|
+
const fiatValueB = b.fiatValue ?? 0;
|
|
12
|
+
return fiatValueB - fiatValueA;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -42,10 +42,10 @@ export type UseBalanceDeps = () => {
|
|
|
42
42
|
|
|
43
43
|
export type BalanceUI = {
|
|
44
44
|
// Raw values
|
|
45
|
-
balance
|
|
45
|
+
balance: BigNumber;
|
|
46
46
|
fiatValue?: number;
|
|
47
47
|
fiatUnit?: Unit;
|
|
48
|
-
currency
|
|
48
|
+
currency: CryptoOrTokenCurrency;
|
|
49
49
|
// Formatting parameters
|
|
50
50
|
locale?: string;
|
|
51
51
|
discreet?: boolean;
|
|
@@ -83,6 +83,7 @@ export type NetworkHookParams = {
|
|
|
83
83
|
networks: CryptoOrTokenCurrency[];
|
|
84
84
|
accounts$?: Observable<WalletAPIAccount[]>;
|
|
85
85
|
};
|
|
86
|
+
// Network hook type that returns currency properties spread at top level
|
|
86
87
|
export type NetworkHook = (
|
|
87
88
|
params: NetworkHookParams,
|
|
88
89
|
) => Array<CryptoOrTokenCurrency & Network & { balanceData?: BalanceUI; count?: number }>;
|
|
@@ -263,9 +263,9 @@
|
|
|
263
263
|
{
|
|
264
264
|
"id": "1inch",
|
|
265
265
|
"name": "1inch",
|
|
266
|
-
"url": "https://dapp-browser.apps.ledger.com/?params=%7B%22dappUrl%22%3A%22https%3A%2F%
|
|
266
|
+
"url": "https://dapp-browser.apps.ledger.com/?params=%7B%22dappUrl%22%3A%22https%3A%2F%2F1inch.com%2Fswap%2F%22%2C%22nanoApp%22%3A%221inch%22%2C%22dappName%22%3A%221inch%22%2C%22networks%22%3A%5B%7B%22currency%22%3A%22ethereum%22%2C%22chainID%22%3A1%2C%22nodeURL%22%3A%22wss%3A%2F%2Feth-mainnet.ws.alchemyapi.io%2Fv2%2F0fyudoTG94QWC0tEtfJViM9v2ZXJuij2%22%7D%2C%7B%22currency%22%3A%22bsc%22%2C%22chainID%22%3A56%2C%22nodeURL%22%3A%22https%3A%2F%2Fbsc-dataseed.binance.org%2F%22%7D%2C%7B%22currency%22%3A%22polygon%22%2C%22chainID%22%3A137%2C%22nodeURL%22%3A%22https%3A%2F%2Fpolygon-mainnet.g.alchemy.com%2Fv2%2FoPIxZM7kXsPVVY1Sk0kOQwkoIOpSu8PE%22%7D%5D%7D",
|
|
267
267
|
"params": {
|
|
268
|
-
"dappUrl": "https://
|
|
268
|
+
"dappUrl": "https://1inch.com/swap/",
|
|
269
269
|
"nanoApp": "1inch",
|
|
270
270
|
"dappName": "1inch",
|
|
271
271
|
"networks": [
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
}
|
|
287
287
|
]
|
|
288
288
|
},
|
|
289
|
-
"homepageUrl": "https://1inch.
|
|
289
|
+
"homepageUrl": "https://1inch.com/",
|
|
290
290
|
"icon": "https://cdn.live.ledger.com/icons/platform/1inch.png",
|
|
291
291
|
"platforms": ["ios", "android", "desktop"],
|
|
292
292
|
"apiVersion": "^1.0.0 || ~0.0.1",
|
|
@@ -8,7 +8,7 @@ import { getAccountBridge } from "../bridge";
|
|
|
8
8
|
import { getEnv } from "@ledgerhq/live-env";
|
|
9
9
|
import network from "@ledgerhq/live-network/network";
|
|
10
10
|
import { getWalletAPITransactionSignFlowInfos } from "./converters";
|
|
11
|
-
import {
|
|
11
|
+
import { findTokenByAddressInCurrency, getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
|
|
12
12
|
import { prepareMessageToSign } from "../hw/signMessage/index";
|
|
13
13
|
import { CurrentAccountHistDB, UiHook, usePermission } from "./react";
|
|
14
14
|
import BigNumber from "bignumber.js";
|
|
@@ -482,8 +482,6 @@ export function useDappLogic({
|
|
|
482
482
|
|
|
483
483
|
const transactionType = getTxType(signFlowInfos.liveTx as EvmTransaction);
|
|
484
484
|
|
|
485
|
-
const token = findTokenByAddress(tx.recipient);
|
|
486
|
-
|
|
487
485
|
const accountCurrencyName =
|
|
488
486
|
currentAccount.type === "TokenAccount"
|
|
489
487
|
? currentAccount.token.name
|
|
@@ -494,6 +492,8 @@ export function useDappLogic({
|
|
|
494
492
|
? currentAccount.token.parentCurrency.id
|
|
495
493
|
: currentAccount.currency.id;
|
|
496
494
|
|
|
495
|
+
const token = findTokenByAddressInCurrency(tx.recipient, accountNetwork);
|
|
496
|
+
|
|
497
497
|
trackingData = {
|
|
498
498
|
type: transactionType,
|
|
499
499
|
currency: token ? token.name : accountCurrencyName,
|