@ledgerhq/live-common 34.42.0-nightly.2 → 34.42.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/generic-alpaca/alpaca/network/network-alpaca.d.ts +3 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +6 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/modularDrawer/__mocks__/currencies.mock.d.ts +17 -0
- package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/currencies.mock.js +60 -0
- package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +41 -0
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +28 -0
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.js +29 -0
- package/lib/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
- package/lib/modularDrawer/utils/index.d.ts +2 -1
- 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-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +3 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +6 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts +17 -0
- package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js +55 -0
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +38 -0
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +26 -0
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.js +25 -0
- package/lib-es/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts +2 -1
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +2 -1
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/package.json +34 -34
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +8 -1
- package/src/modularDrawer/__mocks__/currencies.mock.ts +62 -0
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +49 -0
- package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +34 -0
- package/src/modularDrawer/utils/haveOneCommonProvider.ts +31 -0
- package/src/modularDrawer/utils/index.ts +2 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { Account, Balance, Block, BlockInfo, Operation, FeeEstimation, Pagination, TransactionIntent, Transaction, TransactionValidation, AccountInfo } from "@ledgerhq/coin-framework/api/index";
|
2
2
|
type AssetInfo = {
|
3
3
|
type: "native";
|
4
4
|
};
|
@@ -12,6 +12,8 @@ export declare const getNetworkAlpacaApi: (networkFamily: string) => {
|
|
12
12
|
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<any>[], string]>;
|
13
13
|
lastBlock: () => Promise<BlockInfo>;
|
14
14
|
craftTransaction: (intent: TransactionIntent<any>) => Promise<string>;
|
15
|
+
getBlock(_height: number): Promise<Block<any>>;
|
16
|
+
getBlockInfo(_height: number): Promise<BlockInfo>;
|
15
17
|
};
|
16
18
|
export {};
|
17
19
|
//# sourceMappingURL=network-alpaca.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"network-alpaca.d.ts","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"network-alpaca.d.ts","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,WAAW,EAEZ,MAAM,oCAAoC,CAAC;AAiG5C,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAsEF,eAAO,MAAM,mBAAmB,kBAAmB,MAAM;iCAxJb,MAAM,KAAG,QAAQ,MAAM,CAAC;kBAmBvC,MAAM,aAAa,MAAM,WAAW,MAAM,KAAG,QAAQ,MAAM,CAAC;8BAqC5E,OAAO,eACH,WAAW,KACvB,QAAQ,qBAAqB,CAAC;2BApBG,kBAAkB,GAAG,CAAC,KAAG,QAAQ,aAAa,CAAC;0BA+ChD,MAAM,KAAG,QAAQ,QAAQ,SAAS,CAAC,EAAE,CAAC;8BAetC,MAAM,KAAG,QAAQ,WAAW,CAAC;8BAWrD,MAAM,cACH,UAAU,KACrB,QAAQ,CAAC,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;qBAYV,QAAQ,SAAS,CAAC;+BAaN,kBAAkB,GAAG,CAAC,KAAG,QAAQ,MAAM,CAAC;+BAyB3D,QAAQ,MAAM,GAAG,CAAC,CAAC;0BAGhB,MAAM,GAAG,QAAQ,SAAS,CAAC;CAG9B,CAAC"}
|
@@ -126,6 +126,12 @@ const getNetworkAlpacaApi = (networkFamily) => ({
|
|
126
126
|
listOperations: buildListOperations(networkFamily),
|
127
127
|
lastBlock: buildLastBlock(networkFamily),
|
128
128
|
craftTransaction: buildCraftTransaction(networkFamily),
|
129
|
+
getBlock(_height) {
|
130
|
+
throw new Error("getBlock is not supported");
|
131
|
+
},
|
132
|
+
getBlockInfo(_height) {
|
133
|
+
throw new Error("getBlockInfo is not supported");
|
134
|
+
},
|
129
135
|
});
|
130
136
|
exports.getNetworkAlpacaApi = getNetworkAlpacaApi;
|
131
137
|
//# sourceMappingURL=network-alpaca.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"network-alpaca.js","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"network-alpaca.js","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/al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KAAK,UAAU,gBAAgB,CAAC,MAA8B;IAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,sBAAO,EAAe;QAC3C,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,UAAU,IAAI,aAAa,qBAAqB;QACxD,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,GAAG,MAAM;gBACT,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;aACnC;SACF;KACF,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,cAAc,CAAC;AAC7B,CAAC,CAAC;AAEG,MAAM,mBAAmB,GAAG,CAAC,aAAqB,EAAE,EAAE,CAC3D,CAAC;IACC,SAAS,EAAE,cAAc,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,YAAY,CAAC,aAAa,CAAC;IACpC,cAAc,EAAE,mBAAmB,CAAC,aAAa,CAAC;IAClD,YAAY,EAAE,iBAAiB,CAAC,aAAa,CAAC;IAC9C,UAAU,EAAE,eAAe,CAAC,aAAa,CAAC;IAC1C,cAAc,EAAE,mBAAmB,CAAC,aAAa,CAAC;IAClD,cAAc,EAAE,mBAAmB,CAAC,aAAa,CAAC;IAClD,SAAS,EAAE,cAAc,CAAC,aAAa,CAAC;IACxC,gBAAgB,EAAE,qBAAqB,CAAC,aAAa,CAAC;IACtD,QAAQ,CAAC,OAAO;QACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,YAAY,CAAC,OAAe;QAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;CACF,CAAoB,CAAC;AAjBX,QAAA,mBAAmB,uBAiBR"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
export declare const mockBtcCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
3
|
+
export declare const mockEthCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
4
|
+
export declare const mockArbitrumCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
5
|
+
export declare const mockBaseCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
6
|
+
export declare const mockScrollCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
7
|
+
export declare const mockInjectiveCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
8
|
+
export declare const arbitrumToken: TokenCurrency;
|
9
|
+
export declare const usdcToken: TokenCurrency;
|
10
|
+
export declare const findCryptoCurrencyById: (id: string) => import("@ledgerhq/types-cryptoassets").CryptoCurrency | undefined;
|
11
|
+
export declare const getTokenOrCryptoCurrencyById: (id: string) => import("@ledgerhq/types-cryptoassets").CryptoCurrency | TokenCurrency | undefined;
|
12
|
+
export declare const mockCurrenciesByProvider: {
|
13
|
+
providerId: string;
|
14
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
15
|
+
}[];
|
16
|
+
export declare const mockCurrencyIds: string[];
|
17
|
+
//# sourceMappingURL=currencies.mock.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currencies.mock.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/currencies.mock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,uDAAmC,CAAC;AACtE,eAAO,MAAM,qBAAqB,uDAAoC,CAAC;AACvE,eAAO,MAAM,0BAA0B,uDAAoC,CAAC;AAC5E,eAAO,MAAM,sBAAsB,uDAAgC,CAAC;AACpE,eAAO,MAAM,wBAAwB,uDAAkC,CAAC;AACxE,eAAO,MAAM,2BAA2B,uDAAqC,CAAC;AAE9E,eAAO,MAAM,aAAa,EAAE,aAe3B,CAAC;AACF,eAAO,MAAM,SAAS,EAAE,aAevB,CAAC;AAEF,eAAO,MAAM,sBAAsB,OAAQ,MAAM,sEACkD,CAAC;AACpG,eAAO,MAAM,4BAA4B,OAAQ,MAAM,sFAO7B,CAAC;AAE3B,eAAO,MAAM,wBAAwB;;;GAKpC,CAAC;AAEF,eAAO,MAAM,eAAe,UAA8C,CAAC"}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mockCurrencyIds = exports.mockCurrenciesByProvider = exports.getTokenOrCryptoCurrencyById = exports.findCryptoCurrencyById = exports.usdcToken = exports.arbitrumToken = exports.mockInjectiveCryptoCurrency = exports.mockScrollCryptoCurrency = exports.mockBaseCryptoCurrency = exports.mockArbitrumCryptoCurrency = exports.mockEthCryptoCurrency = exports.mockBtcCryptoCurrency = void 0;
|
4
|
+
const index_1 = require("@ledgerhq/live-common/currencies/index");
|
5
|
+
exports.mockBtcCryptoCurrency = (0, index_1.getCryptoCurrencyById)("bitcoin");
|
6
|
+
exports.mockEthCryptoCurrency = (0, index_1.getCryptoCurrencyById)("ethereum");
|
7
|
+
exports.mockArbitrumCryptoCurrency = (0, index_1.getCryptoCurrencyById)("arbitrum");
|
8
|
+
exports.mockBaseCryptoCurrency = (0, index_1.getCryptoCurrencyById)("base");
|
9
|
+
exports.mockScrollCryptoCurrency = (0, index_1.getCryptoCurrencyById)("scroll");
|
10
|
+
exports.mockInjectiveCryptoCurrency = (0, index_1.getCryptoCurrencyById)("injective");
|
11
|
+
exports.arbitrumToken = {
|
12
|
+
type: "TokenCurrency",
|
13
|
+
id: "arbitrum/erc20/arbitrum",
|
14
|
+
contractAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
|
15
|
+
parentCurrency: exports.mockArbitrumCryptoCurrency,
|
16
|
+
tokenType: "erc20",
|
17
|
+
name: "Arbitrum",
|
18
|
+
ticker: "ARB",
|
19
|
+
units: [
|
20
|
+
{
|
21
|
+
name: "Arbitrum",
|
22
|
+
code: "ARB",
|
23
|
+
magnitude: 18,
|
24
|
+
},
|
25
|
+
],
|
26
|
+
};
|
27
|
+
exports.usdcToken = {
|
28
|
+
type: "TokenCurrency",
|
29
|
+
id: "ethereum/erc20/usd__coin",
|
30
|
+
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
31
|
+
parentCurrency: exports.mockEthCryptoCurrency,
|
32
|
+
tokenType: "erc20",
|
33
|
+
name: "USD Coin",
|
34
|
+
ticker: "USDC",
|
35
|
+
units: [
|
36
|
+
{
|
37
|
+
name: "USD Coin",
|
38
|
+
code: "USDC",
|
39
|
+
magnitude: 6,
|
40
|
+
},
|
41
|
+
],
|
42
|
+
};
|
43
|
+
const findCryptoCurrencyById = (id) => [exports.mockBtcCryptoCurrency, exports.mockEthCryptoCurrency, exports.mockArbitrumCryptoCurrency].find(a => a.id === id);
|
44
|
+
exports.findCryptoCurrencyById = findCryptoCurrencyById;
|
45
|
+
const getTokenOrCryptoCurrencyById = (id) => [
|
46
|
+
exports.mockBtcCryptoCurrency,
|
47
|
+
exports.mockEthCryptoCurrency,
|
48
|
+
exports.mockArbitrumCryptoCurrency,
|
49
|
+
exports.arbitrumToken,
|
50
|
+
exports.usdcToken,
|
51
|
+
].find(a => a.id === id);
|
52
|
+
exports.getTokenOrCryptoCurrencyById = getTokenOrCryptoCurrencyById;
|
53
|
+
exports.mockCurrenciesByProvider = [
|
54
|
+
{
|
55
|
+
providerId: "ethereum",
|
56
|
+
currenciesByNetwork: [exports.mockEthCryptoCurrency],
|
57
|
+
},
|
58
|
+
];
|
59
|
+
exports.mockCurrencyIds = ["bitcoin", "ethereum", "arbitrum", "base"];
|
60
|
+
//# sourceMappingURL=currencies.mock.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currencies.mock.js","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/currencies.mock.ts"],"names":[],"mappings":";;;AAAA,kEAA+E;AAGlE,QAAA,qBAAqB,GAAG,IAAA,6BAA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AAG,CAAC,EAAU,EAAE,EAAE,CACzD;IACE,6BAAqB;IACrB,6BAAqB;IACrB,kCAA0B;IAC1B,qBAAa;IACb,iBAAS;CACV,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAPd,QAAA,4BAA4B,gCAOd;AAEd,QAAA,wBAAwB,GAAG;IACtC;QACE,UAAU,EAAE,UAAU;QACtB,mBAAmB,EAAE,CAAC,6BAAqB,CAAC;KAC7C;CACF,CAAC;AAEW,QAAA,eAAe,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/// <reference types="jest" />
|
2
|
+
export declare const providers: ({
|
3
|
+
providerId: string;
|
4
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
5
|
+
} | {
|
6
|
+
providerId: string;
|
7
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").TokenCurrency[];
|
8
|
+
})[];
|
9
|
+
export declare const res: {
|
10
|
+
result: {
|
11
|
+
currenciesByProvider: ({
|
12
|
+
providerId: string;
|
13
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
14
|
+
} | {
|
15
|
+
providerId: string;
|
16
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").TokenCurrency[];
|
17
|
+
})[];
|
18
|
+
sortedCryptoCurrencies: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export declare const useGroupedCurrenciesByProvider: jest.Mock;
|
22
|
+
//# sourceMappingURL=useGroupedCurrenciesByProvider.mock.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useGroupedCurrenciesByProvider.mock.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts"],"names":[],"mappings":";AAYA,eAAO,MAAM,SAAS;;;;;;IAiBrB,CAAC;AAEF,eAAO,MAAM,GAAG;;;;;;;;;;;CAYf,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,IAAI,CAAC,IAG/C,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useGroupedCurrenciesByProvider = exports.res = exports.providers = void 0;
|
4
|
+
const type_1 = require("@ledgerhq/live-common/deposit/type");
|
5
|
+
const currencies_mock_1 = require("./currencies.mock");
|
6
|
+
exports.providers = [
|
7
|
+
{
|
8
|
+
providerId: "bitcoin",
|
9
|
+
currenciesByNetwork: [currencies_mock_1.mockBtcCryptoCurrency],
|
10
|
+
},
|
11
|
+
{
|
12
|
+
providerId: "ethereum",
|
13
|
+
currenciesByNetwork: [
|
14
|
+
currencies_mock_1.mockEthCryptoCurrency,
|
15
|
+
currencies_mock_1.mockArbitrumCryptoCurrency,
|
16
|
+
currencies_mock_1.mockBaseCryptoCurrency,
|
17
|
+
currencies_mock_1.mockScrollCryptoCurrency,
|
18
|
+
],
|
19
|
+
},
|
20
|
+
{ providerId: "arbitrum", currenciesByNetwork: [currencies_mock_1.arbitrumToken] },
|
21
|
+
{ providerId: "usd-coin", currenciesByNetwork: [currencies_mock_1.usdcToken] },
|
22
|
+
{ providerId: "injective-protocol", currenciesByNetwork: [currencies_mock_1.mockInjectiveCryptoCurrency] },
|
23
|
+
];
|
24
|
+
exports.res = {
|
25
|
+
result: {
|
26
|
+
currenciesByProvider: exports.providers,
|
27
|
+
sortedCryptoCurrencies: [
|
28
|
+
currencies_mock_1.mockBtcCryptoCurrency,
|
29
|
+
currencies_mock_1.mockEthCryptoCurrency,
|
30
|
+
currencies_mock_1.mockArbitrumCryptoCurrency,
|
31
|
+
currencies_mock_1.mockBaseCryptoCurrency,
|
32
|
+
currencies_mock_1.mockScrollCryptoCurrency,
|
33
|
+
currencies_mock_1.mockInjectiveCryptoCurrency,
|
34
|
+
],
|
35
|
+
},
|
36
|
+
};
|
37
|
+
exports.useGroupedCurrenciesByProvider = jest.fn(() => ({
|
38
|
+
...exports.res,
|
39
|
+
loadingStatus: type_1.LoadingStatus.Success,
|
40
|
+
}));
|
41
|
+
//# sourceMappingURL=useGroupedCurrenciesByProvider.mock.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useGroupedCurrenciesByProvider.mock.js","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts"],"names":[],"mappings":";;;AAAA,6DAAmE;AACnE,uDAS2B;AAEd,QAAA,SAAS,GAAG;IACvB;QACE,UAAU,EAAE,SAAS;QACrB,mBAAmB,EAAE,CAAC,uCAAqB,CAAC;KAC7C;IACD;QACE,UAAU,EAAE,UAAU;QACtB,mBAAmB,EAAE;YACnB,uCAAqB;YACrB,4CAA0B;YAC1B,wCAAsB;YACtB,0CAAwB;SACzB;KACF;IACD,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,+BAAa,CAAC,EAAE;IAChE,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,2BAAS,CAAC,EAAE;IAC5D,EAAE,UAAU,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC,6CAA2B,CAAC,EAAE;CACzF,CAAC;AAEW,QAAA,GAAG,GAAG;IACjB,MAAM,EAAE;QACN,oBAAoB,EAAE,iBAAS;QAC/B,sBAAsB,EAAE;YACtB,uCAAqB;YACrB,uCAAqB;YACrB,4CAA0B;YAC1B,wCAAsB;YACtB,0CAAwB;YACxB,6CAA2B;SAC5B;KACF;CACF,CAAC;AAEW,QAAA,8BAA8B,GAAc,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,GAAG,WAAG;IACN,aAAa,EAAE,oBAAa,CAAC,OAAO;CACrC,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.test.d.ts","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const haveOneCommonProvider_1 = require("../haveOneCommonProvider");
|
4
|
+
const useGroupedCurrenciesByProvider_mock_1 = require("../../__mocks__/useGroupedCurrenciesByProvider.mock");
|
5
|
+
jest.mock("@ledgerhq/live-common/deposit/useGroupedCurrenciesByProvider.hook", () => ({
|
6
|
+
useGroupedCurrenciesByProvider: () => (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(),
|
7
|
+
}));
|
8
|
+
describe("haveOneCommonProvider", () => {
|
9
|
+
it("should return false for an empty array", () => {
|
10
|
+
expect((0, haveOneCommonProvider_1.haveOneCommonProvider)([], [])).toBe(false);
|
11
|
+
});
|
12
|
+
it("should return true for a single currency with one provider", () => {
|
13
|
+
const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
|
14
|
+
const { currenciesByProvider } = result;
|
15
|
+
expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["bitcoin"], currenciesByProvider)).toBe(true);
|
16
|
+
});
|
17
|
+
it("should return false for multiple currencies with different providers", () => {
|
18
|
+
const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
|
19
|
+
const { currenciesByProvider } = result;
|
20
|
+
expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["bitcoin", "ethereum"], currenciesByProvider)).toBe(false);
|
21
|
+
});
|
22
|
+
it("should return true for multiple currencies with the same provider", () => {
|
23
|
+
const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
|
24
|
+
const { currenciesByProvider } = result;
|
25
|
+
expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["ethereum", "arbitrum"], currenciesByProvider)).toBe(true);
|
26
|
+
});
|
27
|
+
});
|
28
|
+
//# sourceMappingURL=haveOneCommonProvider.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.test.js","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":";;AAAA,oEAAiE;AACjE,6GAAqG;AAGrG,IAAI,CAAC,IAAI,CAAC,mEAAmE,EAAE,GAAG,EAAE,CAAC,CAAC;IACpF,8BAA8B,EAAE,GAAG,EAAE,CAAC,IAAA,oEAA8B,GAAE;CACvE,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,IAAA,6CAAqB,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CurrenciesByProviderId } from "@ledgerhq/live-common/deposit/type";
|
2
|
+
/**
|
3
|
+
* This function checks if all currencies in the provided array
|
4
|
+
* it stopped at the first currency that does not match to prevent unnecessary iterations.
|
5
|
+
*
|
6
|
+
* @param currenciesIdsArray array of currency IDs to check
|
7
|
+
* @param currenciesByProvider array of currencies grouped by provider
|
8
|
+
* @returns boolean indicating whether all currencies in the array have one common provider
|
9
|
+
*/
|
10
|
+
export declare const haveOneCommonProvider: (currenciesIdsArray: string[], currenciesByProvider: CurrenciesByProviderId[]) => boolean;
|
11
|
+
//# sourceMappingURL=haveOneCommonProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,uBACZ,MAAM,EAAE,wBACN,sBAAsB,EAAE,KAC7C,OAiBF,CAAC"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.haveOneCommonProvider = void 0;
|
4
|
+
/**
|
5
|
+
* This function checks if all currencies in the provided array
|
6
|
+
* it stopped at the first currency that does not match to prevent unnecessary iterations.
|
7
|
+
*
|
8
|
+
* @param currenciesIdsArray array of currency IDs to check
|
9
|
+
* @param currenciesByProvider array of currencies grouped by provider
|
10
|
+
* @returns boolean indicating whether all currencies in the array have one common provider
|
11
|
+
*/
|
12
|
+
const haveOneCommonProvider = (currenciesIdsArray, currenciesByProvider) => {
|
13
|
+
if (currenciesIdsArray.length === 0)
|
14
|
+
return false;
|
15
|
+
const providerIds = new Set();
|
16
|
+
for (const currencyId of currenciesIdsArray) {
|
17
|
+
for (const provider of currenciesByProvider) {
|
18
|
+
if (provider.currenciesByNetwork.some(currency => currency.id === currencyId)) {
|
19
|
+
providerIds.add(provider.providerId);
|
20
|
+
if (providerIds.size > 1) {
|
21
|
+
return false;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return true;
|
27
|
+
};
|
28
|
+
exports.haveOneCommonProvider = haveOneCommonProvider;
|
29
|
+
//# sourceMappingURL=haveOneCommonProvider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CACnC,kBAA4B,EAC5B,oBAA8C,EACrC,EAAE;IACX,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAElD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,KAAK,MAAM,UAAU,IAAI,kBAAkB,EAAE;QAC3C,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE;YAC3C,IAAI,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE;gBAC7E,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACrC,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE;oBACxB,OAAO,KAAK,CAAC;iBACd;aACF;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AApBW,QAAA,qBAAqB,yBAoBhC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
2
|
import { CurrenciesByProviderId } from "../../deposit/type";
|
3
|
+
import { haveOneCommonProvider } from "./haveOneCommonProvider";
|
3
4
|
declare function isCorrespondingCurrency(elem: CryptoOrTokenCurrency, network: CryptoOrTokenCurrency): boolean;
|
4
5
|
declare const getEffectiveCurrency: (currency: CryptoOrTokenCurrency, provider: CurrenciesByProviderId, currencyIds: string[]) => CryptoOrTokenCurrency;
|
5
|
-
export { isCorrespondingCurrency, getEffectiveCurrency };
|
6
|
+
export { isCorrespondingCurrency, getEffectiveCurrency, haveOneCommonProvider };
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,iBAAS,uBAAuB,CAC9B,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAQT;AAED,QAAA,MAAM,oBAAoB,aACd,qBAAqB,YACrB,sBAAsB,eACnB,MAAM,EAAE,0BAOtB,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getEffectiveCurrency = exports.isCorrespondingCurrency = void 0;
|
3
|
+
exports.haveOneCommonProvider = exports.getEffectiveCurrency = exports.isCorrespondingCurrency = void 0;
|
4
|
+
const haveOneCommonProvider_1 = require("./haveOneCommonProvider");
|
5
|
+
Object.defineProperty(exports, "haveOneCommonProvider", { enumerable: true, get: function () { return haveOneCommonProvider_1.haveOneCommonProvider; } });
|
4
6
|
function isCorrespondingCurrency(elem, network) {
|
5
7
|
if (elem.type === "TokenCurrency") {
|
6
8
|
return elem.parentCurrency?.id === network.id || elem.id === network.id;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AA2BR,sGA3B/C,6CAAqB,OA2B+C;AAzB7E,SAAS,uBAAuB,CAC9B,IAA2B,EAC3B,OAA8B;IAE9B,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE;QACjC,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;KACzE;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;QAClC,OAAO,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;KAC/B;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAcQ,0DAAuB;AAZhC,MAAM,oBAAoB,GAAG,CAC3B,QAA+B,EAC/B,QAAgC,EAChC,WAAqB,EACrB,EAAE;IACF,MAAM,kBAAkB,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE7D,IAAI,kBAAkB;QAAE,OAAO,QAAQ,CAAC;IAExC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ,CAAC;AAC9F,CAAC,CAAC;AAEgC,oDAAoB"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { Account, Balance, Block, BlockInfo, Operation, FeeEstimation, Pagination, TransactionIntent, Transaction, TransactionValidation, AccountInfo } from "@ledgerhq/coin-framework/api/index";
|
2
2
|
type AssetInfo = {
|
3
3
|
type: "native";
|
4
4
|
};
|
@@ -12,6 +12,8 @@ export declare const getNetworkAlpacaApi: (networkFamily: string) => {
|
|
12
12
|
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<any>[], string]>;
|
13
13
|
lastBlock: () => Promise<BlockInfo>;
|
14
14
|
craftTransaction: (intent: TransactionIntent<any>) => Promise<string>;
|
15
|
+
getBlock(_height: number): Promise<Block<any>>;
|
16
|
+
getBlockInfo(_height: number): Promise<BlockInfo>;
|
15
17
|
};
|
16
18
|
export {};
|
17
19
|
//# sourceMappingURL=network-alpaca.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"network-alpaca.d.ts","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"network-alpaca.d.ts","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,WAAW,EAEZ,MAAM,oCAAoC,CAAC;AAiG5C,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAsEF,eAAO,MAAM,mBAAmB,kBAAmB,MAAM;iCAxJb,MAAM,KAAG,QAAQ,MAAM,CAAC;kBAmBvC,MAAM,aAAa,MAAM,WAAW,MAAM,KAAG,QAAQ,MAAM,CAAC;8BAqC5E,OAAO,eACH,WAAW,KACvB,QAAQ,qBAAqB,CAAC;2BApBG,kBAAkB,GAAG,CAAC,KAAG,QAAQ,aAAa,CAAC;0BA+ChD,MAAM,KAAG,QAAQ,QAAQ,SAAS,CAAC,EAAE,CAAC;8BAetC,MAAM,KAAG,QAAQ,WAAW,CAAC;8BAWrD,MAAM,cACH,UAAU,KACrB,QAAQ,CAAC,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;qBAYV,QAAQ,SAAS,CAAC;+BAaN,kBAAkB,GAAG,CAAC,KAAG,QAAQ,MAAM,CAAC;+BAyB3D,QAAQ,MAAM,GAAG,CAAC,CAAC;0BAGhB,MAAM,GAAG,QAAQ,SAAS,CAAC;CAG9B,CAAC"}
|
@@ -120,5 +120,11 @@ export const getNetworkAlpacaApi = (networkFamily) => ({
|
|
120
120
|
listOperations: buildListOperations(networkFamily),
|
121
121
|
lastBlock: buildLastBlock(networkFamily),
|
122
122
|
craftTransaction: buildCraftTransaction(networkFamily),
|
123
|
+
getBlock(_height) {
|
124
|
+
throw new Error("getBlock is not supported");
|
125
|
+
},
|
126
|
+
getBlockInfo(_height) {
|
127
|
+
throw new Error("getBlockInfo is not supported");
|
128
|
+
},
|
123
129
|
});
|
124
130
|
//# sourceMappingURL=network-alpaca.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"network-alpaca.js","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"network-alpaca.js","sourceRoot":"","sources":["../../../../../src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts"],"names":[],"mappings":"AAcA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,SAAS,OAAO,CAAC,SAAc;IAC7B,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO;QACL,GAAG,SAAS;QACZ,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAC9B,EAAE,EAAE,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;KACxE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEzC,MAAM,cAAc,GAAG,CAAC,aAAqB,EAAE,EAAE,CAC/C,KAAK,UAAU,SAAS,CAAC,eAAuB;IAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAO5B;QACA,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,UAAU,IAAI,aAAa,wBAAwB;QAC3D,IAAI,EAAE;YACJ,cAAc,EAAE,eAAe;SAChC;KACF,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,qBAAqB,CAAC;AACpC,CAAC,CAAC;AAEJ,MAAM,YAAY,GAAG,CAAC,aAAqB,EAAE,EAAE,CAC7C,KAAK,UAAU,OAAO,CAAC,EAAU,EAAE,SAAiB,EAAE,MAAe;IACnE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAK5B;QACA,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,UAAU,IAAI,aAAa,sBAAsB;QACzD,IAAI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types-cryptoassets").CryptoCurrency;
|
3
|
+
export declare const mockEthCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
4
|
+
export declare const mockArbitrumCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
5
|
+
export declare const mockBaseCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
6
|
+
export declare const mockScrollCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
7
|
+
export declare const mockInjectiveCryptoCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
8
|
+
export declare const arbitrumToken: TokenCurrency;
|
9
|
+
export declare const usdcToken: TokenCurrency;
|
10
|
+
export declare const findCryptoCurrencyById: (id: string) => import("@ledgerhq/types-cryptoassets").CryptoCurrency | undefined;
|
11
|
+
export declare const getTokenOrCryptoCurrencyById: (id: string) => import("@ledgerhq/types-cryptoassets").CryptoCurrency | TokenCurrency | undefined;
|
12
|
+
export declare const mockCurrenciesByProvider: {
|
13
|
+
providerId: string;
|
14
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
15
|
+
}[];
|
16
|
+
export declare const mockCurrencyIds: string[];
|
17
|
+
//# sourceMappingURL=currencies.mock.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currencies.mock.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/currencies.mock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,uDAAmC,CAAC;AACtE,eAAO,MAAM,qBAAqB,uDAAoC,CAAC;AACvE,eAAO,MAAM,0BAA0B,uDAAoC,CAAC;AAC5E,eAAO,MAAM,sBAAsB,uDAAgC,CAAC;AACpE,eAAO,MAAM,wBAAwB,uDAAkC,CAAC;AACxE,eAAO,MAAM,2BAA2B,uDAAqC,CAAC;AAE9E,eAAO,MAAM,aAAa,EAAE,aAe3B,CAAC;AACF,eAAO,MAAM,SAAS,EAAE,aAevB,CAAC;AAEF,eAAO,MAAM,sBAAsB,OAAQ,MAAM,sEACkD,CAAC;AACpG,eAAO,MAAM,4BAA4B,OAAQ,MAAM,sFAO7B,CAAC;AAE3B,eAAO,MAAM,wBAAwB;;;GAKpC,CAAC;AAEF,eAAO,MAAM,eAAe,UAA8C,CAAC"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
|
2
|
+
export const mockBtcCryptoCurrency = getCryptoCurrencyById("bitcoin");
|
3
|
+
export const mockEthCryptoCurrency = getCryptoCurrencyById("ethereum");
|
4
|
+
export const mockArbitrumCryptoCurrency = getCryptoCurrencyById("arbitrum");
|
5
|
+
export const mockBaseCryptoCurrency = getCryptoCurrencyById("base");
|
6
|
+
export const mockScrollCryptoCurrency = getCryptoCurrencyById("scroll");
|
7
|
+
export const mockInjectiveCryptoCurrency = getCryptoCurrencyById("injective");
|
8
|
+
export const arbitrumToken = {
|
9
|
+
type: "TokenCurrency",
|
10
|
+
id: "arbitrum/erc20/arbitrum",
|
11
|
+
contractAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
|
12
|
+
parentCurrency: mockArbitrumCryptoCurrency,
|
13
|
+
tokenType: "erc20",
|
14
|
+
name: "Arbitrum",
|
15
|
+
ticker: "ARB",
|
16
|
+
units: [
|
17
|
+
{
|
18
|
+
name: "Arbitrum",
|
19
|
+
code: "ARB",
|
20
|
+
magnitude: 18,
|
21
|
+
},
|
22
|
+
],
|
23
|
+
};
|
24
|
+
export const usdcToken = {
|
25
|
+
type: "TokenCurrency",
|
26
|
+
id: "ethereum/erc20/usd__coin",
|
27
|
+
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
28
|
+
parentCurrency: mockEthCryptoCurrency,
|
29
|
+
tokenType: "erc20",
|
30
|
+
name: "USD Coin",
|
31
|
+
ticker: "USDC",
|
32
|
+
units: [
|
33
|
+
{
|
34
|
+
name: "USD Coin",
|
35
|
+
code: "USDC",
|
36
|
+
magnitude: 6,
|
37
|
+
},
|
38
|
+
],
|
39
|
+
};
|
40
|
+
export const findCryptoCurrencyById = (id) => [mockBtcCryptoCurrency, mockEthCryptoCurrency, mockArbitrumCryptoCurrency].find(a => a.id === id);
|
41
|
+
export const getTokenOrCryptoCurrencyById = (id) => [
|
42
|
+
mockBtcCryptoCurrency,
|
43
|
+
mockEthCryptoCurrency,
|
44
|
+
mockArbitrumCryptoCurrency,
|
45
|
+
arbitrumToken,
|
46
|
+
usdcToken,
|
47
|
+
].find(a => a.id === id);
|
48
|
+
export const mockCurrenciesByProvider = [
|
49
|
+
{
|
50
|
+
providerId: "ethereum",
|
51
|
+
currenciesByNetwork: [mockEthCryptoCurrency],
|
52
|
+
},
|
53
|
+
];
|
54
|
+
export const mockCurrencyIds = ["bitcoin", "ethereum", "arbitrum", "base"];
|
55
|
+
//# sourceMappingURL=currencies.mock.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currencies.mock.js","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/currencies.mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAE9E,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e,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/// <reference types="jest" />
|
2
|
+
export declare const providers: ({
|
3
|
+
providerId: string;
|
4
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
5
|
+
} | {
|
6
|
+
providerId: string;
|
7
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").TokenCurrency[];
|
8
|
+
})[];
|
9
|
+
export declare const res: {
|
10
|
+
result: {
|
11
|
+
currenciesByProvider: ({
|
12
|
+
providerId: string;
|
13
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
14
|
+
} | {
|
15
|
+
providerId: string;
|
16
|
+
currenciesByNetwork: import("@ledgerhq/types-cryptoassets").TokenCurrency[];
|
17
|
+
})[];
|
18
|
+
sortedCryptoCurrencies: import("@ledgerhq/types-cryptoassets").CryptoCurrency[];
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export declare const useGroupedCurrenciesByProvider: jest.Mock;
|
22
|
+
//# sourceMappingURL=useGroupedCurrenciesByProvider.mock.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useGroupedCurrenciesByProvider.mock.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts"],"names":[],"mappings":";AAYA,eAAO,MAAM,SAAS;;;;;;IAiBrB,CAAC;AAEF,eAAO,MAAM,GAAG;;;;;;;;;;;CAYf,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,IAAI,CAAC,IAG/C,CAAC"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { LoadingStatus } from "@ledgerhq/live-common/deposit/type";
|
2
|
+
import { arbitrumToken, mockArbitrumCryptoCurrency, mockBaseCryptoCurrency, mockBtcCryptoCurrency, mockEthCryptoCurrency, mockInjectiveCryptoCurrency, mockScrollCryptoCurrency, usdcToken, } from "./currencies.mock";
|
3
|
+
export const providers = [
|
4
|
+
{
|
5
|
+
providerId: "bitcoin",
|
6
|
+
currenciesByNetwork: [mockBtcCryptoCurrency],
|
7
|
+
},
|
8
|
+
{
|
9
|
+
providerId: "ethereum",
|
10
|
+
currenciesByNetwork: [
|
11
|
+
mockEthCryptoCurrency,
|
12
|
+
mockArbitrumCryptoCurrency,
|
13
|
+
mockBaseCryptoCurrency,
|
14
|
+
mockScrollCryptoCurrency,
|
15
|
+
],
|
16
|
+
},
|
17
|
+
{ providerId: "arbitrum", currenciesByNetwork: [arbitrumToken] },
|
18
|
+
{ providerId: "usd-coin", currenciesByNetwork: [usdcToken] },
|
19
|
+
{ providerId: "injective-protocol", currenciesByNetwork: [mockInjectiveCryptoCurrency] },
|
20
|
+
];
|
21
|
+
export const res = {
|
22
|
+
result: {
|
23
|
+
currenciesByProvider: providers,
|
24
|
+
sortedCryptoCurrencies: [
|
25
|
+
mockBtcCryptoCurrency,
|
26
|
+
mockEthCryptoCurrency,
|
27
|
+
mockArbitrumCryptoCurrency,
|
28
|
+
mockBaseCryptoCurrency,
|
29
|
+
mockScrollCryptoCurrency,
|
30
|
+
mockInjectiveCryptoCurrency,
|
31
|
+
],
|
32
|
+
},
|
33
|
+
};
|
34
|
+
export const useGroupedCurrenciesByProvider = jest.fn(() => ({
|
35
|
+
...res,
|
36
|
+
loadingStatus: LoadingStatus.Success,
|
37
|
+
}));
|
38
|
+
//# sourceMappingURL=useGroupedCurrenciesByProvider.mock.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useGroupedCurrenciesByProvider.mock.js","sourceRoot":"","sources":["../../../src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,EACxB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;QACE,UAAU,EAAE,SAAS;QACrB,mBAAmB,EAAE,CAAC,qBAAqB,CAAC;KAC7C;IACD;QACE,UAAU,EAAE,UAAU;QACtB,mBAAmB,EAAE;YACnB,qBAAqB;YACrB,0BAA0B;YAC1B,sBAAsB;YACtB,wBAAwB;SACzB;KACF;IACD,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,aAAa,CAAC,EAAE;IAChE,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,SAAS,CAAC,EAAE;IAC5D,EAAE,UAAU,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC,2BAA2B,CAAC,EAAE;CACzF,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,MAAM,EAAE;QACN,oBAAoB,EAAE,SAAS;QAC/B,sBAAsB,EAAE;YACtB,qBAAqB;YACrB,qBAAqB;YACrB,0BAA0B;YAC1B,sBAAsB;YACtB,wBAAwB;YACxB,2BAA2B;SAC5B;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAc,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,GAAG,GAAG;IACN,aAAa,EAAE,aAAa,CAAC,OAAO;CACrC,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.test.d.ts","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { haveOneCommonProvider } from "../haveOneCommonProvider";
|
2
|
+
import { useGroupedCurrenciesByProvider } from "../../__mocks__/useGroupedCurrenciesByProvider.mock";
|
3
|
+
jest.mock("@ledgerhq/live-common/deposit/useGroupedCurrenciesByProvider.hook", () => ({
|
4
|
+
useGroupedCurrenciesByProvider: () => useGroupedCurrenciesByProvider(),
|
5
|
+
}));
|
6
|
+
describe("haveOneCommonProvider", () => {
|
7
|
+
it("should return false for an empty array", () => {
|
8
|
+
expect(haveOneCommonProvider([], [])).toBe(false);
|
9
|
+
});
|
10
|
+
it("should return true for a single currency with one provider", () => {
|
11
|
+
const { result } = useGroupedCurrenciesByProvider(true);
|
12
|
+
const { currenciesByProvider } = result;
|
13
|
+
expect(haveOneCommonProvider(["bitcoin"], currenciesByProvider)).toBe(true);
|
14
|
+
});
|
15
|
+
it("should return false for multiple currencies with different providers", () => {
|
16
|
+
const { result } = useGroupedCurrenciesByProvider(true);
|
17
|
+
const { currenciesByProvider } = result;
|
18
|
+
expect(haveOneCommonProvider(["bitcoin", "ethereum"], currenciesByProvider)).toBe(false);
|
19
|
+
});
|
20
|
+
it("should return true for multiple currencies with the same provider", () => {
|
21
|
+
const { result } = useGroupedCurrenciesByProvider(true);
|
22
|
+
const { currenciesByProvider } = result;
|
23
|
+
expect(haveOneCommonProvider(["ethereum", "arbitrum"], currenciesByProvider)).toBe(true);
|
24
|
+
});
|
25
|
+
});
|
26
|
+
//# sourceMappingURL=haveOneCommonProvider.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.test.js","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AAGrG,IAAI,CAAC,IAAI,CAAC,mEAAmE,EAAE,GAAG,EAAE,CAAC,CAAC;IACpF,8BAA8B,EAAE,GAAG,EAAE,CAAC,8BAA8B,EAAE;CACvE,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,w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|
+
* it stopped at the first currency that does not match to prevent unnecessary iterations.
|
5
|
+
*
|
6
|
+
* @param currenciesIdsArray array of currency IDs to check
|
7
|
+
* @param currenciesByProvider array of currencies grouped by provider
|
8
|
+
* @returns boolean indicating whether all currencies in the array have one common provider
|
9
|
+
*/
|
10
|
+
export declare const haveOneCommonProvider: (currenciesIdsArray: string[], currenciesByProvider: CurrenciesByProviderId[]) => boolean;
|
11
|
+
//# sourceMappingURL=haveOneCommonProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,uBACZ,MAAM,EAAE,wBACN,sBAAsB,EAAE,KAC7C,OAiBF,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* This function checks if all currencies in the provided array
|
3
|
+
* it stopped at the first currency that does not match to prevent unnecessary iterations.
|
4
|
+
*
|
5
|
+
* @param currenciesIdsArray array of currency IDs to check
|
6
|
+
* @param currenciesByProvider array of currencies grouped by provider
|
7
|
+
* @returns boolean indicating whether all currencies in the array have one common provider
|
8
|
+
*/
|
9
|
+
export const haveOneCommonProvider = (currenciesIdsArray, currenciesByProvider) => {
|
10
|
+
if (currenciesIdsArray.length === 0)
|
11
|
+
return false;
|
12
|
+
const providerIds = new Set();
|
13
|
+
for (const currencyId of currenciesIdsArray) {
|
14
|
+
for (const provider of currenciesByProvider) {
|
15
|
+
if (provider.currenciesByNetwork.some(currency => currency.id === currencyId)) {
|
16
|
+
providerIds.add(provider.providerId);
|
17
|
+
if (providerIds.size > 1) {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
return true;
|
24
|
+
};
|
25
|
+
//# sourceMappingURL=haveOneCommonProvider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"haveOneCommonProvider.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,kBAA4B,EAC5B,oBAA8C,EACrC,EAAE;IACX,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAElD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,KAAK,MAAM,UAAU,IAAI,kBAAkB,EAAE;QAC3C,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE;YAC3C,IAAI,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE;gBAC7E,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACrC,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE;oBACxB,OAAO,KAAK,CAAC;iBACd;aACF;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
2
|
import { CurrenciesByProviderId } from "../../deposit/type";
|
3
|
+
import { haveOneCommonProvider } from "./haveOneCommonProvider";
|
3
4
|
declare function isCorrespondingCurrency(elem: CryptoOrTokenCurrency, network: CryptoOrTokenCurrency): boolean;
|
4
5
|
declare const getEffectiveCurrency: (currency: CryptoOrTokenCurrency, provider: CurrenciesByProviderId, currencyIds: string[]) => CryptoOrTokenCurrency;
|
5
|
-
export { isCorrespondingCurrency, getEffectiveCurrency };
|
6
|
+
export { isCorrespondingCurrency, getEffectiveCurrency, haveOneCommonProvider };
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,iBAAS,uBAAuB,CAC9B,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAQT;AAED,QAAA,MAAM,oBAAoB,aACd,qBAAqB,YACrB,sBAAsB,eACnB,MAAM,EAAE,0BAOtB,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { haveOneCommonProvider } from "./haveOneCommonProvider";
|
1
2
|
function isCorrespondingCurrency(elem, network) {
|
2
3
|
if (elem.type === "TokenCurrency") {
|
3
4
|
return elem.parentCurrency?.id === network.id || elem.id === network.id;
|
@@ -13,5 +14,5 @@ const getEffectiveCurrency = (currency, provider, currencyIds) => {
|
|
13
14
|
return currency;
|
14
15
|
return provider.currenciesByNetwork.find(elem => currencyIds.includes(elem.id)) ?? currency;
|
15
16
|
};
|
16
|
-
export { isCorrespondingCurrency, getEffectiveCurrency };
|
17
|
+
export { isCorrespondingCurrency, getEffectiveCurrency, haveOneCommonProvider };
|
17
18
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,SAAS,uBAAuB,CAC9B,IAA2B,EAC3B,OAA8B;IAE9B,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE;QACjC,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;KACzE;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;QAClC,OAAO,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;KAC/B;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,oBAAoB,GAAG,CAC3B,QAA+B,EAC/B,QAAgC,EAChC,WAAqB,EACrB,EAAE;IACF,MAAM,kBAAkB,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE7D,IAAI,kBAAkB;QAAE,OAAO,QAAQ,CAAC;IAExC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ,CAAC;AAC9F,CAAC,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ledgerhq/live-common",
|
3
3
|
"description": "Common ground for the Ledger Live apps",
|
4
|
-
"version": "34.42.0-nightly.
|
4
|
+
"version": "34.42.0-nightly.3",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
7
7
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
@@ -162,39 +162,39 @@
|
|
162
162
|
"xstate": "^5.19.2",
|
163
163
|
"yargs": "^17.0.0",
|
164
164
|
"zod": "^3.22.4",
|
165
|
-
"@ledgerhq/coin-algorand": "^0.9.14-nightly.
|
166
|
-
"@ledgerhq/coin-aptos": "^2.
|
167
|
-
"@ledgerhq/coin-bitcoin": "^0.17.1-nightly.
|
168
|
-
"@ledgerhq/coin-cardano": "^0.9.1-nightly.
|
169
|
-
"@ledgerhq/coin-casper": "^2.0.5-nightly.
|
170
|
-
"@ledgerhq/coin-celo": "^1.1.12-nightly.
|
171
|
-
"@ledgerhq/coin-cosmos": "^0.16.3-nightly.
|
172
|
-
"@ledgerhq/coin-evm": "^2.
|
173
|
-
"@ledgerhq/coin-filecoin": "^1.9.14-nightly.
|
174
|
-
"@ledgerhq/coin-framework": "^5.7.0-nightly.
|
175
|
-
"@ledgerhq/coin-hedera": "^1.8.3-nightly.
|
176
|
-
"@ledgerhq/coin-icon": "^0.11.1-nightly.
|
177
|
-
"@ledgerhq/coin-internet_computer": "^1.7.14-nightly.
|
178
|
-
"@ledgerhq/coin-mina": "^1.1.13-nightly.
|
179
|
-
"@ledgerhq/coin-multiversx": "^0.4.14-nightly.
|
180
|
-
"@ledgerhq/coin-near": "^0.11.14-nightly.
|
181
|
-
"@ledgerhq/coin-polkadot": "^6.
|
182
|
-
"@ledgerhq/coin-solana": "^0.28.0-nightly.
|
183
|
-
"@ledgerhq/coin-stacks": "^0.8.14-nightly.
|
184
|
-
"@ledgerhq/coin-stellar": "^5.
|
185
|
-
"@ledgerhq/coin-sui": "^0.7.0-nightly.
|
186
|
-
"@ledgerhq/coin-tezos": "^5.
|
187
|
-
"@ledgerhq/coin-ton": "^0.13.3-nightly.
|
188
|
-
"@ledgerhq/coin-tron": "^4.
|
189
|
-
"@ledgerhq/coin-vechain": "^2.7.14-nightly.
|
190
|
-
"@ledgerhq/coin-xrp": "^6.
|
165
|
+
"@ledgerhq/coin-algorand": "^0.9.14-nightly.2",
|
166
|
+
"@ledgerhq/coin-aptos": "^2.6.0-nightly.2",
|
167
|
+
"@ledgerhq/coin-bitcoin": "^0.17.1-nightly.2",
|
168
|
+
"@ledgerhq/coin-cardano": "^0.9.1-nightly.2",
|
169
|
+
"@ledgerhq/coin-casper": "^2.0.5-nightly.2",
|
170
|
+
"@ledgerhq/coin-celo": "^1.1.12-nightly.2",
|
171
|
+
"@ledgerhq/coin-cosmos": "^0.16.3-nightly.2",
|
172
|
+
"@ledgerhq/coin-evm": "^2.24.0-nightly.2",
|
173
|
+
"@ledgerhq/coin-filecoin": "^1.9.14-nightly.2",
|
174
|
+
"@ledgerhq/coin-framework": "^5.7.0-nightly.2",
|
175
|
+
"@ledgerhq/coin-hedera": "^1.8.3-nightly.2",
|
176
|
+
"@ledgerhq/coin-icon": "^0.11.1-nightly.2",
|
177
|
+
"@ledgerhq/coin-internet_computer": "^1.7.14-nightly.2",
|
178
|
+
"@ledgerhq/coin-mina": "^1.1.13-nightly.2",
|
179
|
+
"@ledgerhq/coin-multiversx": "^0.4.14-nightly.2",
|
180
|
+
"@ledgerhq/coin-near": "^0.11.14-nightly.2",
|
181
|
+
"@ledgerhq/coin-polkadot": "^6.4.0-nightly.2",
|
182
|
+
"@ledgerhq/coin-solana": "^0.28.0-nightly.2",
|
183
|
+
"@ledgerhq/coin-stacks": "^0.8.14-nightly.2",
|
184
|
+
"@ledgerhq/coin-stellar": "^5.4.0-nightly.2",
|
185
|
+
"@ledgerhq/coin-sui": "^0.7.0-nightly.2",
|
186
|
+
"@ledgerhq/coin-tezos": "^5.7.0-nightly.2",
|
187
|
+
"@ledgerhq/coin-ton": "^0.13.3-nightly.2",
|
188
|
+
"@ledgerhq/coin-tron": "^4.5.0-nightly.2",
|
189
|
+
"@ledgerhq/coin-vechain": "^2.7.14-nightly.2",
|
190
|
+
"@ledgerhq/coin-xrp": "^6.5.0-nightly.2",
|
191
191
|
"@ledgerhq/crypto-icons-ui": "^1.16.0",
|
192
192
|
"@ledgerhq/cryptoassets": "^13.22.0-nightly.5",
|
193
193
|
"@ledgerhq/device-core": "^0.5.3-nightly.0",
|
194
194
|
"@ledgerhq/devices": "8.4.8-nightly.0",
|
195
195
|
"@ledgerhq/errors": "^6.23.0-nightly.0",
|
196
|
-
"@ledgerhq/hw-app-algorand": "^6.31.4-nightly.0",
|
197
196
|
"@ledgerhq/hw-app-aptos": "^6.34.4-nightly.0",
|
197
|
+
"@ledgerhq/hw-app-algorand": "^6.31.4-nightly.0",
|
198
198
|
"@ledgerhq/hw-app-btc": "^10.10.0-nightly.1",
|
199
199
|
"@ledgerhq/hw-app-celo": "^6.33.10-nightly.0",
|
200
200
|
"@ledgerhq/hw-app-cosmos": "^6.32.4-nightly.0",
|
@@ -215,17 +215,17 @@
|
|
215
215
|
"@ledgerhq/hw-transport-mocker": "^6.29.8-nightly.0",
|
216
216
|
"@ledgerhq/ledger-cal-service": "^1.2.1-nightly.1",
|
217
217
|
"@ledgerhq/live-config": "^3.1.0",
|
218
|
-
"@ledgerhq/live-countervalues": "^0.5.14-nightly.
|
219
|
-
"@ledgerhq/live-countervalues-react": "^0.2.43-nightly.
|
218
|
+
"@ledgerhq/live-countervalues": "^0.5.14-nightly.2",
|
219
|
+
"@ledgerhq/live-countervalues-react": "^0.2.43-nightly.2",
|
220
220
|
"@ledgerhq/live-dmk-shared": "^0.11.0",
|
221
221
|
"@ledgerhq/live-env": "^2.12.0-nightly.1",
|
222
222
|
"@ledgerhq/live-hooks": "0.1.0",
|
223
223
|
"@ledgerhq/live-network": "^2.0.13-nightly.1",
|
224
|
-
"@ledgerhq/live-nft": "^0.8.14-nightly.
|
224
|
+
"@ledgerhq/live-nft": "^0.8.14-nightly.2",
|
225
225
|
"@ledgerhq/live-promise": "^0.1.1",
|
226
|
-
"@ledgerhq/live-signer-evm": "^0.5.7-nightly.
|
227
|
-
"@ledgerhq/live-signer-solana": "^0.4.2-nightly.
|
228
|
-
"@ledgerhq/live-wallet": "^0.11.5-nightly.
|
226
|
+
"@ledgerhq/live-signer-evm": "^0.5.7-nightly.2",
|
227
|
+
"@ledgerhq/live-signer-solana": "^0.4.2-nightly.2",
|
228
|
+
"@ledgerhq/live-wallet": "^0.11.5-nightly.3",
|
229
229
|
"@ledgerhq/logs": "^6.13.0",
|
230
230
|
"@ledgerhq/speculos-transport": "^0.2.6-nightly.1",
|
231
231
|
"@ledgerhq/wallet-api-acre-module": "^0.5.0",
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import {
|
2
2
|
Account,
|
3
3
|
Balance,
|
4
|
+
Block,
|
4
5
|
BlockInfo,
|
5
6
|
Operation,
|
6
7
|
FeeEstimation,
|
@@ -190,4 +191,10 @@ export const getNetworkAlpacaApi = (networkFamily: string) =>
|
|
190
191
|
listOperations: buildListOperations(networkFamily),
|
191
192
|
lastBlock: buildLastBlock(networkFamily),
|
192
193
|
craftTransaction: buildCraftTransaction(networkFamily),
|
194
|
+
getBlock(_height): Promise<Block<any>> {
|
195
|
+
throw new Error("getBlock is not supported");
|
196
|
+
},
|
197
|
+
getBlockInfo(_height: number): Promise<BlockInfo> {
|
198
|
+
throw new Error("getBlockInfo is not supported");
|
199
|
+
},
|
193
200
|
}) satisfies Api<any>;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
|
2
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
|
4
|
+
export const mockBtcCryptoCurrency = getCryptoCurrencyById("bitcoin");
|
5
|
+
export const mockEthCryptoCurrency = getCryptoCurrencyById("ethereum");
|
6
|
+
export const mockArbitrumCryptoCurrency = getCryptoCurrencyById("arbitrum");
|
7
|
+
export const mockBaseCryptoCurrency = getCryptoCurrencyById("base");
|
8
|
+
export const mockScrollCryptoCurrency = getCryptoCurrencyById("scroll");
|
9
|
+
export const mockInjectiveCryptoCurrency = getCryptoCurrencyById("injective");
|
10
|
+
|
11
|
+
export const arbitrumToken: TokenCurrency = {
|
12
|
+
type: "TokenCurrency",
|
13
|
+
id: "arbitrum/erc20/arbitrum",
|
14
|
+
contractAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
|
15
|
+
parentCurrency: mockArbitrumCryptoCurrency,
|
16
|
+
tokenType: "erc20",
|
17
|
+
name: "Arbitrum",
|
18
|
+
ticker: "ARB",
|
19
|
+
units: [
|
20
|
+
{
|
21
|
+
name: "Arbitrum",
|
22
|
+
code: "ARB",
|
23
|
+
magnitude: 18,
|
24
|
+
},
|
25
|
+
],
|
26
|
+
};
|
27
|
+
export const usdcToken: TokenCurrency = {
|
28
|
+
type: "TokenCurrency",
|
29
|
+
id: "ethereum/erc20/usd__coin",
|
30
|
+
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
31
|
+
parentCurrency: mockEthCryptoCurrency,
|
32
|
+
tokenType: "erc20",
|
33
|
+
name: "USD Coin",
|
34
|
+
ticker: "USDC",
|
35
|
+
units: [
|
36
|
+
{
|
37
|
+
name: "USD Coin",
|
38
|
+
code: "USDC",
|
39
|
+
magnitude: 6,
|
40
|
+
},
|
41
|
+
],
|
42
|
+
};
|
43
|
+
|
44
|
+
export const findCryptoCurrencyById = (id: string) =>
|
45
|
+
[mockBtcCryptoCurrency, mockEthCryptoCurrency, mockArbitrumCryptoCurrency].find(a => a.id === id);
|
46
|
+
export const getTokenOrCryptoCurrencyById = (id: string) =>
|
47
|
+
[
|
48
|
+
mockBtcCryptoCurrency,
|
49
|
+
mockEthCryptoCurrency,
|
50
|
+
mockArbitrumCryptoCurrency,
|
51
|
+
arbitrumToken,
|
52
|
+
usdcToken,
|
53
|
+
].find(a => a.id === id);
|
54
|
+
|
55
|
+
export const mockCurrenciesByProvider = [
|
56
|
+
{
|
57
|
+
providerId: "ethereum",
|
58
|
+
currenciesByNetwork: [mockEthCryptoCurrency],
|
59
|
+
},
|
60
|
+
];
|
61
|
+
|
62
|
+
export const mockCurrencyIds = ["bitcoin", "ethereum", "arbitrum", "base"];
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { LoadingStatus } from "@ledgerhq/live-common/deposit/type";
|
2
|
+
import {
|
3
|
+
arbitrumToken,
|
4
|
+
mockArbitrumCryptoCurrency,
|
5
|
+
mockBaseCryptoCurrency,
|
6
|
+
mockBtcCryptoCurrency,
|
7
|
+
mockEthCryptoCurrency,
|
8
|
+
mockInjectiveCryptoCurrency,
|
9
|
+
mockScrollCryptoCurrency,
|
10
|
+
usdcToken,
|
11
|
+
} from "./currencies.mock";
|
12
|
+
|
13
|
+
export const providers = [
|
14
|
+
{
|
15
|
+
providerId: "bitcoin",
|
16
|
+
currenciesByNetwork: [mockBtcCryptoCurrency],
|
17
|
+
},
|
18
|
+
{
|
19
|
+
providerId: "ethereum",
|
20
|
+
currenciesByNetwork: [
|
21
|
+
mockEthCryptoCurrency,
|
22
|
+
mockArbitrumCryptoCurrency,
|
23
|
+
mockBaseCryptoCurrency,
|
24
|
+
mockScrollCryptoCurrency,
|
25
|
+
],
|
26
|
+
},
|
27
|
+
{ providerId: "arbitrum", currenciesByNetwork: [arbitrumToken] },
|
28
|
+
{ providerId: "usd-coin", currenciesByNetwork: [usdcToken] },
|
29
|
+
{ providerId: "injective-protocol", currenciesByNetwork: [mockInjectiveCryptoCurrency] },
|
30
|
+
];
|
31
|
+
|
32
|
+
export const res = {
|
33
|
+
result: {
|
34
|
+
currenciesByProvider: providers,
|
35
|
+
sortedCryptoCurrencies: [
|
36
|
+
mockBtcCryptoCurrency,
|
37
|
+
mockEthCryptoCurrency,
|
38
|
+
mockArbitrumCryptoCurrency,
|
39
|
+
mockBaseCryptoCurrency,
|
40
|
+
mockScrollCryptoCurrency,
|
41
|
+
mockInjectiveCryptoCurrency,
|
42
|
+
],
|
43
|
+
},
|
44
|
+
};
|
45
|
+
|
46
|
+
export const useGroupedCurrenciesByProvider: jest.Mock = jest.fn(() => ({
|
47
|
+
...res,
|
48
|
+
loadingStatus: LoadingStatus.Success,
|
49
|
+
}));
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { haveOneCommonProvider } from "../haveOneCommonProvider";
|
2
|
+
import { useGroupedCurrenciesByProvider } from "../../__mocks__/useGroupedCurrenciesByProvider.mock";
|
3
|
+
import { LoadingBasedGroupedCurrencies } from "@ledgerhq/live-common/deposit/type";
|
4
|
+
|
5
|
+
jest.mock("@ledgerhq/live-common/deposit/useGroupedCurrenciesByProvider.hook", () => ({
|
6
|
+
useGroupedCurrenciesByProvider: () => useGroupedCurrenciesByProvider(),
|
7
|
+
}));
|
8
|
+
|
9
|
+
describe("haveOneCommonProvider", () => {
|
10
|
+
it("should return false for an empty array", () => {
|
11
|
+
expect(haveOneCommonProvider([], [])).toBe(false);
|
12
|
+
});
|
13
|
+
|
14
|
+
it("should return true for a single currency with one provider", () => {
|
15
|
+
const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
|
16
|
+
const { currenciesByProvider } = result;
|
17
|
+
|
18
|
+
expect(haveOneCommonProvider(["bitcoin"], currenciesByProvider)).toBe(true);
|
19
|
+
});
|
20
|
+
|
21
|
+
it("should return false for multiple currencies with different providers", () => {
|
22
|
+
const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
|
23
|
+
const { currenciesByProvider } = result;
|
24
|
+
|
25
|
+
expect(haveOneCommonProvider(["bitcoin", "ethereum"], currenciesByProvider)).toBe(false);
|
26
|
+
});
|
27
|
+
|
28
|
+
it("should return true for multiple currencies with the same provider", () => {
|
29
|
+
const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
|
30
|
+
const { currenciesByProvider } = result;
|
31
|
+
|
32
|
+
expect(haveOneCommonProvider(["ethereum", "arbitrum"], currenciesByProvider)).toBe(true);
|
33
|
+
});
|
34
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { CurrenciesByProviderId } from "@ledgerhq/live-common/deposit/type";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* This function checks if all currencies in the provided array
|
5
|
+
* it stopped at the first currency that does not match to prevent unnecessary iterations.
|
6
|
+
*
|
7
|
+
* @param currenciesIdsArray array of currency IDs to check
|
8
|
+
* @param currenciesByProvider array of currencies grouped by provider
|
9
|
+
* @returns boolean indicating whether all currencies in the array have one common provider
|
10
|
+
*/
|
11
|
+
export const haveOneCommonProvider = (
|
12
|
+
currenciesIdsArray: string[],
|
13
|
+
currenciesByProvider: CurrenciesByProviderId[],
|
14
|
+
): boolean => {
|
15
|
+
if (currenciesIdsArray.length === 0) return false;
|
16
|
+
|
17
|
+
const providerIds = new Set<string>();
|
18
|
+
|
19
|
+
for (const currencyId of currenciesIdsArray) {
|
20
|
+
for (const provider of currenciesByProvider) {
|
21
|
+
if (provider.currenciesByNetwork.some(currency => currency.id === currencyId)) {
|
22
|
+
providerIds.add(provider.providerId);
|
23
|
+
if (providerIds.size > 1) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return true;
|
31
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
2
|
import { CurrenciesByProviderId } from "../../deposit/type";
|
3
|
+
import { haveOneCommonProvider } from "./haveOneCommonProvider";
|
3
4
|
|
4
5
|
function isCorrespondingCurrency(
|
5
6
|
elem: CryptoOrTokenCurrency,
|
@@ -26,4 +27,4 @@ const getEffectiveCurrency = (
|
|
26
27
|
return provider.currenciesByNetwork.find(elem => currencyIds.includes(elem.id)) ?? currency;
|
27
28
|
};
|
28
29
|
|
29
|
-
export { isCorrespondingCurrency, getEffectiveCurrency };
|
30
|
+
export { isCorrespondingCurrency, getEffectiveCurrency, haveOneCommonProvider };
|