@ledgerhq/live-common 34.51.0-nightly.11 → 34.51.0-nightly.12
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/config/index.d.ts +2 -2
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js.map +1 -1
- package/lib/exchange/index.d.ts.map +1 -1
- package/lib/exchange/index.js +4 -15
- package/lib/exchange/index.js.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.d.ts +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.d.ts.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js +5 -5
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib/exchange/swap/hooks/useSelectableCurrencies.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useSelectableCurrencies.js +16 -4
- package/lib/exchange/swap/hooks/useSelectableCurrencies.js.map +1 -1
- package/lib/generated/specs.d.ts +1 -1
- package/lib/market/hooks/useLargeMoverChartData.d.ts +1 -2
- package/lib/market/hooks/useLargeMoverChartData.d.ts.map +1 -1
- package/lib/market/hooks/useLargeMoverChartData.js.map +1 -1
- package/lib/market/hooks/useLargeMoverCurrencies.d.ts +1 -2
- package/lib/market/hooks/useLargeMoverCurrencies.d.ts.map +1 -1
- package/lib/market/hooks/useLargeMoverCurrencies.js +1 -3
- package/lib/market/hooks/useLargeMoverCurrencies.js.map +1 -1
- package/lib/market/utils/currencyFormatter.d.ts +1 -1
- package/lib/market/utils/currencyFormatter.d.ts.map +1 -1
- package/lib/market/utils/currencyFormatter.js +1 -1
- package/lib/market/utils/currencyFormatter.js.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts +1 -1
- package/lib/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +1 -2
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +1 -1
- package/lib/wallet-api/constants.d.ts +2 -2
- package/lib-es/config/index.d.ts +2 -2
- package/lib-es/config/index.d.ts.map +1 -1
- package/lib-es/config/index.js.map +1 -1
- package/lib-es/exchange/index.d.ts.map +1 -1
- package/lib-es/exchange/index.js +4 -15
- package/lib-es/exchange/index.js.map +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.d.ts +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.d.ts.map +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.js +5 -5
- package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useSelectableCurrencies.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/useSelectableCurrencies.js +18 -6
- package/lib-es/exchange/swap/hooks/useSelectableCurrencies.js.map +1 -1
- package/lib-es/generated/specs.d.ts +1 -1
- package/lib-es/market/hooks/useLargeMoverChartData.d.ts +1 -2
- package/lib-es/market/hooks/useLargeMoverChartData.d.ts.map +1 -1
- package/lib-es/market/hooks/useLargeMoverChartData.js.map +1 -1
- package/lib-es/market/hooks/useLargeMoverCurrencies.d.ts +1 -2
- package/lib-es/market/hooks/useLargeMoverCurrencies.d.ts.map +1 -1
- package/lib-es/market/hooks/useLargeMoverCurrencies.js +1 -3
- package/lib-es/market/hooks/useLargeMoverCurrencies.js.map +1 -1
- package/lib-es/market/utils/currencyFormatter.d.ts +1 -1
- package/lib-es/market/utils/currencyFormatter.d.ts.map +1 -1
- package/lib-es/market/utils/currencyFormatter.js +1 -1
- package/lib-es/market/utils/currencyFormatter.js.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts +1 -1
- package/lib-es/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +1 -2
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +1 -1
- package/lib-es/wallet-api/constants.d.ts +2 -2
- package/package.json +40 -40
- package/src/bridge/cache.test.ts +2 -2
- package/src/config/index.ts +2 -4
- package/src/currencies/sortByMarketcap.test.ts +10 -7
- package/src/exchange/index.ts +4 -15
- package/src/exchange/swap/getCompleteSwapHistory.ts +5 -5
- package/src/exchange/swap/hooks/useFromState.test.ts +11 -4
- package/src/exchange/swap/hooks/useReverseAccounts.test.ts +11 -4
- package/src/exchange/swap/hooks/useSelectableCurrencies.test.ts +14 -8
- package/src/exchange/swap/hooks/useSelectableCurrencies.ts +23 -6
- package/src/exchange/swap/hooks/useToState.test.ts +11 -4
- package/src/exchange/swap/hooks/useUpdateMaxAmount.test.ts +11 -4
- package/src/exchange/swap/utils/index.test.ts +10 -4
- package/src/market/hooks/useLargeMoverChartData.ts +1 -2
- package/src/market/hooks/useLargeMoverCurrencies.ts +3 -6
- package/src/market/utils/currencyFormatter.ts +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { findCryptoCurrencyById
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { findCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
3
|
+
import { getCryptoAssetsStore } from "../../../bridge/crypto-assets/index";
|
|
3
4
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
5
|
|
|
5
6
|
export const useSelectableCurrencies = ({
|
|
@@ -7,10 +8,26 @@ export const useSelectableCurrencies = ({
|
|
|
7
8
|
}: {
|
|
8
9
|
allCurrencies: string[];
|
|
9
10
|
}): (TokenCurrency | CryptoCurrency)[] => {
|
|
10
|
-
const currencies =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const [currencies, setCurrencies] = useState<(TokenCurrency | CryptoCurrency)[]>([]);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const loadCurrencies = async () => {
|
|
15
|
+
const results = await Promise.all(
|
|
16
|
+
allCurrencies.map(async id => {
|
|
17
|
+
// Try token first, then crypto currency
|
|
18
|
+
const token = await getCryptoAssetsStore().findTokenById(id);
|
|
19
|
+
if (token) return token;
|
|
20
|
+
|
|
21
|
+
const crypto = findCryptoCurrencyById(id);
|
|
22
|
+
return crypto;
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const validCurrencies = results.filter(Boolean) as (TokenCurrency | CryptoCurrency)[];
|
|
27
|
+
setCurrencies(validCurrencies);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
loadCurrencies();
|
|
14
31
|
}, [allCurrencies]);
|
|
15
32
|
|
|
16
33
|
return currencies;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import "../../../__tests__/test-helpers/dom-polyfill";
|
|
5
5
|
import { renderHook, act } from "@testing-library/react";
|
|
6
|
-
import { getCryptoCurrencyById
|
|
6
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
7
7
|
import { selectorStateDefaultValues, useToState } from ".";
|
|
8
8
|
import { genTokenAccount } from "@ledgerhq/coin-framework/mocks/account";
|
|
9
9
|
import { genAccount } from "../../../mock/account";
|
|
@@ -12,9 +12,16 @@ import type { Account } from "@ledgerhq/types-live";
|
|
|
12
12
|
|
|
13
13
|
const BTC = getCryptoCurrencyById("bitcoin");
|
|
14
14
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const USDT = {
|
|
16
|
+
type: "TokenCurrency" as const,
|
|
17
|
+
id: "ethereum/erc20/usd_tether__erc20_",
|
|
18
|
+
name: "Tether USD (ERC-20)",
|
|
19
|
+
ticker: "USDT",
|
|
20
|
+
units: [{ name: "Tether USD", code: "USDT", magnitude: 6 }],
|
|
21
|
+
contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
22
|
+
parentCurrency: ETH,
|
|
23
|
+
tokenType: "erc20" as const,
|
|
24
|
+
};
|
|
18
25
|
|
|
19
26
|
const selectedAccount = genAccount("mocked-account-selected", { currency: ETH });
|
|
20
27
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
import "../../../__tests__/test-helpers/dom-polyfill";
|
|
5
|
-
import { getCryptoCurrencyById
|
|
5
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
6
6
|
import { act, renderHook } from "@testing-library/react";
|
|
7
7
|
import BigNumber from "bignumber.js";
|
|
8
8
|
import { checkAccountSupported } from "../../../account/index";
|
|
@@ -19,9 +19,16 @@ jest.mock("../../../families/evm/bridge/mock");
|
|
|
19
19
|
const mockedEstimateMaxSpendable = jest.mocked(ethBridge.accountBridge.estimateMaxSpendable);
|
|
20
20
|
|
|
21
21
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const USDT = {
|
|
23
|
+
type: "TokenCurrency" as const,
|
|
24
|
+
id: "ethereum/erc20/usd_tether__erc20_",
|
|
25
|
+
name: "Tether USD (ERC-20)",
|
|
26
|
+
ticker: "USDT",
|
|
27
|
+
units: [{ name: "Tether USD", code: "USDT", magnitude: 6 }],
|
|
28
|
+
contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
29
|
+
parentCurrency: ETH,
|
|
30
|
+
tokenType: "erc20" as const,
|
|
31
|
+
};
|
|
25
32
|
|
|
26
33
|
const parentAccount = genAccount("parent-account", {
|
|
27
34
|
currency: ETH,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { findTokenById } from "@ledgerhq/cryptoassets";
|
|
2
1
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
2
|
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
4
3
|
import BigNumber from "bignumber.js";
|
|
@@ -87,9 +86,16 @@ describe("swap/utils/getAccountTuplesForCurrency", () => {
|
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
describe("TokenCurrency", () => {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
const aaveToken = Object.freeze({
|
|
90
|
+
type: "TokenCurrency" as const,
|
|
91
|
+
id: "ethereum/erc20/aave",
|
|
92
|
+
name: "Aave Token",
|
|
93
|
+
ticker: "AAVE",
|
|
94
|
+
units: [{ name: "Aave Token", code: "AAVE", magnitude: 18 }],
|
|
95
|
+
contractAddress: "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
|
|
96
|
+
parentCurrency: getCryptoCurrencyById("ethereum"),
|
|
97
|
+
tokenType: "erc20" as const,
|
|
98
|
+
});
|
|
93
99
|
|
|
94
100
|
test("returns correct parent accounts including a new subAccount when a TokenCurrency is provided", () => {
|
|
95
101
|
const ethAccounts = [
|
|
@@ -2,7 +2,6 @@ import { useQueries } from "@tanstack/react-query";
|
|
|
2
2
|
import { fetchCurrencyChartData } from "../api";
|
|
3
3
|
import { QUERY_KEY } from "../utils/queryKeys";
|
|
4
4
|
import { REFETCH_TIME_ONE_MINUTE, BASIC_REFETCH } from "../utils/timers";
|
|
5
|
-
import { MarketCoinDataChart } from "../utils/types";
|
|
6
5
|
|
|
7
6
|
type UseLargeMoverChartDataParams = {
|
|
8
7
|
ids: string[];
|
|
@@ -29,7 +28,7 @@ export const useLargeMoverChartData = ({
|
|
|
29
28
|
|
|
30
29
|
const chartDataArray = ids.map((id, index) => ({
|
|
31
30
|
idChartData: id,
|
|
32
|
-
chartData: chartQueries[index]?.data
|
|
31
|
+
chartData: chartQueries[index]?.data,
|
|
33
32
|
isLoading: chartQueries[index]?.isLoading || false,
|
|
34
33
|
isError: chartQueries[index]?.isError || false,
|
|
35
34
|
}));
|
|
@@ -2,11 +2,8 @@ import { useQueries } from "@tanstack/react-query";
|
|
|
2
2
|
import { fetchCurrency } from "../api";
|
|
3
3
|
import { QUERY_KEY } from "../utils/queryKeys";
|
|
4
4
|
import { REFETCH_TIME_ONE_MINUTE, BASIC_REFETCH } from "../utils/timers";
|
|
5
|
-
import { MarketItemResponse
|
|
5
|
+
import { MarketItemResponse } from "../utils/types";
|
|
6
6
|
import { format } from "../utils/currencyFormatter";
|
|
7
|
-
import { listCryptoCurrencies } from "@ledgerhq/cryptoassets/currencies";
|
|
8
|
-
|
|
9
|
-
const cryptoCurrenciesList = [...listCryptoCurrencies()];
|
|
10
7
|
|
|
11
8
|
type UseLargeMoverCurrenciesParams = {
|
|
12
9
|
ids: string[];
|
|
@@ -23,13 +20,13 @@ export const useLargeMoverCurrencies = ({
|
|
|
23
20
|
queryFn: () => fetchCurrency({ id, counterCurrency }),
|
|
24
21
|
refetchInterval: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
|
25
22
|
staleTime: REFETCH_TIME_ONE_MINUTE * BASIC_REFETCH,
|
|
26
|
-
select: (data: MarketItemResponse) => format(data
|
|
23
|
+
select: (data: MarketItemResponse) => format(data),
|
|
27
24
|
})),
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
return ids.map((id, index) => ({
|
|
31
28
|
id,
|
|
32
|
-
data: currencyQueries[index]?.data
|
|
29
|
+
data: currencyQueries[index]?.data,
|
|
33
30
|
isLoading: currencyQueries[index]?.isLoading || false,
|
|
34
31
|
isError: currencyQueries[index]?.isError || false,
|
|
35
32
|
}));
|
|
@@ -54,11 +54,11 @@ export function currencyFormatter(
|
|
|
54
54
|
|
|
55
55
|
export const format = (
|
|
56
56
|
currency: MarketItemResponse,
|
|
57
|
-
cryptoCurrenciesList
|
|
57
|
+
cryptoCurrenciesList?: (CryptoCurrency | TokenCurrency)[],
|
|
58
58
|
): CurrencyData => {
|
|
59
59
|
const ledgerIdsSet = new Set(currency.ledgerIds.map(id => id.toLowerCase()));
|
|
60
60
|
|
|
61
|
-
const internalCurrency = cryptoCurrenciesList
|
|
61
|
+
const internalCurrency = cryptoCurrenciesList?.find(({ id }) =>
|
|
62
62
|
ledgerIdsSet.has(id.toLowerCase()),
|
|
63
63
|
);
|
|
64
64
|
|