@ledgerhq/live-common 34.51.0-nightly.3 → 34.51.0-nightly.4
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 +2 -30
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +5 -34
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +2 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +1 -1
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/currencies/cryptoIcons.test.js +4 -1
- package/lib/currencies/cryptoIcons.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 +1 -3
- package/lib/currencies/index.js.map +1 -1
- package/lib/deposit/deposit.test.js +29 -12
- package/lib/deposit/deposit.test.js.map +1 -1
- package/lib/deposit/helper.d.ts.map +1 -1
- package/lib/deposit/helper.js +5 -1
- package/lib/deposit/helper.js.map +1 -1
- package/lib/exchange/swap/hooks/useFromState.test.js +4 -1
- package/lib/exchange/swap/hooks/useFromState.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useReverseAccounts.test.js +4 -1
- package/lib/exchange/swap/hooks/useReverseAccounts.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useToState.test.js +4 -1
- package/lib/exchange/swap/hooks/useToState.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.test.js +4 -1
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.test.js.map +1 -1
- package/lib/exchange/swap/utils/index.test.js +4 -1
- package/lib/exchange/swap/utils/index.test.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts +1 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +4 -1
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +2 -7
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +5 -11
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +2 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/currencies/cryptoIcons.test.js +5 -2
- package/lib-es/currencies/cryptoIcons.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/deposit/deposit.test.js +30 -13
- package/lib-es/deposit/deposit.test.js.map +1 -1
- package/lib-es/deposit/helper.d.ts.map +1 -1
- package/lib-es/deposit/helper.js +6 -2
- package/lib-es/deposit/helper.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useFromState.test.js +5 -2
- package/lib-es/exchange/swap/hooks/useFromState.test.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useReverseAccounts.test.js +5 -2
- package/lib-es/exchange/swap/hooks/useReverseAccounts.test.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useToState.test.js +5 -2
- package/lib-es/exchange/swap/hooks/useToState.test.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useUpdateMaxAmount.test.js +5 -2
- package/lib-es/exchange/swap/hooks/useUpdateMaxAmount.test.js.map +1 -1
- package/lib-es/exchange/swap/utils/index.test.js +5 -2
- package/lib-es/exchange/swap/utils/index.test.js.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.js +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +5 -2
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/package.json +40 -40
- package/src/bridge/crypto-assets/index.test.ts +9 -11
- package/src/bridge/crypto-assets/index.ts +2 -8
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +6 -4
- package/src/bridge/generic-alpaca/utils.ts +1 -2
- package/src/currencies/cryptoIcons.test.ts +4 -4
- package/src/currencies/index.ts +0 -2
- package/src/deposit/deposit.test.ts +29 -14
- package/src/deposit/helper.ts +6 -2
- package/src/exchange/swap/hooks/useFromState.test.ts +4 -2
- package/src/exchange/swap/hooks/useReverseAccounts.test.ts +4 -2
- package/src/exchange/swap/hooks/useToState.test.ts +4 -2
- package/src/exchange/swap/hooks/useUpdateMaxAmount.test.ts +4 -2
- package/src/exchange/swap/utils/index.test.ts +4 -2
- package/src/notifications/ServiceStatusProvider/index.tsx +1 -1
- package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
2
2
|
import { getCryptoAssetsStore, setCryptoAssetsStore } from ".";
|
|
3
|
-
import
|
|
3
|
+
import { legacyCryptoAssetsStore } from "@ledgerhq/cryptoassets/tokens";
|
|
4
4
|
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
|
5
5
|
|
|
6
6
|
describe("Testing CryptoAssetStore", () => {
|
|
@@ -13,11 +13,10 @@ describe("Testing CryptoAssetStore", () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const store = getCryptoAssetsStore();
|
|
16
|
-
expect(store).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
16
|
+
expect(store.findTokenById).toBe(legacyCryptoAssetsStore.findTokenById);
|
|
17
|
+
expect(store.findTokenByAddressInCurrency).toBe(
|
|
18
|
+
legacyCryptoAssetsStore.findTokenByAddressInCurrency,
|
|
19
|
+
);
|
|
21
20
|
});
|
|
22
21
|
|
|
23
22
|
it("should return the default methods from cryptoassets libs when feature flag is disabled", () => {
|
|
@@ -29,11 +28,10 @@ describe("Testing CryptoAssetStore", () => {
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
const store = getCryptoAssetsStore();
|
|
32
|
-
expect(store).
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
31
|
+
expect(store.findTokenById).toBe(legacyCryptoAssetsStore.findTokenById);
|
|
32
|
+
expect(store.findTokenByAddressInCurrency).toBe(
|
|
33
|
+
legacyCryptoAssetsStore.findTokenByAddressInCurrency,
|
|
34
|
+
);
|
|
37
35
|
});
|
|
38
36
|
|
|
39
37
|
it("should throw an error when no store is set and feature flag is enabled", () => {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
2
|
-
import
|
|
2
|
+
import { legacyCryptoAssetsStore } from "@ledgerhq/cryptoassets/tokens";
|
|
3
3
|
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
|
4
4
|
|
|
5
|
-
const legacyStore: CryptoAssetsStore = {
|
|
6
|
-
getTokenById: legacy.getTokenById,
|
|
7
|
-
findTokenById: legacy.findTokenById,
|
|
8
|
-
findTokenByAddressInCurrency: legacy.findTokenByAddressInCurrency,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
5
|
let cryptoAssetsStore: CryptoAssetsStore | undefined = undefined;
|
|
12
6
|
|
|
13
7
|
export function setCryptoAssetsStore(store: CryptoAssetsStore) {
|
|
@@ -18,7 +12,7 @@ export function getCryptoAssetsStore(): CryptoAssetsStore {
|
|
|
18
12
|
const featureEnabled =
|
|
19
13
|
LiveConfig.isConfigSet() && LiveConfig.getValueByKey("feature_cal_lazy_loading");
|
|
20
14
|
if (!featureEnabled) {
|
|
21
|
-
return
|
|
15
|
+
return legacyCryptoAssetsStore;
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
if (!cryptoAssetsStore) {
|
|
@@ -36,14 +36,16 @@ export function genericGetTransactionStatus(
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const { errors, warnings, estimatedFees, amount, totalSpent } =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const { errors, warnings, estimatedFees, amount, totalSpent, totalFees } =
|
|
40
|
+
await alpacaApi.validateIntent(
|
|
41
|
+
transactionToIntent(account, draftTransaction, alpacaApi.computeIntentType),
|
|
42
|
+
{ value: transaction.fees ? BigInt(transaction.fees.toString()) : 0n },
|
|
43
|
+
);
|
|
43
44
|
|
|
44
45
|
return {
|
|
45
46
|
errors,
|
|
46
47
|
warnings,
|
|
48
|
+
totalFees: typeof totalFees === "bigint" ? new BigNumber(totalFees.toString()) : undefined,
|
|
47
49
|
estimatedFees:
|
|
48
50
|
!transaction.fees || transaction.fees.isZero()
|
|
49
51
|
? new BigNumber(estimatedFees.toString())
|
|
@@ -141,8 +141,7 @@ export function transactionToIntent(
|
|
|
141
141
|
amount,
|
|
142
142
|
asset: { type: "native", name: account.currency.name, unit: account.currency.units[0] },
|
|
143
143
|
useAllAmount,
|
|
144
|
-
feesStrategy:
|
|
145
|
-
transaction.feesStrategy === "custom" ? undefined : transaction.feesStrategy ?? undefined,
|
|
144
|
+
feesStrategy: transaction.feesStrategy ?? undefined,
|
|
146
145
|
data: Buffer.isBuffer(transaction.data)
|
|
147
146
|
? { type: "buffer", value: transaction.data }
|
|
148
147
|
: { type: "none" },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
2
2
|
import { inferCryptoCurrencyIcon } from "./cryptoIcons";
|
|
3
|
-
import {
|
|
3
|
+
import { findTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
4
4
|
|
|
5
5
|
describe("inferCryptoCurrencyIcon", () => {
|
|
6
6
|
const registryMock = {
|
|
@@ -23,8 +23,8 @@ describe("inferCryptoCurrencyIcon", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test("USDT is inferred properly", () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
).toBe(4);
|
|
26
|
+
const usdt = findTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
27
|
+
if (!usdt) throw new Error("USDT token not found");
|
|
28
|
+
expect(inferCryptoCurrencyIcon(registryMock, usdt)).toBe(4);
|
|
29
29
|
});
|
|
30
30
|
});
|
package/src/currencies/index.ts
CHANGED
|
@@ -9,12 +9,12 @@ import { MOCK_TOKENS_ONLY, MOCK_WITH_TOKEN_AND_CURRENCY_ASSET, MOCK_IDS, MOCK_PO
|
|
|
9
9
|
import { MappedAsset } from "./type";
|
|
10
10
|
import {
|
|
11
11
|
getCryptoCurrencyById,
|
|
12
|
-
|
|
12
|
+
findTokenById,
|
|
13
13
|
setSupportedCurrencies,
|
|
14
14
|
sortCurrenciesByIds,
|
|
15
15
|
} from "../currencies/index";
|
|
16
16
|
import { isCurrencySupported, listSupportedCurrencies, listTokens } from "../currencies";
|
|
17
|
-
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
17
|
+
import { CryptoOrTokenCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
18
18
|
|
|
19
19
|
const TOKEN_ONLY_ASSETS = MOCK_TOKENS_ONLY as MappedAsset[];
|
|
20
20
|
|
|
@@ -107,7 +107,9 @@ describe("Deposit logic", () => {
|
|
|
107
107
|
|
|
108
108
|
describe("groupCurrenciesByProvider", () => {
|
|
109
109
|
test("should group currencies by provider", () => {
|
|
110
|
-
const currencies = TOKEN_ONLY_ASSETS.map(asset =>
|
|
110
|
+
const currencies = TOKEN_ONLY_ASSETS.map(asset => findTokenById(asset.ledgerId)).filter(
|
|
111
|
+
(t): t is TokenCurrency => t !== undefined,
|
|
112
|
+
);
|
|
111
113
|
const { currenciesByProvider } = groupCurrenciesByProvider(TOKEN_ONLY_ASSETS, currencies);
|
|
112
114
|
expect(currenciesByProvider).toEqual([
|
|
113
115
|
{
|
|
@@ -120,9 +122,9 @@ describe("Deposit logic", () => {
|
|
|
120
122
|
test("should handle POL assets correctly", () => {
|
|
121
123
|
const currenciesPol = MOCK_POL.map(asset =>
|
|
122
124
|
asset.$type === "Token"
|
|
123
|
-
?
|
|
125
|
+
? findTokenById(asset.ledgerId)
|
|
124
126
|
: getCryptoCurrencyById(asset.ledgerId),
|
|
125
|
-
);
|
|
127
|
+
).filter((c): c is CryptoOrTokenCurrency => c !== undefined);
|
|
126
128
|
const { currenciesByProvider: currenciesByProviderBis, sortedCryptoCurrencies } =
|
|
127
129
|
groupCurrenciesByProvider(MOCK_POL as MappedAsset[], currenciesPol);
|
|
128
130
|
expect(currenciesByProviderBis).toEqual([
|
|
@@ -136,7 +138,9 @@ describe("Deposit logic", () => {
|
|
|
136
138
|
});
|
|
137
139
|
|
|
138
140
|
test("should handle empty assets array", () => {
|
|
139
|
-
const currencies = TOKEN_ONLY_ASSETS.map(asset =>
|
|
141
|
+
const currencies = TOKEN_ONLY_ASSETS.map(asset => findTokenById(asset.ledgerId)).filter(
|
|
142
|
+
(t): t is TokenCurrency => t !== undefined,
|
|
143
|
+
);
|
|
140
144
|
const { currenciesByProvider, sortedCryptoCurrencies } = groupCurrenciesByProvider(
|
|
141
145
|
[],
|
|
142
146
|
currencies,
|
|
@@ -172,7 +176,8 @@ describe("Deposit logic", () => {
|
|
|
172
176
|
|
|
173
177
|
setSupportedCurrencies(["ethereum"]);
|
|
174
178
|
const ethCurrency = getCryptoCurrencyById("ethereum");
|
|
175
|
-
const tokenCurrency =
|
|
179
|
+
const tokenCurrency = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
180
|
+
if (!tokenCurrency) throw new Error("Token not found");
|
|
176
181
|
|
|
177
182
|
const { sortedCryptoCurrencies } = groupCurrenciesByProvider(mockAssets, [
|
|
178
183
|
tokenCurrency,
|
|
@@ -188,7 +193,9 @@ describe("Deposit logic", () => {
|
|
|
188
193
|
{ ...TOKEN_ONLY_ASSETS[0], ledgerId: "different-id" },
|
|
189
194
|
] as MappedAsset[];
|
|
190
195
|
|
|
191
|
-
const
|
|
196
|
+
const token = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
197
|
+
if (!token) throw new Error("Token not found");
|
|
198
|
+
const currencies = [token];
|
|
192
199
|
const { currenciesByProvider } = groupCurrenciesByProvider(duplicateAssets, currencies);
|
|
193
200
|
|
|
194
201
|
expect(currenciesByProvider).toHaveLength(1);
|
|
@@ -319,7 +326,7 @@ describe("Deposit logic", () => {
|
|
|
319
326
|
MOCK_TOKENS_ONLY as MappedAsset[],
|
|
320
327
|
currencies,
|
|
321
328
|
);
|
|
322
|
-
expect(sortedCryptoCurrencies).toEqual([
|
|
329
|
+
expect(sortedCryptoCurrencies).toEqual([findTokenById("polygon/erc20/(pos)_tether_usd")]);
|
|
323
330
|
});
|
|
324
331
|
|
|
325
332
|
it("should return only BSC token while its currency is supported in the list", () => {
|
|
@@ -333,7 +340,7 @@ describe("Deposit logic", () => {
|
|
|
333
340
|
MOCK_TOKENS_ONLY as MappedAsset[],
|
|
334
341
|
currencies,
|
|
335
342
|
);
|
|
336
|
-
expect(sortedCryptoCurrencies).toEqual([
|
|
343
|
+
expect(sortedCryptoCurrencies).toEqual([findTokenById("bsc/bep20/binance-peg_bsc-usd")]);
|
|
337
344
|
});
|
|
338
345
|
|
|
339
346
|
it("should return tokens that are actually supported based on mock data", () => {
|
|
@@ -596,7 +603,9 @@ describe("Deposit logic", () => {
|
|
|
596
603
|
{ ...TOKEN_ONLY_ASSETS[0], providerId: null as any },
|
|
597
604
|
] as MappedAsset[];
|
|
598
605
|
|
|
599
|
-
const
|
|
606
|
+
const token = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
607
|
+
if (!token) throw new Error("Token not found");
|
|
608
|
+
const currencies = [token];
|
|
600
609
|
|
|
601
610
|
expect(() => {
|
|
602
611
|
groupCurrenciesByProvider(malformedAssets, currencies);
|
|
@@ -608,7 +617,9 @@ describe("Deposit logic", () => {
|
|
|
608
617
|
{ ...TOKEN_ONLY_ASSETS[0], providerId: "" },
|
|
609
618
|
] as MappedAsset[];
|
|
610
619
|
|
|
611
|
-
const
|
|
620
|
+
const token = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
621
|
+
if (!token) throw new Error("Token not found");
|
|
622
|
+
const currencies = [token];
|
|
612
623
|
|
|
613
624
|
expect(() => {
|
|
614
625
|
groupCurrenciesByProvider(partiallyMalformedAssets, currencies);
|
|
@@ -624,7 +635,9 @@ describe("Deposit logic", () => {
|
|
|
624
635
|
providerId: `provider_${index % 10}`,
|
|
625
636
|
})) as MappedAsset[];
|
|
626
637
|
|
|
627
|
-
const
|
|
638
|
+
const token = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
639
|
+
if (!token) throw new Error("Token not found");
|
|
640
|
+
const currencies = [token];
|
|
628
641
|
|
|
629
642
|
const startTime = Date.now();
|
|
630
643
|
const result = groupCurrenciesByProvider(largeAssetList, currencies);
|
|
@@ -640,7 +653,9 @@ describe("Deposit logic", () => {
|
|
|
640
653
|
{ ...TOKEN_ONLY_ASSETS[0], ledgerId: TOKEN_ONLY_ASSETS[0].ledgerId.toUpperCase() },
|
|
641
654
|
] as MappedAsset[];
|
|
642
655
|
|
|
643
|
-
const
|
|
656
|
+
const token = findTokenById(TOKEN_ONLY_ASSETS[0].ledgerId);
|
|
657
|
+
if (!token) throw new Error("Token not found");
|
|
658
|
+
const currencies = [token];
|
|
644
659
|
const { currenciesByProvider } = groupCurrenciesByProvider(mixedCaseAssets, currencies);
|
|
645
660
|
|
|
646
661
|
expect(currenciesByProvider).toHaveLength(1);
|
package/src/deposit/helper.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { MappedAsset, CurrenciesByProviderId, GroupedCurrencies } from "./type";
|
|
|
3
3
|
import {
|
|
4
4
|
currenciesByMarketcap,
|
|
5
5
|
getCryptoCurrencyById,
|
|
6
|
-
|
|
6
|
+
findTokenById,
|
|
7
7
|
hasCryptoCurrencyId,
|
|
8
8
|
} from "../currencies";
|
|
9
9
|
import { getMappedAssets } from "./api";
|
|
@@ -75,5 +75,9 @@ export const getTokenOrCryptoCurrencyById = (id: string): CryptoOrTokenCurrency
|
|
|
75
75
|
if (hasCryptoCurrencyId(id)) {
|
|
76
76
|
return getCryptoCurrencyById(id);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
const token = findTokenById(id);
|
|
79
|
+
if (!token) {
|
|
80
|
+
throw new Error(`token with id "${id}" not found`);
|
|
81
|
+
}
|
|
82
|
+
return token;
|
|
79
83
|
};
|
|
@@ -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, findTokenById } from "@ledgerhq/cryptoassets";
|
|
6
6
|
import { Account } from "@ledgerhq/types-live";
|
|
7
7
|
import { renderHook, act } from "@testing-library/react";
|
|
8
8
|
import BigNumber from "bignumber.js";
|
|
@@ -14,7 +14,9 @@ import { useFromState } from "./useFromState";
|
|
|
14
14
|
|
|
15
15
|
const BTC = getCryptoCurrencyById("bitcoin");
|
|
16
16
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
17
|
-
const
|
|
17
|
+
const usdtToken = findTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
18
|
+
if (!usdtToken) throw new Error("USDT token not found");
|
|
19
|
+
const USDT = usdtToken;
|
|
18
20
|
|
|
19
21
|
jest.useFakeTimers();
|
|
20
22
|
|
|
@@ -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, findTokenById } from "@ledgerhq/cryptoassets";
|
|
6
6
|
import type { Account } from "@ledgerhq/types-live";
|
|
7
7
|
import { renderHook, act } from "@testing-library/react";
|
|
8
8
|
import { genTokenAccount } from "@ledgerhq/coin-framework/mocks/account";
|
|
@@ -11,7 +11,9 @@ import { useReverseAccounts } from "./useReverseAccounts";
|
|
|
11
11
|
|
|
12
12
|
const BTC = getCryptoCurrencyById("bitcoin");
|
|
13
13
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
14
|
-
const
|
|
14
|
+
const usdtToken = findTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
15
|
+
if (!usdtToken) throw new Error("USDT token not found");
|
|
16
|
+
const USDT = usdtToken;
|
|
15
17
|
|
|
16
18
|
const fromParentAccount = genAccount("mocked-account-2", {
|
|
17
19
|
currency: ETH,
|
|
@@ -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, findTokenById } 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,7 +12,9 @@ import type { Account } from "@ledgerhq/types-live";
|
|
|
12
12
|
|
|
13
13
|
const BTC = getCryptoCurrencyById("bitcoin");
|
|
14
14
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
15
|
-
const
|
|
15
|
+
const usdtToken = findTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
16
|
+
if (!usdtToken) throw new Error("USDT token not found");
|
|
17
|
+
const USDT = usdtToken;
|
|
16
18
|
|
|
17
19
|
const selectedAccount = genAccount("mocked-account-selected", { currency: ETH });
|
|
18
20
|
|
|
@@ -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, findTokenById } 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,7 +19,9 @@ 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
|
|
22
|
+
const usdtToken = findTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
23
|
+
if (!usdtToken) throw new Error("USDT token not found");
|
|
24
|
+
const USDT = usdtToken;
|
|
23
25
|
|
|
24
26
|
const parentAccount = genAccount("parent-account", {
|
|
25
27
|
currency: ETH,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findTokenById } from "@ledgerhq/cryptoassets";
|
|
2
2
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
3
|
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
@@ -87,7 +87,9 @@ describe("swap/utils/getAccountTuplesForCurrency", () => {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
describe("TokenCurrency", () => {
|
|
90
|
-
const
|
|
90
|
+
const token = findTokenById("ethereum/erc20/aave");
|
|
91
|
+
if (!token) throw new Error("AAVE token not found");
|
|
92
|
+
const aaveToken = Object.freeze(token);
|
|
91
93
|
|
|
92
94
|
test("returns correct parent accounts including a new subAccount when a TokenCurrency is provided", () => {
|
|
93
95
|
const ethAccounts = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCryptoCurrencyById,
|
|
1
|
+
import { getCryptoCurrencyById, findTokenById } from "@ledgerhq/cryptoassets";
|
|
2
2
|
import { genAccount } from "../../mock/account";
|
|
3
3
|
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
4
|
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
@@ -66,7 +66,9 @@ describe("getAccountTuplesForCurrency", () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
describe("TokenCurrency", () => {
|
|
69
|
-
const
|
|
69
|
+
const token = findTokenById("ethereum/erc20/aave");
|
|
70
|
+
if (!token) throw new Error("AAVE token not found");
|
|
71
|
+
const aaveToken = token;
|
|
70
72
|
|
|
71
73
|
test("returns correct parent accounts including a new subAccount when a TokenCurrency is provided", () => {
|
|
72
74
|
const ethAccounts = [
|