@ledgerhq/live-common 34.53.0-nightly.20251118023800 → 34.53.0-nightly.20251119023741
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.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +0 -4
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +12 -10
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/deposit/type.d.ts +0 -17
- package/lib/deposit/type.d.ts.map +1 -1
- package/lib/deposit/type.js.map +1 -1
- package/lib/deviceSDK/tasks/core.d.ts +1 -1
- package/lib/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib/deviceSDK/tasks/core.js +1 -1
- package/lib/deviceSDK/tasks/core.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +0 -1
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +0 -1
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +0 -1
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +1 -5
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts +6 -0
- package/lib/e2e/enum/ReceiveFundsOptions.d.ts.map +1 -0
- package/lib/e2e/enum/ReceiveFundsOptions.js +8 -0
- package/lib/e2e/enum/ReceiveFundsOptions.js.map +1 -0
- package/lib/exchange/providers/swap.d.ts +1 -0
- package/lib/exchange/providers/swap.d.ts.map +1 -1
- package/lib/exchange/providers/swap.js +5 -1
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js +2 -3
- package/lib/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js +15 -10
- package/lib/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib/market/hooks/useMarketDataProvider.js +1 -0
- package/lib/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib/market/utils/types.d.ts +1 -0
- package/lib/market/utils/types.d.ts.map +1 -1
- package/lib/market/utils/types.js.map +1 -1
- package/lib/modularDrawer/utils/{groupCurrenciesByProvider.d.ts → groupCurrenciesByAsset.d.ts} +2 -2
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +1 -0
- package/lib/modularDrawer/utils/{groupCurrenciesByProvider.js → groupCurrenciesByAsset.js} +7 -7
- package/lib/modularDrawer/utils/groupCurrenciesByAsset.js.map +1 -0
- package/lib/modularDrawer/utils/index.d.ts +1 -1
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +3 -3
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/wallet-api/types.d.ts +3 -0
- package/lib/wallet-api/types.d.ts.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts +6 -0
- package/lib/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js +13 -3
- package/lib/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +0 -4
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +13 -11
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/deposit/type.d.ts +0 -17
- package/lib-es/deposit/type.d.ts.map +1 -1
- package/lib-es/deposit/type.js.map +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts +1 -1
- package/lib-es/deviceSDK/tasks/core.d.ts.map +1 -1
- package/lib-es/deviceSDK/tasks/core.js +1 -1
- package/lib-es/deviceSDK/tasks/core.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +0 -1
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +0 -1
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +0 -1
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +1 -5
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts +6 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.d.ts.map +1 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.js +5 -0
- package/lib-es/e2e/enum/ReceiveFundsOptions.js.map +1 -0
- package/lib-es/exchange/providers/swap.d.ts +1 -0
- package/lib-es/exchange/providers/swap.d.ts.map +1 -1
- package/lib-es/exchange/providers/swap.js +3 -0
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js +2 -3
- package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyAll.js.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js +17 -12
- package/lib-es/exchange/swap/hooks/v5/useFilteredProviders.js.map +1 -1
- package/lib-es/market/hooks/useMarketDataProvider.js +1 -0
- package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -1
- package/lib-es/market/utils/types.d.ts +1 -0
- package/lib-es/market/utils/types.d.ts.map +1 -1
- package/lib-es/market/utils/types.js.map +1 -1
- package/lib-es/modularDrawer/utils/{groupCurrenciesByProvider.d.ts → groupCurrenciesByAsset.d.ts} +2 -2
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/{groupCurrenciesByProvider.js → groupCurrenciesByAsset.js} +5 -5
- package/lib-es/modularDrawer/utils/groupCurrenciesByAsset.js.map +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts +1 -1
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +1 -1
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/wallet-api/types.d.ts +3 -0
- package/lib-es/wallet-api/types.d.ts.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts +6 -0
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.d.ts.map +1 -1
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js +11 -2
- package/lib-es/wallet-api/utils/deriveAccountIdForManifest.js.map +1 -1
- package/package.json +54 -54
- package/src/__tests__/test-helpers/bridge.ts +0 -2
- package/src/bridge/generic-alpaca/getAccountShape.ts +15 -12
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +142 -101
- package/src/deposit/type.ts +0 -21
- package/src/deviceSDK/tasks/core.test.ts +20 -0
- package/src/deviceSDK/tasks/core.ts +2 -1
- package/src/e2e/enum/Account.ts +0 -6
- package/src/e2e/enum/Currency.ts +1 -5
- package/src/e2e/enum/ReceiveFundsOptions.ts +7 -0
- package/src/exchange/providers/swap.ts +4 -0
- package/src/exchange/swap/hooks/v5/useFetchCurrencyAll.ts +2 -3
- package/src/exchange/swap/hooks/v5/useFilteredProviders.ts +37 -12
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +84 -12
- package/src/market/hooks/useMarketDataProvider.ts +1 -0
- package/src/market/utils/types.ts +1 -0
- package/src/modularDrawer/modules/__test__/createAssetConfiguration.test.tsx +2 -2
- package/src/modularDrawer/utils/__tests__/{groupCurrenciesByProvider.test.ts → groupCurrenciesByAsset.test.ts} +6 -6
- package/src/modularDrawer/utils/{groupCurrenciesByProvider.ts → groupCurrenciesByAsset.ts} +4 -4
- package/src/modularDrawer/utils/index.ts +1 -1
- package/src/wallet-api/types.ts +5 -0
- package/src/wallet-api/utils/deriveAccountIdForManifest.ts +14 -2
- package/lib/deposit/helper.d.ts +0 -8
- package/lib/deposit/helper.d.ts.map +0 -1
- package/lib/deposit/helper.js +0 -125
- package/lib/deposit/helper.js.map +0 -1
- package/lib/deposit/index.d.ts +0 -3
- package/lib/deposit/index.d.ts.map +0 -1
- package/lib/deposit/index.js +0 -6
- package/lib/deposit/index.js.map +0 -1
- package/lib/deposit/mock.d.ts +0 -75
- package/lib/deposit/mock.d.ts.map +0 -1
- package/lib/deposit/mock.js +0 -15111
- package/lib/deposit/mock.js.map +0 -1
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts +0 -3
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +0 -1
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js +0 -40
- package/lib/deposit/useGroupedCurrenciesByProvider.hook.js.map +0 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +0 -22
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +0 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +0 -41
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +0 -1
- package/lib/modularDrawer/utils/currencyUtils.d.ts +0 -10
- package/lib/modularDrawer/utils/currencyUtils.d.ts.map +0 -1
- package/lib/modularDrawer/utils/currencyUtils.js +0 -74
- package/lib/modularDrawer/utils/currencyUtils.js.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +0 -1
- package/lib/modularDrawer/utils/groupCurrenciesByProvider.js.map +0 -1
- package/lib-es/deposit/helper.d.ts +0 -8
- package/lib-es/deposit/helper.d.ts.map +0 -1
- package/lib-es/deposit/helper.js +0 -117
- package/lib-es/deposit/helper.js.map +0 -1
- package/lib-es/deposit/index.d.ts +0 -3
- package/lib-es/deposit/index.d.ts.map +0 -1
- package/lib-es/deposit/index.js +0 -3
- package/lib-es/deposit/index.js.map +0 -1
- package/lib-es/deposit/mock.d.ts +0 -75
- package/lib-es/deposit/mock.d.ts.map +0 -1
- package/lib-es/deposit/mock.js +0 -15108
- package/lib-es/deposit/mock.js.map +0 -1
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts +0 -3
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.d.ts.map +0 -1
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js +0 -36
- package/lib-es/deposit/useGroupedCurrenciesByProvider.hook.js.map +0 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +0 -22
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +0 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +0 -38
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +0 -1
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts +0 -10
- package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/currencyUtils.js +0 -65
- package/lib-es/modularDrawer/utils/currencyUtils.js.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/groupCurrenciesByProvider.js.map +0 -1
- package/src/deposit/deposit.integration.test.ts +0 -88
- package/src/deposit/deposit.test.ts +0 -684
- package/src/deposit/helper.ts +0 -143
- package/src/deposit/index.ts +0 -3
- package/src/deposit/mock.ts +0 -15112
- package/src/deposit/useGroupedCurrenciesByProvider.hook.ts +0 -46
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +0 -49
- package/src/modularDrawer/modules/__test__/createNetworkConfiguration.test.ts +0 -342
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +0 -126
- package/src/modularDrawer/utils/currencyUtils.ts +0 -95
package/src/e2e/enum/Currency.ts
CHANGED
|
@@ -156,10 +156,6 @@ export class Currency {
|
|
|
156
156
|
AppInfos.BNB_CHAIN,
|
|
157
157
|
[Network.BNB_CHAIN, Network.POLYGON],
|
|
158
158
|
);
|
|
159
|
-
static readonly BSC_SHIBA = new Currency("Shiba Inu", "SHIB", "bsc", AppInfos.BNB_CHAIN, [
|
|
160
|
-
Network.BNB_CHAIN,
|
|
161
|
-
Network.ETHEREUM,
|
|
162
|
-
]);
|
|
163
159
|
static readonly POL_DAI = new Currency(
|
|
164
160
|
"(PoS) Dai Stablecoin",
|
|
165
161
|
"DAI",
|
|
@@ -204,7 +200,7 @@ export class Currency {
|
|
|
204
200
|
static readonly SUI = new Currency("Sui", "SUI", "sui", AppInfos.SUI, [Network.SUI]);
|
|
205
201
|
|
|
206
202
|
static readonly SUI_USDC = new Currency(
|
|
207
|
-
"
|
|
203
|
+
"USD Coin",
|
|
208
204
|
"USDC",
|
|
209
205
|
"sui/coin/usdc_0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::usdc",
|
|
210
206
|
AppInfos.SUI,
|
|
@@ -328,3 +328,7 @@ export const getAvailableProviders = async (): Promise<string[]> => {
|
|
|
328
328
|
}
|
|
329
329
|
return Object.keys(await fetchAndMergeProviderData({ ledgerSignatureEnv, partnerSignatureEnv }));
|
|
330
330
|
};
|
|
331
|
+
|
|
332
|
+
export const getDefaultSwapProviderKeys = (): string[] => {
|
|
333
|
+
return Object.keys(DEFAULT_SWAP_PROVIDERS);
|
|
334
|
+
};
|
|
@@ -6,7 +6,7 @@ import { useFilteredProviders } from "./useFilteredProviders";
|
|
|
6
6
|
|
|
7
7
|
export function useFetchCurrencyAll() {
|
|
8
8
|
const fetchAdditionalCoins = useFeature("fetchAdditionalCoins");
|
|
9
|
-
const { providers,
|
|
9
|
+
const { providers, error } = useFilteredProviders();
|
|
10
10
|
|
|
11
11
|
const { data, ...rest } = useAPI({
|
|
12
12
|
queryFn: fetchCurrencyAll,
|
|
@@ -14,9 +14,8 @@ export function useFetchCurrencyAll() {
|
|
|
14
14
|
additionalCoinsFlag: fetchAdditionalCoins?.enabled,
|
|
15
15
|
providers,
|
|
16
16
|
},
|
|
17
|
-
// assume the all currency list for the given props won't change during a users session.
|
|
18
17
|
staleTimeout: FETCH_CURRENCIES_TIMEOUT_MS,
|
|
19
|
-
enabled: !
|
|
18
|
+
enabled: !error && providers.length > 0,
|
|
20
19
|
});
|
|
21
20
|
return {
|
|
22
21
|
...rest,
|
|
@@ -1,27 +1,52 @@
|
|
|
1
1
|
import { getEnv } from "@ledgerhq/live-env";
|
|
2
|
-
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
import { fetchAndMergeProviderData } from "../../../providers/swap";
|
|
2
|
+
import { useCallback, useEffect, useState, useMemo } from "react";
|
|
3
|
+
import { fetchAndMergeProviderData, getDefaultSwapProviderKeys } from "../../../providers/swap";
|
|
4
4
|
import { useFeature } from "../../../../featureFlags";
|
|
5
5
|
|
|
6
|
+
const filterProvidersByFeatureFlags = (
|
|
7
|
+
providers: string[],
|
|
8
|
+
ptxSwapMoonpayProviderFlag?: { enabled?: boolean },
|
|
9
|
+
ptxSwapExodusProviderFlag?: { enabled?: boolean },
|
|
10
|
+
): string[] => {
|
|
11
|
+
let filtered = providers;
|
|
12
|
+
if (!ptxSwapMoonpayProviderFlag?.enabled) {
|
|
13
|
+
filtered = filtered.filter(provider => provider !== "moonpay");
|
|
14
|
+
}
|
|
15
|
+
if (!ptxSwapExodusProviderFlag?.enabled) {
|
|
16
|
+
filtered = filtered.filter(provider => provider !== "exodus");
|
|
17
|
+
}
|
|
18
|
+
return filtered;
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
export const useFilteredProviders = () => {
|
|
7
|
-
const [providers, setProviders] = useState<string[]>([]);
|
|
8
|
-
const [loading, setLoading] = useState(true);
|
|
9
|
-
const [error, setError] = useState<unknown>(null);
|
|
10
22
|
const ptxSwapMoonpayProviderFlag = useFeature("ptxSwapMoonpayProvider");
|
|
11
23
|
const ptxSwapExodusProviderFlag = useFeature("ptxSwapExodusProvider");
|
|
24
|
+
|
|
25
|
+
const defaultProviders = useMemo(
|
|
26
|
+
() =>
|
|
27
|
+
filterProvidersByFeatureFlags(
|
|
28
|
+
getDefaultSwapProviderKeys(),
|
|
29
|
+
ptxSwapMoonpayProviderFlag ?? undefined,
|
|
30
|
+
ptxSwapExodusProviderFlag ?? undefined,
|
|
31
|
+
),
|
|
32
|
+
[ptxSwapMoonpayProviderFlag, ptxSwapExodusProviderFlag],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const [providers, setProviders] = useState<string[]>(defaultProviders);
|
|
36
|
+
const [loading, setLoading] = useState(true);
|
|
37
|
+
const [error, setError] = useState<unknown>(null);
|
|
38
|
+
|
|
12
39
|
const fetchProviders = useCallback(async () => {
|
|
13
40
|
try {
|
|
14
41
|
const ledgerSignatureEnv = getEnv("MOCK_EXCHANGE_TEST_CONFIG") ? "test" : "prod";
|
|
15
42
|
const partnerSignatureEnv = getEnv("MOCK_EXCHANGE_TEST_PARTNER") ? "test" : "prod";
|
|
16
43
|
|
|
17
44
|
const data = await fetchAndMergeProviderData({ ledgerSignatureEnv, partnerSignatureEnv });
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
filteredProviders = filteredProviders.filter(provider => provider !== "exodus");
|
|
24
|
-
}
|
|
45
|
+
const filteredProviders = filterProvidersByFeatureFlags(
|
|
46
|
+
Object.keys(data),
|
|
47
|
+
ptxSwapMoonpayProviderFlag ?? undefined,
|
|
48
|
+
ptxSwapExodusProviderFlag ?? undefined,
|
|
49
|
+
);
|
|
25
50
|
|
|
26
51
|
setProviders(filteredProviders);
|
|
27
52
|
} catch (error) {
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
4
4
|
[
|
|
5
5
|
{
|
|
6
|
-
"balance": "
|
|
6
|
+
"balance": "341065024",
|
|
7
7
|
"currencyId": "stellar",
|
|
8
8
|
"derivationMode": "sep5",
|
|
9
9
|
"freshAddress": "GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
|
|
10
10
|
"freshAddressPath": "44'/148'/0'",
|
|
11
11
|
"id": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
12
12
|
"index": 0,
|
|
13
|
-
"operationsCount":
|
|
13
|
+
"operationsCount": 145,
|
|
14
14
|
"pendingOperations": [],
|
|
15
15
|
"seedIdentifier": "27c586f8499294c64d57f8d7956eef4431de58ab20e1c88001f6cf131c97d6f3",
|
|
16
|
-
"spendableBalance": "
|
|
16
|
+
"spendableBalance": "311064924",
|
|
17
17
|
"subAccounts": [],
|
|
18
18
|
"swapHistory": [],
|
|
19
|
-
"syncHash":
|
|
19
|
+
"syncHash": "0x1431ef5f",
|
|
20
20
|
"used": true,
|
|
21
21
|
"xpub": "GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
|
|
22
22
|
},
|
|
@@ -34,7 +34,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
|
34
34
|
"spendableBalance": "79999760",
|
|
35
35
|
"subAccounts": [],
|
|
36
36
|
"swapHistory": [],
|
|
37
|
-
"syncHash":
|
|
37
|
+
"syncHash": "0x1431ef5f",
|
|
38
38
|
"used": true,
|
|
39
39
|
"xpub": "GAIXIJBMYPTSF2CDVQ35WOTULCLZIE4W2SDEK3RQGAA3A22BPWY7R53Z",
|
|
40
40
|
},
|
|
@@ -52,7 +52,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
|
52
52
|
"spendableBalance": "44999262",
|
|
53
53
|
"subAccounts": [],
|
|
54
54
|
"swapHistory": [],
|
|
55
|
-
"syncHash":
|
|
55
|
+
"syncHash": "0x1431ef5f",
|
|
56
56
|
"used": true,
|
|
57
57
|
"xpub": "GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS",
|
|
58
58
|
},
|
|
@@ -70,7 +70,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
|
70
70
|
"spendableBalance": "10145721",
|
|
71
71
|
"subAccounts": [],
|
|
72
72
|
"swapHistory": [],
|
|
73
|
-
"syncHash":
|
|
73
|
+
"syncHash": "0x1431ef5f",
|
|
74
74
|
"used": true,
|
|
75
75
|
"xpub": "GAHQKL7UW5DSNJXWNA4ASJ6D2I7JYFWVHDFWYJZK3WDR4BUTG27K2PWC",
|
|
76
76
|
},
|
|
@@ -88,7 +88,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
|
88
88
|
"spendableBalance": "0",
|
|
89
89
|
"subAccounts": [],
|
|
90
90
|
"swapHistory": [],
|
|
91
|
-
"syncHash":
|
|
91
|
+
"syncHash": "0x1431ef5f",
|
|
92
92
|
"used": true,
|
|
93
93
|
"xpub": "GBQMOU2WYJUP6AKY53FFKZJGQMDWCMTWSOUTZ5DVIAQPVW7AJUHSX2M5",
|
|
94
94
|
},
|
|
@@ -106,7 +106,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 1`] = `
|
|
|
106
106
|
"spendableBalance": "0",
|
|
107
107
|
"subAccounts": [],
|
|
108
108
|
"swapHistory": [],
|
|
109
|
-
"syncHash":
|
|
109
|
+
"syncHash": "0x1431ef5f",
|
|
110
110
|
"used": false,
|
|
111
111
|
"xpub": "GAJEKFXY76YWDSKJESDOKS2EGKRMCHSIC5AU32SU7OF54E5VVREUHXLH",
|
|
112
112
|
},
|
|
@@ -690,7 +690,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
690
690
|
],
|
|
691
691
|
"transactionSequenceNumber": "251606365385008908",
|
|
692
692
|
"type": "IN",
|
|
693
|
-
"value": "
|
|
693
|
+
"value": "10000",
|
|
694
694
|
},
|
|
695
695
|
{
|
|
696
696
|
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
@@ -764,6 +764,30 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
764
764
|
"type": "IN",
|
|
765
765
|
"value": "1",
|
|
766
766
|
},
|
|
767
|
+
{
|
|
768
|
+
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
769
|
+
"blockHash": "0d4b1748aeb13c64f001d9b486054744d5e8521081ce6d21dc9acbb2a1c0a171",
|
|
770
|
+
"blockHeight": 59792876,
|
|
771
|
+
"extra": {
|
|
772
|
+
"memo": {
|
|
773
|
+
"type": "MEMO_TEXT",
|
|
774
|
+
"value": "Own VTX & Start Earning XLM!",
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
"fee": "10000",
|
|
778
|
+
"hasFailed": false,
|
|
779
|
+
"hash": "277aa9d93c6674951b4cc198a25ee1d5726d686f459d957a9bf4b40b0b66ffb6",
|
|
780
|
+
"id": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5-277aa9d93c6674951b4cc198a25ee1d5726d686f459d957a9bf4b40b0b66ffb6-IN",
|
|
781
|
+
"recipients": [
|
|
782
|
+
"GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
|
|
783
|
+
],
|
|
784
|
+
"senders": [
|
|
785
|
+
"GDM2UBYCTDJ7LBBNLWU5XTNNIR6GIQW7KXJTPBWOTMFECHF5YJAE3JTH",
|
|
786
|
+
],
|
|
787
|
+
"transactionSequenceNumber": "256741054621943059",
|
|
788
|
+
"type": "IN",
|
|
789
|
+
"value": "1",
|
|
790
|
+
},
|
|
767
791
|
{
|
|
768
792
|
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
769
793
|
"blockHash": "d43eb458fb93eb861373fbe61743bdc51800bf41eaeff2fd2b6a2b001254044b",
|
|
@@ -1676,6 +1700,30 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
1676
1700
|
"type": "IN",
|
|
1677
1701
|
"value": "1",
|
|
1678
1702
|
},
|
|
1703
|
+
{
|
|
1704
|
+
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
1705
|
+
"blockHash": "70caf48d48b190098064b972f0142dfa3549adbc4893021d5d002df3c7a6c9b0",
|
|
1706
|
+
"blockHeight": 59745989,
|
|
1707
|
+
"extra": {
|
|
1708
|
+
"memo": {
|
|
1709
|
+
"type": "MEMO_TEXT",
|
|
1710
|
+
"value": "Buy XRVT Earn fchain.io XRP!",
|
|
1711
|
+
},
|
|
1712
|
+
},
|
|
1713
|
+
"fee": "10000",
|
|
1714
|
+
"hasFailed": false,
|
|
1715
|
+
"hash": "6db88bc812940527d1387217bd4574cdac5bf3857efe72e0c1aec661b5c4a90f",
|
|
1716
|
+
"id": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5-6db88bc812940527d1387217bd4574cdac5bf3857efe72e0c1aec661b5c4a90f-IN",
|
|
1717
|
+
"recipients": [
|
|
1718
|
+
"GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
|
|
1719
|
+
],
|
|
1720
|
+
"senders": [
|
|
1721
|
+
"GD7NZ4LUIJPEIWM3UY4IW5HMV3WV3PRVM5CPSILLBUIG5YFNNCCTZXJL",
|
|
1722
|
+
],
|
|
1723
|
+
"transactionSequenceNumber": "256247545699769514",
|
|
1724
|
+
"type": "IN",
|
|
1725
|
+
"value": "1",
|
|
1726
|
+
},
|
|
1679
1727
|
{
|
|
1680
1728
|
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
1681
1729
|
"blockHash": "d36bfe52924033397bdb89574feb1d4bdf2f063420d204c54d3cf7b829bd571f",
|
|
@@ -3068,6 +3116,30 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
3068
3116
|
"type": "IN",
|
|
3069
3117
|
"value": "1",
|
|
3070
3118
|
},
|
|
3119
|
+
{
|
|
3120
|
+
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
3121
|
+
"blockHash": "e70f311ceddcb90dd9853589896e4dedfe9d57dcdc130cf62a1c5e8564b24b7b",
|
|
3122
|
+
"blockHeight": 59761051,
|
|
3123
|
+
"extra": {
|
|
3124
|
+
"memo": {
|
|
3125
|
+
"type": "MEMO_TEXT",
|
|
3126
|
+
"value": "Buy XRVT Earn fchain.io XRP!",
|
|
3127
|
+
},
|
|
3128
|
+
},
|
|
3129
|
+
"fee": "10000",
|
|
3130
|
+
"hasFailed": false,
|
|
3131
|
+
"hash": "c911e6f578b4d869a71ea7e8cd139c5a885d996d2f15e63c63b31db10e42f415",
|
|
3132
|
+
"id": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5-c911e6f578b4d869a71ea7e8cd139c5a885d996d2f15e63c63b31db10e42f415-IN",
|
|
3133
|
+
"recipients": [
|
|
3134
|
+
"GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV",
|
|
3135
|
+
],
|
|
3136
|
+
"senders": [
|
|
3137
|
+
"GD7NZ4LUIJPEIWM3UY4IW5HMV3WV3PRVM5CPSILLBUIG5YFNNCCTZXJL",
|
|
3138
|
+
],
|
|
3139
|
+
"transactionSequenceNumber": "256247545699771532",
|
|
3140
|
+
"type": "IN",
|
|
3141
|
+
"value": "1",
|
|
3142
|
+
},
|
|
3071
3143
|
{
|
|
3072
3144
|
"accountId": "js:2:stellar:GAT4LBXYJGJJJRSNK74NPFLO55CDDXSYVMQODSEAAH3M6EY4S7LPH5GV:sep5",
|
|
3073
3145
|
"blockHash": "6eb78e902ecc290b25216c0afae3a354b9b3bf723510c8aa3162f801635b0f35",
|
|
@@ -5283,7 +5355,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
5283
5355
|
],
|
|
5284
5356
|
"transactionSequenceNumber": "119784086674866178",
|
|
5285
5357
|
"type": "OUT",
|
|
5286
|
-
"value": "
|
|
5358
|
+
"value": "100",
|
|
5287
5359
|
},
|
|
5288
5360
|
{
|
|
5289
5361
|
"accountId": "js:2:stellar:GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS:sep5",
|
|
@@ -5798,7 +5870,7 @@ exports[`stellar currency bridge scanAccounts stellar seed 1 2`] = `
|
|
|
5798
5870
|
],
|
|
5799
5871
|
"transactionSequenceNumber": "119784086674866178",
|
|
5800
5872
|
"type": "IN",
|
|
5801
|
-
"value": "
|
|
5873
|
+
"value": "100",
|
|
5802
5874
|
},
|
|
5803
5875
|
{
|
|
5804
5876
|
"accountId": "js:2:stellar:GAHQKL7UW5DSNJXWNA4ASJ6D2I7JYFWVHDFWYJZK3WDR4BUTG27K2PWC:sep5",
|
|
@@ -134,6 +134,7 @@ function combineMarketData(
|
|
|
134
134
|
return {
|
|
135
135
|
data: results.flatMap(result => result.data?.formattedData ?? []),
|
|
136
136
|
isPending: results.some(result => result.isPending),
|
|
137
|
+
isFetching: results.some(result => result.isFetching),
|
|
137
138
|
isLoading: results.some(result => result.isLoading),
|
|
138
139
|
isError: results.some(result => result.isError),
|
|
139
140
|
cachedMetadataMap: hashMap,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { renderHook } from "@testing-library/react";
|
|
7
7
|
import { mockEthCryptoCurrency } from "../../__mocks__/currencies.mock";
|
|
8
|
-
import {
|
|
8
|
+
import { groupCurrenciesByAsset } from "../../utils";
|
|
9
9
|
import createAssetConfigurationHook from "../createAssetConfiguration";
|
|
10
10
|
import { BigNumber } from "bignumber.js";
|
|
11
11
|
import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
|
|
@@ -114,7 +114,7 @@ const assetConfigurationDeps = {
|
|
|
114
114
|
ApyIndicator,
|
|
115
115
|
MarketPercentIndicator,
|
|
116
116
|
MarketPriceIndicator,
|
|
117
|
-
assetsMap:
|
|
117
|
+
assetsMap: groupCurrenciesByAsset([
|
|
118
118
|
{
|
|
119
119
|
asset: {
|
|
120
120
|
id: "ethereum",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { groupCurrenciesByAsset } from "../groupCurrenciesByAsset";
|
|
2
2
|
import { AssetData } from "../type";
|
|
3
3
|
import {
|
|
4
4
|
mockBtcCryptoCurrency,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
mockBaseCryptoCurrency,
|
|
7
7
|
} from "../../__mocks__/currencies.mock";
|
|
8
8
|
|
|
9
|
-
describe("
|
|
9
|
+
describe("groupCurrenciesByAsset", () => {
|
|
10
10
|
it("should return an empty map when given an empty array", () => {
|
|
11
|
-
const result =
|
|
11
|
+
const result = groupCurrenciesByAsset([]);
|
|
12
12
|
expect(result).toBeInstanceOf(Map);
|
|
13
13
|
expect(result.size).toBe(0);
|
|
14
14
|
});
|
|
@@ -26,7 +26,7 @@ describe("groupCurrenciesByProvider", () => {
|
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
const result =
|
|
29
|
+
const result = groupCurrenciesByAsset(assetData);
|
|
30
30
|
expect(result.size).toBe(0);
|
|
31
31
|
});
|
|
32
32
|
|
|
@@ -43,7 +43,7 @@ describe("groupCurrenciesByProvider", () => {
|
|
|
43
43
|
},
|
|
44
44
|
];
|
|
45
45
|
|
|
46
|
-
const result =
|
|
46
|
+
const result = groupCurrenciesByAsset(assetData);
|
|
47
47
|
expect(result.size).toBe(1);
|
|
48
48
|
expect(result.has("ethereum")).toBe(true);
|
|
49
49
|
|
|
@@ -74,7 +74,7 @@ describe("groupCurrenciesByProvider", () => {
|
|
|
74
74
|
},
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
-
const result =
|
|
77
|
+
const result = groupCurrenciesByAsset(assetData);
|
|
78
78
|
expect(result.size).toBe(2);
|
|
79
79
|
expect(result.has("bitcoin")).toBe(true);
|
|
80
80
|
expect(result.has("ethereum")).toBe(true);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
import { AssetData } from "./type";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const groupCurrenciesByAsset = (assetsSorted: AssetData[]) => {
|
|
5
5
|
const assetMap = new Map<
|
|
6
6
|
string,
|
|
7
7
|
{ mainCurrency: CryptoOrTokenCurrency; currencies: CryptoOrTokenCurrency[] }
|
|
@@ -10,12 +10,12 @@ export const groupCurrenciesByProvider = (assetsSorted: AssetData[]) => {
|
|
|
10
10
|
if (assetsSorted) {
|
|
11
11
|
for (const item of assetsSorted) {
|
|
12
12
|
const {
|
|
13
|
-
asset: { id:
|
|
13
|
+
asset: { id: assetId },
|
|
14
14
|
networks = [],
|
|
15
15
|
} = item;
|
|
16
16
|
if (networks?.length > 0) {
|
|
17
|
-
const mainCurrency = networks.find(c => c.id ===
|
|
18
|
-
assetMap.set(
|
|
17
|
+
const mainCurrency = networks.find(c => c.id === assetId) ?? networks[0];
|
|
18
|
+
assetMap.set(assetId, {
|
|
19
19
|
mainCurrency,
|
|
20
20
|
currencies: networks,
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
export {
|
|
2
|
+
export { groupCurrenciesByAsset } from "./groupCurrenciesByAsset";
|
|
3
3
|
export { sortAccountsByFiatValue } from "./sortAccountsByFiatValue";
|
|
4
4
|
|
|
5
5
|
const getBaseId = (currency: CryptoOrTokenCurrency) =>
|
package/src/wallet-api/types.ts
CHANGED
|
@@ -83,3 +83,8 @@ export type DAppTrackingData = {
|
|
|
83
83
|
currency: string;
|
|
84
84
|
network: CryptoCurrency["id"];
|
|
85
85
|
};
|
|
86
|
+
|
|
87
|
+
export type AccountIdFormat = "uuid" | "encoded";
|
|
88
|
+
|
|
89
|
+
/** @developer note uuid = wallet API id format, encoded = ledger wallet default format */
|
|
90
|
+
export type AccountIdFormatsResponse = Record<string, AccountIdFormat>;
|
|
@@ -4,14 +4,26 @@ import { TokenAccount, Account, AccountLike } from "@ledgerhq/types-live";
|
|
|
4
4
|
import { LiveAppManifest } from "../../platform/types";
|
|
5
5
|
import semver from "semver";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Determines if a manifest uses (Ledger Live) account ID format or UUID (Wallet API) format.
|
|
9
|
+
* @param manifest - The live app manifest to check
|
|
10
|
+
* @returns true if the manifest uses encoded format (v3+ dapp), false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export function usesEncodedAccountIdFormat(manifest: LiveAppManifest): boolean {
|
|
13
|
+
return (
|
|
14
|
+
"dapp" in manifest &&
|
|
15
|
+
!!manifest.apiVersion &&
|
|
16
|
+
semver.satisfies(WALLET_API_VERSION, manifest.apiVersion)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
/** The dapp connector "v3" uses the ledger live account ID to find the correct account. Live app and dapp browser manifests require wallet API ID. */
|
|
8
21
|
export function deriveAccountIdForManifest(
|
|
9
22
|
accountId: Account["id"] | TokenAccount["id"] | AccountLike["id"],
|
|
10
23
|
walletApiAccountId: WalletAPIAccount["id"] | string,
|
|
11
24
|
manifest: LiveAppManifest,
|
|
12
25
|
) {
|
|
13
|
-
|
|
14
|
-
if (isDapp && manifest.apiVersion && semver.satisfies(WALLET_API_VERSION, manifest.apiVersion)) {
|
|
26
|
+
if (usesEncodedAccountIdFormat(manifest)) {
|
|
15
27
|
return accountId;
|
|
16
28
|
}
|
|
17
29
|
/** Assume dapp browser <=v2 or live app, fallback to wallet ID. */
|
package/lib/deposit/helper.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
import { MappedAsset, GroupedCurrencies } from "./type";
|
|
3
|
-
export declare const loadCurrenciesByProvider: (coinsAndTokensSupported: CryptoOrTokenCurrency[]) => Promise<GroupedCurrencies>;
|
|
4
|
-
export declare const groupCurrenciesByProvider: (assets: MappedAsset[], sortedCurrencies: CryptoOrTokenCurrency[]) => GroupedCurrencies;
|
|
5
|
-
export declare const searchByProviderId: (list: MappedAsset[], providerId: string) => MappedAsset[];
|
|
6
|
-
export declare const searchByNameOrTicker: (list: MappedAsset[], nameOrTicker: string) => MappedAsset[];
|
|
7
|
-
export declare const getTokenOrCryptoCurrencyById: (id: string) => Promise<CryptoOrTokenCurrency>;
|
|
8
|
-
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/deposit/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,WAAW,EAA0B,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAgEhF,eAAO,MAAM,wBAAwB,4BACV,qBAAqB,EAAE,KAC/C,QAAQ,iBAAiB,CAW3B,CAAC;AACF,eAAO,MAAM,yBAAyB,WAC5B,WAAW,EAAE,oBACH,qBAAqB,EAAE,KACxC,iBAwCF,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,WAAW,EAAE,cAAc,MAAM,kBACO,CAAC;AAClF,eAAO,MAAM,oBAAoB,SAAU,WAAW,EAAE,gBAAgB,MAAM,kBAK3E,CAAC;AAEJ,eAAO,MAAM,4BAA4B,OAAc,MAAM,KAAG,QAAQ,qBAAqB,CAS5F,CAAC"}
|
package/lib/deposit/helper.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTokenOrCryptoCurrencyById = exports.searchByNameOrTicker = exports.searchByProviderId = exports.groupCurrenciesByProvider = exports.loadCurrenciesByProvider = void 0;
|
|
4
|
-
const currencies_1 = require("../currencies");
|
|
5
|
-
const index_1 = require("../bridge/crypto-assets/index");
|
|
6
|
-
const api_1 = require("./api");
|
|
7
|
-
/**
|
|
8
|
-
* WORKAROUND: Fallback mappings for currencies not yet available in getMappedAssets()
|
|
9
|
-
* TODO: Remove these entries once they are properly supported by the mapping service
|
|
10
|
-
*
|
|
11
|
-
* Each entry maps a Ledger currency ID to its provider ID.
|
|
12
|
-
* The provider ID is used to group currencies by their external provider (e.g., CoinGecko).
|
|
13
|
-
*/
|
|
14
|
-
const FALLBACK_CURRENCY_MAPPINGS = {
|
|
15
|
-
// Canton Network - using canton_network as both ledgerId and providerId
|
|
16
|
-
canton_network: "canton_network",
|
|
17
|
-
canton_network_devnet: "canton_network_devnet",
|
|
18
|
-
canton_network_testnet: "canton_network_testnet",
|
|
19
|
-
// Add more fallback mappings here as needed:
|
|
20
|
-
// "ledger_currency_id": "provider_id",
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Creates synthetic MappedAsset entries for currencies that are not yet available
|
|
24
|
-
* in the mapping service API but need to be supported.
|
|
25
|
-
*/
|
|
26
|
-
const createFallbackMappedAssets = (currencies, existingAssets) => {
|
|
27
|
-
const existingLedgerIds = new Set(existingAssets.map(asset => asset.ledgerId.toLowerCase()));
|
|
28
|
-
const fallbackAssets = [];
|
|
29
|
-
for (const [currencyId, providerId] of Object.entries(FALLBACK_CURRENCY_MAPPINGS)) {
|
|
30
|
-
// Skip if currency already exists in mapped assets
|
|
31
|
-
if (existingLedgerIds.has(currencyId.toLowerCase())) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
// Find the currency in the list
|
|
35
|
-
const currency = currencies.find(c => c.id === currencyId);
|
|
36
|
-
if (currency) {
|
|
37
|
-
fallbackAssets.push({
|
|
38
|
-
$type: currency.type === "TokenCurrency" ? "Token" : "Coin",
|
|
39
|
-
ledgerId: currency.id,
|
|
40
|
-
providerId: providerId,
|
|
41
|
-
name: currency.name,
|
|
42
|
-
ticker: currency.ticker,
|
|
43
|
-
network: currency.type === "TokenCurrency" ? currency.parentCurrency?.id : undefined,
|
|
44
|
-
contract: currency.type === "TokenCurrency" ? currency.contractAddress : undefined,
|
|
45
|
-
status: "active",
|
|
46
|
-
reason: null,
|
|
47
|
-
data: {
|
|
48
|
-
img: "",
|
|
49
|
-
marketCapRank: null,
|
|
50
|
-
},
|
|
51
|
-
ledgerCurrency: currency,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return fallbackAssets;
|
|
56
|
-
};
|
|
57
|
-
const loadCurrenciesByProvider = async (coinsAndTokensSupported) => {
|
|
58
|
-
const [sortedCurrenciesSupported, assets] = await Promise.all([
|
|
59
|
-
(0, currencies_1.currenciesByMarketcap)(coinsAndTokensSupported),
|
|
60
|
-
(0, api_1.getMappedAssets)(),
|
|
61
|
-
]);
|
|
62
|
-
// Merge API assets with fallback assets for currencies not yet in the API
|
|
63
|
-
const fallbackAssets = createFallbackMappedAssets(sortedCurrenciesSupported, assets);
|
|
64
|
-
const allAssets = [...assets, ...fallbackAssets];
|
|
65
|
-
return (0, exports.groupCurrenciesByProvider)(allAssets, sortedCurrenciesSupported);
|
|
66
|
-
};
|
|
67
|
-
exports.loadCurrenciesByProvider = loadCurrenciesByProvider;
|
|
68
|
-
const groupCurrenciesByProvider = (assets, sortedCurrencies) => {
|
|
69
|
-
const assetsByLedgerId = new Map();
|
|
70
|
-
for (const asset of assets) {
|
|
71
|
-
/// FIXME(LIVE-10508) drop usage of toLowerCase
|
|
72
|
-
assetsByLedgerId.set(asset.ledgerId.toLowerCase(), asset);
|
|
73
|
-
}
|
|
74
|
-
const assetsByProviderId = new Map();
|
|
75
|
-
const sortedCryptoCurrencies = [];
|
|
76
|
-
// iterate over currencies by preserving their order
|
|
77
|
-
for (const ledgerCurrency of sortedCurrencies) {
|
|
78
|
-
/// FIXME(LIVE-10508) drop usage of toLowerCase
|
|
79
|
-
const asset = assetsByLedgerId.get(ledgerCurrency.id.toLowerCase());
|
|
80
|
-
if (asset) {
|
|
81
|
-
// we only yield the intersection of currencies and mapped assets
|
|
82
|
-
const existingEntry = assetsByProviderId.get(asset.providerId);
|
|
83
|
-
if (!existingEntry) {
|
|
84
|
-
assetsByProviderId.set(asset.providerId, {
|
|
85
|
-
providerId: asset.providerId,
|
|
86
|
-
currenciesByNetwork: [ledgerCurrency],
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
existingEntry.currenciesByNetwork.push(ledgerCurrency);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// in this case, the first currency of the provider is the one we want to display (Wasn't true)
|
|
95
|
-
// So we need to take the first crypto or token currency of each provider to fix that
|
|
96
|
-
for (const [, { currenciesByNetwork }] of assetsByProviderId.entries()) {
|
|
97
|
-
const firstCrypto = currenciesByNetwork.find(c => c.type === "CryptoCurrency");
|
|
98
|
-
const elem = firstCrypto ?? currenciesByNetwork.find(c => c.type === "TokenCurrency");
|
|
99
|
-
if (elem) {
|
|
100
|
-
sortedCryptoCurrencies.push(elem);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
currenciesByProvider: Array.from(assetsByProviderId.values()),
|
|
105
|
-
sortedCryptoCurrencies,
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
exports.groupCurrenciesByProvider = groupCurrenciesByProvider;
|
|
109
|
-
const searchByProviderId = (list, providerId) => list.filter(elem => elem.providerId.toLowerCase() === providerId.toLowerCase());
|
|
110
|
-
exports.searchByProviderId = searchByProviderId;
|
|
111
|
-
const searchByNameOrTicker = (list, nameOrTicker) => list.filter(elem => elem.name.toLowerCase().includes(nameOrTicker.toLowerCase()) ||
|
|
112
|
-
elem.ticker.toLowerCase().includes(nameOrTicker.toLowerCase()));
|
|
113
|
-
exports.searchByNameOrTicker = searchByNameOrTicker;
|
|
114
|
-
const getTokenOrCryptoCurrencyById = async (id) => {
|
|
115
|
-
if ((0, currencies_1.hasCryptoCurrencyId)(id)) {
|
|
116
|
-
return (0, currencies_1.getCryptoCurrencyById)(id);
|
|
117
|
-
}
|
|
118
|
-
const token = await (0, index_1.getCryptoAssetsStore)().findTokenById(id);
|
|
119
|
-
if (!token) {
|
|
120
|
-
throw new Error(`token with id "${id}" not found`);
|
|
121
|
-
}
|
|
122
|
-
return token;
|
|
123
|
-
};
|
|
124
|
-
exports.getTokenOrCryptoCurrencyById = getTokenOrCryptoCurrencyById;
|
|
125
|
-
//# sourceMappingURL=helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/deposit/helper.ts"],"names":[],"mappings":";;;AAEA,8CAAkG;AAClG,yDAAqE;AACrE,+BAAwC;AAExC;;;;;;GAMG;AACH,MAAM,0BAA0B,GAA2B;IACzD,wEAAwE;IACxE,cAAc,EAAE,gBAAgB;IAChC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AAE,CAAC,CAAC;AADrE,QAAA,kBAAkB,sBACmD;AAC3E,MAAM,oBAAoB,GAAG,CAAC,IAAmB,EAAE,YAAoB,EAAE,EAAE,CAChF,IAAI,CAAC,MAAM,CACT,IAAI,CAAC,EAAE,CACL,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC5D,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CACjE,CAAC;AALS,QAAA,oBAAoB,wBAK7B;AAEG,MAAM,4BAA4B,GAAG,KAAK,EAAE,EAAU,EAAkC,EAAE;IAC/F,IAAI,IAAA,gCAAmB,EAAC,EAAE,CAAC,EAAE;QAC3B,OAAO,IAAA,kCAAqB,EAAC,EAAE,CAAC,CAAC;KAClC;IACD,MAAM,KAAK,GAAG,MAAM,IAAA,4BAAoB,GAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;KACpD;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AATW,QAAA,4BAA4B,gCASvC"}
|
package/lib/deposit/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deposit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAEvF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
|
package/lib/deposit/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGroupedCurrenciesByProvider = void 0;
|
|
4
|
-
const useGroupedCurrenciesByProvider_hook_1 = require("./useGroupedCurrenciesByProvider.hook");
|
|
5
|
-
Object.defineProperty(exports, "useGroupedCurrenciesByProvider", { enumerable: true, get: function () { return useGroupedCurrenciesByProvider_hook_1.useGroupedCurrenciesByProvider; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/lib/deposit/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/deposit/index.ts"],"names":[],"mappings":";;;AAAA,+FAAuF;AAE9E,+GAFA,oEAA8B,OAEA"}
|