@ledgerhq/live-common 25.0.0-next.2 → 25.0.0-next.5
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__/accounts/importAccounts.js +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -1
- package/lib/account/helpers.d.ts +5 -1
- package/lib/account/helpers.d.ts.map +1 -1
- package/lib/account/helpers.js +28 -1
- package/lib/account/helpers.js.map +1 -1
- package/lib/apps/filtering.test.js +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +2 -1
- package/lib/apps/support.js.map +1 -1
- package/lib/currencies/helpers.d.ts +9 -0
- package/lib/currencies/helpers.d.ts.map +1 -0
- package/lib/currencies/helpers.js +78 -0
- package/lib/currencies/helpers.js.map +1 -0
- package/lib/currencies/helpers.test.d.ts +2 -0
- package/lib/currencies/helpers.test.d.ts.map +1 -0
- package/lib/currencies/helpers.test.js +20 -0
- package/lib/currencies/helpers.test.js.map +1 -0
- package/lib/currencies/index.d.ts +1 -0
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +1 -0
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/react.d.ts +4 -0
- package/lib/currencies/react.d.ts.map +1 -0
- package/lib/currencies/react.js +16 -0
- package/lib/currencies/react.js.map +1 -0
- package/lib/families/cardano/bridge.integration.test.d.ts.map +1 -1
- package/lib/families/cardano/bridge.integration.test.js +36 -2
- package/lib/families/cardano/bridge.integration.test.js.map +1 -1
- package/lib/families/cardano/buildSubAccounts.d.ts.map +1 -1
- package/lib/families/cardano/buildSubAccounts.js +5 -3
- package/lib/families/cardano/buildSubAccounts.js.map +1 -1
- package/lib/families/cardano/deviceTransactionConfig.d.ts +11 -0
- package/lib/families/cardano/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/families/cardano/deviceTransactionConfig.js +91 -0
- package/lib/families/cardano/deviceTransactionConfig.js.map +1 -0
- package/lib/families/cardano/errors.d.ts +4 -0
- package/lib/families/cardano/errors.d.ts.map +1 -1
- package/lib/families/cardano/errors.js +5 -1
- package/lib/families/cardano/errors.js.map +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.js +3 -2
- package/lib/families/cardano/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/cardano/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/cardano/js-getTransactionStatus.js +6 -5
- package/lib/families/cardano/js-getTransactionStatus.js.map +1 -1
- package/lib/families/cardano/js-signOperation.d.ts.map +1 -1
- package/lib/families/cardano/js-signOperation.js +10 -5
- package/lib/families/cardano/js-signOperation.js.map +1 -1
- package/lib/families/cardano/js-synchronisation.d.ts.map +1 -1
- package/lib/families/cardano/js-synchronisation.js +126 -98
- package/lib/families/cardano/js-synchronisation.js.map +1 -1
- package/lib/families/cardano/js-transaction.js +1 -1
- package/lib/families/cardano/js-transaction.js.map +1 -1
- package/lib/families/cardano/logic.d.ts +1 -0
- package/lib/families/cardano/logic.d.ts.map +1 -1
- package/lib/families/cardano/logic.js +11 -1
- package/lib/families/cardano/logic.js.map +1 -1
- package/lib/families/cardano/specs.d.ts.map +1 -1
- package/lib/families/cardano/specs.js +39 -1
- package/lib/families/cardano/specs.js.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.js +15 -0
- package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
- package/lib/families/hedera/api/mirror.js +1 -1
- package/lib/families/hedera/api/mirror.js.map +1 -1
- package/lib/families/hedera/api/network.d.ts.map +1 -1
- package/lib/families/hedera/api/network.js +3 -1
- package/lib/families/hedera/api/network.js.map +1 -1
- package/lib/families/hedera/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/families/hedera/deviceTransactionConfig.js +7 -0
- package/lib/families/hedera/deviceTransactionConfig.js.map +1 -1
- package/lib/families/hedera/js-synchronisation.d.ts.map +1 -1
- package/lib/families/hedera/js-synchronisation.js +10 -7
- package/lib/families/hedera/js-synchronisation.js.map +1 -1
- package/lib/families/hedera/specs.d.ts.map +1 -1
- package/lib/families/hedera/specs.js +23 -0
- package/lib/families/hedera/specs.js.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.js +5 -1
- package/lib/families/hedera/speculos-deviceActions.js.map +1 -1
- package/lib/families/hedera/transaction.d.ts.map +1 -1
- package/lib/families/hedera/transaction.js +2 -2
- package/lib/families/hedera/transaction.js.map +1 -1
- package/lib/families/hedera/types.d.ts +2 -5
- package/lib/families/hedera/types.d.ts.map +1 -1
- package/lib/families/hedera/types.js +0 -4
- package/lib/families/hedera/types.js.map +1 -1
- package/lib/families/hedera/utils.d.ts.map +1 -1
- package/lib/featureFlags/types.d.ts +1 -1
- package/lib/featureFlags/types.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +2 -0
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +28 -26
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.js +11 -11
- package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.d.ts +0 -7
- package/lib/platform/PlatformAppProvider/helpers.d.ts.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.js +1 -29
- package/lib/platform/PlatformAppProvider/helpers.js.map +1 -1
- package/lib/platform/converters.d.ts +4 -4
- package/lib/platform/converters.d.ts.map +1 -1
- package/lib/platform/converters.js +40 -2
- package/lib/platform/converters.js.map +1 -1
- package/lib/platform/filters.d.ts +18 -0
- package/lib/platform/filters.d.ts.map +1 -0
- package/lib/platform/filters.js +63 -0
- package/lib/platform/filters.js.map +1 -0
- package/lib/platform/helpers.d.ts +7 -0
- package/lib/platform/helpers.d.ts.map +1 -0
- package/lib/platform/helpers.js +22 -0
- package/lib/platform/helpers.js.map +1 -0
- package/lib/platform/logic.d.ts +1 -5
- package/lib/platform/logic.d.ts.map +1 -1
- package/lib/platform/logic.js +1 -18
- package/lib/platform/logic.js.map +1 -1
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/lib/platform/react.d.ts +11 -0
- package/lib/platform/react.d.ts.map +1 -0
- package/lib/platform/react.js +61 -0
- package/lib/platform/react.js.map +1 -0
- package/lib/platform/types.d.ts +8 -2
- package/lib/platform/types.d.ts.map +1 -1
- package/lib/platform/types.js +15 -0
- package/lib/platform/types.js.map +1 -1
- package/lib/platform/version.test.js +1 -1
- package/lib/walletconnect/walletconnect.test.js +0 -2
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +5 -4
- package/src/__tests__/accounts/importAccounts.ts +1 -1
- package/src/__tests__/test-helpers/setup.ts +1 -1
- package/src/account/helpers.ts +51 -0
- package/src/apps/filtering.test.ts +1 -1
- package/src/apps/support.ts +1 -0
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +101 -0
- package/src/currencies/helpers.test.ts +21 -0
- package/src/currencies/helpers.ts +69 -0
- package/src/currencies/index.ts +1 -0
- package/src/currencies/react.ts +16 -0
- package/src/families/cardano/__snapshots__/bridge.integration.test.ts.snap +41 -1
- package/src/families/cardano/bridge.integration.test.ts +38 -0
- package/src/families/cardano/buildSubAccounts.ts +5 -3
- package/src/families/cardano/deviceTransactionConfig.ts +109 -0
- package/src/families/cardano/errors.ts +7 -0
- package/src/families/cardano/js-estimateMaxSpendable.ts +4 -1
- package/src/families/cardano/js-getTransactionStatus.ts +7 -7
- package/src/families/cardano/js-signOperation.ts +10 -5
- package/src/families/cardano/js-synchronisation.ts +52 -21
- package/src/families/cardano/js-transaction.ts +1 -1
- package/src/families/cardano/logic.ts +10 -0
- package/src/families/cardano/specs.ts +53 -1
- package/src/families/cardano/speculos-deviceActions.ts +15 -0
- package/src/families/hedera/api/mirror.ts +1 -1
- package/src/families/hedera/api/network.ts +1 -0
- package/src/families/hedera/deviceTransactionConfig.ts +8 -0
- package/src/families/hedera/js-synchronisation.ts +5 -3
- package/src/families/hedera/specs.ts +56 -5
- package/src/families/hedera/speculos-deviceActions.ts +1 -0
- package/src/families/hedera/transaction.ts +2 -0
- package/src/families/hedera/types.ts +2 -8
- package/src/families/hedera/utils.ts +1 -1
- package/src/featureFlags/types.ts +1 -0
- package/src/generated/deviceTransactionConfig.ts +3 -0
- package/src/platform/PlatformAppProvider/api/api.mock.ts +11 -11
- package/src/platform/PlatformAppProvider/helpers.ts +0 -48
- package/src/platform/converters.ts +60 -6
- package/src/platform/filters.ts +102 -0
- package/src/platform/helpers.ts +33 -0
- package/src/platform/logic.ts +1 -20
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/src/platform/react.ts +93 -0
- package/src/platform/types.ts +23 -1
- package/src/platform/version.test.ts +1 -1
- package/src/walletconnect/walletconnect.test.ts +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccountLike } from "../types";
|
|
2
|
+
import { ListPlatformAccount, ListPlatformCurrency, PlatformCurrency, AppManifest } from "./types";
|
|
3
|
+
export declare function usePlatformUrl(manifest: AppManifest, params: {
|
|
4
|
+
background: string;
|
|
5
|
+
text: string;
|
|
6
|
+
loadDate?: Date;
|
|
7
|
+
}, inputs: Record<string, string>): URL;
|
|
8
|
+
export declare function useListPlatformAccounts(accounts: AccountLike[]): ListPlatformAccount;
|
|
9
|
+
export declare function usePlatformCurrencies(includeTokens?: boolean): PlatformCurrency[];
|
|
10
|
+
export declare function useListPlatformCurrencies(): ListPlatformCurrency;
|
|
11
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/platform/react.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAYvC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACZ,MAAM,SAAS,CAAC;AAIjB,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;CAAE,EAC7D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,GAAG,CAwBL;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,EAAE,GACtB,mBAAmB,CAerB;AAED,wBAAgB,qBAAqB,CACnC,aAAa,UAAQ,GACpB,gBAAgB,EAAE,CAQpB;AAED,wBAAgB,yBAAyB,IAAI,oBAAoB,CAShE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.useListPlatformCurrencies = exports.usePlatformCurrencies = exports.useListPlatformAccounts = exports.usePlatformUrl = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var converters_1 = require("./converters");
|
|
6
|
+
var filters_1 = require("./filters");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var account_1 = require("../account");
|
|
9
|
+
var currencies_1 = require("../currencies");
|
|
10
|
+
function usePlatformUrl(manifest, params, inputs) {
|
|
11
|
+
return (0, react_1.useMemo)(function () {
|
|
12
|
+
var url = new URL(manifest.url.toString());
|
|
13
|
+
if (inputs) {
|
|
14
|
+
for (var key in inputs) {
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(inputs, key)) {
|
|
16
|
+
url.searchParams.set(key, inputs[key]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
url.searchParams.set("backgroundColor", params.background);
|
|
21
|
+
url.searchParams.set("textColor", params.text);
|
|
22
|
+
if (params.loadDate) {
|
|
23
|
+
url.searchParams.set("loadDate", params.loadDate.valueOf().toString());
|
|
24
|
+
}
|
|
25
|
+
if (manifest.params) {
|
|
26
|
+
url.searchParams.set("params", JSON.stringify(manifest.params));
|
|
27
|
+
}
|
|
28
|
+
return url;
|
|
29
|
+
}, [manifest.url, manifest.params, params, inputs]);
|
|
30
|
+
}
|
|
31
|
+
exports.usePlatformUrl = usePlatformUrl;
|
|
32
|
+
function useListPlatformAccounts(accounts) {
|
|
33
|
+
var platformAccounts = (0, react_1.useMemo)(function () {
|
|
34
|
+
return accounts.map(function (account) {
|
|
35
|
+
var parentAccount = (0, account_1.getParentAccount)(account, accounts);
|
|
36
|
+
return (0, converters_1.accountToPlatformAccount)(account, parentAccount);
|
|
37
|
+
});
|
|
38
|
+
}, [accounts]);
|
|
39
|
+
return (0, react_1.useCallback)(function (filters) {
|
|
40
|
+
if (filters === void 0) { filters = {}; }
|
|
41
|
+
return (0, filters_1.filterPlatformAccounts)(platformAccounts, filters);
|
|
42
|
+
}, [platformAccounts]);
|
|
43
|
+
}
|
|
44
|
+
exports.useListPlatformAccounts = useListPlatformAccounts;
|
|
45
|
+
function usePlatformCurrencies(includeTokens) {
|
|
46
|
+
if (includeTokens === void 0) { includeTokens = false; }
|
|
47
|
+
return (0, react_1.useMemo)(function () {
|
|
48
|
+
return (0, currencies_1.listCurrencies)(includeTokens)
|
|
49
|
+
.filter(helpers_1.isPlatformSupportedCurrency)
|
|
50
|
+
.map(converters_1.currencyToPlatformCurrency);
|
|
51
|
+
}, [includeTokens]);
|
|
52
|
+
}
|
|
53
|
+
exports.usePlatformCurrencies = usePlatformCurrencies;
|
|
54
|
+
function useListPlatformCurrencies() {
|
|
55
|
+
var currencies = usePlatformCurrencies(true);
|
|
56
|
+
return (0, react_1.useCallback)(function (filters) {
|
|
57
|
+
return (0, filters_1.filterPlatformCurrencies)(currencies, filters || {});
|
|
58
|
+
}, [currencies]);
|
|
59
|
+
}
|
|
60
|
+
exports.useListPlatformCurrencies = useListPlatformCurrencies;
|
|
61
|
+
//# sourceMapping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|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SignedOperation, CryptoCurrency, TokenCurrency } from "../types";
|
|
2
|
+
import { AccountFilters, CurrencyFilters } from "./filters";
|
|
3
|
+
import { Account as PlatformAccount, Currency as PlatformCurrency } from "@ledgerhq/live-app-sdk";
|
|
4
|
+
export type { Account as PlatformAccount, Currency as PlatformCurrency, Unit as PlatformUnit, Transaction as PlatformTransaction, CryptoCurrency as PlatformCryptoCurrency, ERC20TokenCurrency as PlatformERC20TokenCurrency, } from "@ledgerhq/live-app-sdk";
|
|
5
|
+
export { CurrencyType as PlatformCurrencyType, TokenStandard as PlatformTokenStandard, } from "@ledgerhq/live-app-sdk";
|
|
3
6
|
export declare type TranslatableString = {
|
|
4
7
|
en: string;
|
|
5
8
|
[locale: string]: string;
|
|
@@ -36,4 +39,7 @@ export declare type PlatformApi = {
|
|
|
36
39
|
fetchManifest: () => Promise<AppManifest[]>;
|
|
37
40
|
};
|
|
38
41
|
export declare type PlatformSignedTransaction = SignedOperation;
|
|
42
|
+
export declare type ListPlatformAccount = (filters?: AccountFilters) => PlatformAccount[];
|
|
43
|
+
export declare type ListPlatformCurrency = (filters?: CurrencyFilters) => PlatformCurrency[];
|
|
44
|
+
export declare type PlatformSupportedCurrency = CryptoCurrency | TokenCurrency;
|
|
39
45
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,QAAQ,IAAI,gBAAgB,E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CAAC;QACrC,WAAW,EAAE,kBAAkB,CAAC;KACjC,CAAC;IACF,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,aAAa,EAAE,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAC7C,CAAC;AAEF,oBAAY,yBAAyB,GAAG,eAAe,CAAC;AAExD,oBAAY,mBAAmB,GAAG,CAChC,OAAO,CAAC,EAAE,cAAc,KACrB,eAAe,EAAE,CAAC;AAEvB,oBAAY,oBAAoB,GAAG,CACjC,OAAO,CAAC,EAAE,eAAe,KACtB,gBAAgB,EAAE,CAAC;AAExB,oBAAY,yBAAyB,GAAG,cAAc,GAAG,aAAa,CAAC"}
|
package/lib/platform/types.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
2
13
|
exports.__esModule = true;
|
|
14
|
+
exports.PlatformTokenStandard = exports.PlatformCurrencyType = void 0;
|
|
15
|
+
var live_app_sdk_1 = require("@ledgerhq/live-app-sdk");
|
|
16
|
+
__createBinding(exports, live_app_sdk_1, "CurrencyType", "PlatformCurrencyType");
|
|
17
|
+
__createBinding(exports, live_app_sdk_1, "TokenStandard", "PlatformTokenStandard");
|
|
3
18
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,uDAGgC;AAF9B,iFAAoC;AACpC,mFAAsC"}
|
|
@@ -3,6 +3,6 @@ exports.__esModule = true;
|
|
|
3
3
|
require("../__tests__/test-helpers/setup");
|
|
4
4
|
var version_1 = require("./version");
|
|
5
5
|
test("version is defined by setup", function () {
|
|
6
|
-
expect((0, version_1.getPlatformVersion)()).toBe("0.0
|
|
6
|
+
expect((0, version_1.getPlatformVersion)()).toBe("1.0.0");
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=version.test.js.map
|
|
@@ -47,8 +47,6 @@ var index_1 = require("./index");
|
|
|
47
47
|
var currencies_1 = require("../currencies");
|
|
48
48
|
var account_1 = require("../account");
|
|
49
49
|
var env_1 = require("../env");
|
|
50
|
-
var version_1 = require("../platform/version");
|
|
51
|
-
(0, version_1.setPlatformVersion)("0.0.1");
|
|
52
50
|
describe("walletconnect", function () {
|
|
53
51
|
var account = {
|
|
54
52
|
type: "Account",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletconnect.test.js","sourceRoot":"","sources":["../../src/walletconnect/walletconnect.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyC;AACzC,6CAAyC;AACzC,gDAA0B;AAC1B,oCAA6C;AAC7C,iCAA2C;AAE3C,4CAA8E;AAE9E,sCAA+C;AAC/C,8BAAgC;
|
|
1
|
+
{"version":3,"file":"walletconnect.test.js","sourceRoot":"","sources":["../../src/walletconnect/walletconnect.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyC;AACzC,6CAAyC;AACzC,gDA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AAE,WAAW;wBACjB,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,aAAa;qBACpB,CAAC,CAAC;;;;SACJ,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"name": "@ledgerhq/live-common",
|
|
6
6
|
"description": "Common ground for the Ledger Live apps",
|
|
7
|
-
"version": "25.0.0-next.
|
|
7
|
+
"version": "25.0.0-next.5",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -108,13 +108,13 @@
|
|
|
108
108
|
"@ethereumjs/tx": "^3.5.0",
|
|
109
109
|
"@hashgraph/sdk": "^2.10.1",
|
|
110
110
|
"@ledgerhq/compressjs": "github:LedgerHQ/compressjs#d9e8e4d994923e0ea76a32b97289bcccfe71b82e",
|
|
111
|
-
"@ledgerhq/cryptoassets": "^6.30.0-next.
|
|
111
|
+
"@ledgerhq/cryptoassets": "^6.30.0-next.2",
|
|
112
112
|
"@ledgerhq/devices": "^7.0.0-next.0",
|
|
113
113
|
"@ledgerhq/errors": "^6.10.1-next.0",
|
|
114
114
|
"@ledgerhq/hw-app-algorand": "^6.27.2-next.0",
|
|
115
115
|
"@ledgerhq/hw-app-btc": "^8.0.0-next.0",
|
|
116
116
|
"@ledgerhq/hw-app-cosmos": "^6.27.2-next.0",
|
|
117
|
-
"@ledgerhq/hw-app-eth": "^6.29.2-next.
|
|
117
|
+
"@ledgerhq/hw-app-eth": "^6.29.2-next.2",
|
|
118
118
|
"@ledgerhq/hw-app-polkadot": "^6.27.2-next.0",
|
|
119
119
|
"@ledgerhq/hw-app-solana": "^6.27.2-next.0",
|
|
120
120
|
"@ledgerhq/hw-app-str": "^6.27.2-next.0",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"@ledgerhq/hw-transport-mocker": "^6.27.2-next.0",
|
|
126
126
|
"@ledgerhq/hw-transport-node-speculos": "^6.27.2-next.0",
|
|
127
127
|
"@ledgerhq/json-bignumber": "^1.1.0",
|
|
128
|
-
"@ledgerhq/live-app-sdk": "^0.
|
|
128
|
+
"@ledgerhq/live-app-sdk": "^0.7.0",
|
|
129
129
|
"@ledgerhq/logs": "^6.10.0",
|
|
130
130
|
"@polkadot/types": "8.5.1",
|
|
131
131
|
"@polkadot/types-known": "8.5.1",
|
|
@@ -184,6 +184,7 @@
|
|
|
184
184
|
"leb128": "^0.0.5",
|
|
185
185
|
"lodash": "^4.17.21",
|
|
186
186
|
"lru-cache": "5.1.1",
|
|
187
|
+
"minimatch": "^5.1.0",
|
|
187
188
|
"numeral": "^2.0.6",
|
|
188
189
|
"object-hash": "^2.2.0",
|
|
189
190
|
"performance-now": "^2.1.0",
|
|
@@ -7,7 +7,7 @@ import { setSupportedCurrencies } from "../../currencies";
|
|
|
7
7
|
import { AccountRaw } from "../../types";
|
|
8
8
|
import { setPlatformVersion } from "../../platform/version";
|
|
9
9
|
|
|
10
|
-
setPlatformVersion("0.0
|
|
10
|
+
setPlatformVersion("1.0.0");
|
|
11
11
|
|
|
12
12
|
setSupportedCurrencies(["ethereum"]);
|
|
13
13
|
describe("importAccountsMakeItems", () => {
|
package/src/account/helpers.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
SubAccount,
|
|
9
9
|
TokenCurrency,
|
|
10
10
|
TokenAccount,
|
|
11
|
+
ChildAccount,
|
|
11
12
|
} from "../types";
|
|
12
13
|
import { getEnv } from "../env";
|
|
13
14
|
import { encodeTokenAccountId } from "./accountId";
|
|
@@ -26,6 +27,7 @@ export const getMainAccount = (
|
|
|
26
27
|
invariant(mainAccount, "an account is expected");
|
|
27
28
|
return mainAccount as Account;
|
|
28
29
|
};
|
|
30
|
+
|
|
29
31
|
export const getAccountCurrency = (account: AccountLike) => {
|
|
30
32
|
switch (account.type) {
|
|
31
33
|
case "Account":
|
|
@@ -39,6 +41,7 @@ export const getAccountCurrency = (account: AccountLike) => {
|
|
|
39
41
|
throw new Error("invalid account.type=" + (account as AccountLike).type);
|
|
40
42
|
}
|
|
41
43
|
};
|
|
44
|
+
|
|
42
45
|
export const getAccountUnit = (account: AccountLike): Unit => {
|
|
43
46
|
switch (account.type) {
|
|
44
47
|
case "Account":
|
|
@@ -54,6 +57,7 @@ export const getAccountUnit = (account: AccountLike): Unit => {
|
|
|
54
57
|
throw new Error("invalid account.type=" + (account as AccountLike).type);
|
|
55
58
|
}
|
|
56
59
|
};
|
|
60
|
+
|
|
57
61
|
export const getAccountName = (account: AccountLike): string => {
|
|
58
62
|
switch (account.type) {
|
|
59
63
|
case "Account":
|
|
@@ -67,6 +71,7 @@ export const getAccountName = (account: AccountLike): string => {
|
|
|
67
71
|
throw new Error("invalid account.type=" + (account as AccountLike).type);
|
|
68
72
|
}
|
|
69
73
|
};
|
|
74
|
+
|
|
70
75
|
export const getAccountSpendableBalance = (account: AccountLike): BigNumber => {
|
|
71
76
|
switch (account.type) {
|
|
72
77
|
case "Account":
|
|
@@ -80,6 +85,7 @@ export const getAccountSpendableBalance = (account: AccountLike): BigNumber => {
|
|
|
80
85
|
throw new Error("invalid account.type=" + (account as AccountLike).type);
|
|
81
86
|
}
|
|
82
87
|
};
|
|
88
|
+
|
|
83
89
|
export const isAccountEmpty = (a: AccountLike): boolean => {
|
|
84
90
|
if (
|
|
85
91
|
a.type === "Account" &&
|
|
@@ -95,6 +101,7 @@ export const isAccountEmpty = (a: AccountLike): boolean => {
|
|
|
95
101
|
a.type === "Account" && a.subAccounts && a.subAccounts.length;
|
|
96
102
|
return a.operationsCount === 0 && a.balance.isZero() && !hasSubAccounts;
|
|
97
103
|
};
|
|
104
|
+
|
|
98
105
|
export function areAllOperationsLoaded(account: AccountLike): boolean {
|
|
99
106
|
if (account.operationsCount !== account.operations.length) {
|
|
100
107
|
return false;
|
|
@@ -106,8 +113,10 @@ export function areAllOperationsLoaded(account: AccountLike): boolean {
|
|
|
106
113
|
|
|
107
114
|
return true;
|
|
108
115
|
}
|
|
116
|
+
|
|
109
117
|
export const isAccountBalanceSignificant = (a: AccountLike): boolean =>
|
|
110
118
|
a.balance.gt(100);
|
|
119
|
+
|
|
111
120
|
// in future, could be a per currency thing
|
|
112
121
|
// clear account to a bare minimal version that can be restored via sync
|
|
113
122
|
// will preserve the balance to avoid user panic
|
|
@@ -153,12 +162,14 @@ export function clearAccount<T extends AccountLike>(account: T): T {
|
|
|
153
162
|
delete copy.nfts;
|
|
154
163
|
return copy as T;
|
|
155
164
|
}
|
|
165
|
+
|
|
156
166
|
export function findSubAccountById(
|
|
157
167
|
account: Account,
|
|
158
168
|
id: string
|
|
159
169
|
): SubAccount | null | undefined {
|
|
160
170
|
return (account.subAccounts || []).find((a) => a.id === id);
|
|
161
171
|
}
|
|
172
|
+
|
|
162
173
|
// get the token accounts of an account, ignoring those that are zero IF user don't want them
|
|
163
174
|
export function listSubAccounts(account: Account): SubAccount[] {
|
|
164
175
|
const accounts = account.subAccounts || [];
|
|
@@ -169,9 +180,11 @@ export function listSubAccounts(account: Account): SubAccount[] {
|
|
|
169
180
|
|
|
170
181
|
return accounts;
|
|
171
182
|
}
|
|
183
|
+
|
|
172
184
|
export type FlattenAccountsOptions = {
|
|
173
185
|
enforceHideEmptySubAccounts?: boolean;
|
|
174
186
|
};
|
|
187
|
+
|
|
175
188
|
export function flattenAccounts(
|
|
176
189
|
topAccounts: AccountLikeArray,
|
|
177
190
|
o: FlattenAccountsOptions = {}
|
|
@@ -195,16 +208,19 @@ export function flattenAccounts(
|
|
|
195
208
|
|
|
196
209
|
return accounts;
|
|
197
210
|
}
|
|
211
|
+
|
|
198
212
|
export const shortAddressPreview = (addr: string, target = 20): string => {
|
|
199
213
|
const slice = Math.floor((target - 3) / 2);
|
|
200
214
|
return addr.length < target - 3
|
|
201
215
|
? addr
|
|
202
216
|
: `${addr.slice(0, slice)}...${addr.slice(addr.length - slice)}`;
|
|
203
217
|
};
|
|
218
|
+
|
|
204
219
|
export const isAccountBalanceUnconfirmed = (account: AccountLike): boolean =>
|
|
205
220
|
account.pendingOperations.some(
|
|
206
221
|
(op) => !account.operations.find((o) => o.hash === op.hash)
|
|
207
222
|
) || account.operations.some((op) => !op.blockHeight);
|
|
223
|
+
|
|
208
224
|
export const isUpToDateAccount = (account: Account | null | undefined) => {
|
|
209
225
|
if (!account) return true;
|
|
210
226
|
const { lastSyncDate, currency } = account;
|
|
@@ -216,6 +232,7 @@ export const isUpToDateAccount = (account: Account | null | undefined) => {
|
|
|
216
232
|
blockAvgTime * 1000 + getEnv("SYNC_OUTDATED_CONSIDERED_DELAY");
|
|
217
233
|
return !outdated;
|
|
218
234
|
};
|
|
235
|
+
|
|
219
236
|
export const getVotesCount = (
|
|
220
237
|
account: AccountLike,
|
|
221
238
|
parentAccount?: Account | null | undefined
|
|
@@ -233,6 +250,7 @@ export const getVotesCount = (
|
|
|
233
250
|
|
|
234
251
|
return 0;
|
|
235
252
|
};
|
|
253
|
+
|
|
236
254
|
export const makeEmptyTokenAccount = (
|
|
237
255
|
account: Account,
|
|
238
256
|
token: TokenCurrency
|
|
@@ -348,3 +366,36 @@ export const findTokenAccountByCurrency = (
|
|
|
348
366
|
|
|
349
367
|
return null; // else return nothing
|
|
350
368
|
};
|
|
369
|
+
|
|
370
|
+
export function isTokenAccount(account: AccountLike): account is TokenAccount {
|
|
371
|
+
return account.type === "TokenAccount";
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function isChildAccount(account: AccountLike): account is ChildAccount {
|
|
375
|
+
return account.type === "ChildAccount";
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function isSubAccount(account: AccountLike): account is SubAccount {
|
|
379
|
+
return isTokenAccount(account) || isChildAccount(account);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function getParentAccount(
|
|
383
|
+
account: AccountLike,
|
|
384
|
+
accounts: AccountLike[]
|
|
385
|
+
): Account {
|
|
386
|
+
switch (account.type) {
|
|
387
|
+
case "Account":
|
|
388
|
+
return account;
|
|
389
|
+
case "TokenAccount":
|
|
390
|
+
case "ChildAccount": {
|
|
391
|
+
const parentAccount = accounts.find((a) => a.id == account.parentId);
|
|
392
|
+
if (!parentAccount) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
"No 'parentAccount' account provided for token account"
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return parentAccount as Account;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
@@ -5,7 +5,7 @@ import { sortFilterApps } from "./filtering";
|
|
|
5
5
|
import { setSupportedCurrencies } from "../currencies/support";
|
|
6
6
|
import { setPlatformVersion } from "../platform/version";
|
|
7
7
|
|
|
8
|
-
setPlatformVersion("0.0
|
|
8
|
+
setPlatformVersion("1.0.0");
|
|
9
9
|
|
|
10
10
|
type FilteringScenario = {
|
|
11
11
|
name: string;
|
package/src/apps/support.ts
CHANGED
|
@@ -6428,6 +6428,107 @@ Array [
|
|
|
6428
6428
|
"algorand/asa/137594422",
|
|
6429
6429
|
"elrond/esdt/555344432d633736663166",
|
|
6430
6430
|
"elrond/esdt/524944452d376431386539",
|
|
6431
|
+
"cardano_testnet/native/581684861359b6d4d00594073a9aa4223c6fc24d24da05e1b34fb865544553545f544f4b454e",
|
|
6432
|
+
"cardano/native/a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",
|
|
6433
|
+
"cardano/native/af2e27f580f7f08e93190a81f72462f153026d06450924726645891b44524950",
|
|
6434
|
+
"cardano/native/9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",
|
|
6435
|
+
"cardano/native/4247d5091db82330100904963ab8d0850976c80d3f1b927e052e07bd546f6b68756e",
|
|
6436
|
+
"cardano/native/d894897411707efa755a76deb66d26dfd50593f2e70863e1661e98a07370616365636f696e73",
|
|
6437
|
+
"cardano/native/29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",
|
|
6438
|
+
"cardano/native/afc910d7a306d20c12903979d4935ae4307241d03245743548e767834153484942",
|
|
6439
|
+
"cardano/native/5ad8deb64bfec21ad2d96e1270b5873d0c4d0f231b928b4c39eb243561646f736961",
|
|
6440
|
+
"cardano/native/8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552",
|
|
6441
|
+
"cardano/native/d030b626219d81673bd32932d2245e0c71ae5193281f971022b23a78436172646f67656f",
|
|
6442
|
+
"cardano/native/a4da8764a57e66a0085b5bfcde96c89b798d92ee83a75f59237e375b46495245",
|
|
6443
|
+
"cardano/native/2afb448ef716bfbed1dcb676102194c3009bee5399e93b90def9db6a4249534f4e",
|
|
6444
|
+
"cardano/native/f28f457472e539dc75e1598a2beddf49ce5a717998c708f05f5de61044454653",
|
|
6445
|
+
"cardano/native/544571c086d0e5c5022aca9717dd0f438e21190abb48f37b3ae129f047524f57",
|
|
6446
|
+
"cardano/native/1a71dc14baa0b4fcfb34464adc6656d0e562571e2ac1bc990c9ce5f6574f4c46",
|
|
6447
|
+
"cardano/native/884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",
|
|
6448
|
+
"cardano/native/7f376e3d1cf52e6c4350a1a91c8f8d0f0b63baedd443999ebe8fe57a424f52475a",
|
|
6449
|
+
"cardano/native/987c1f90efe1c95957509b460e0e4f6d6b3f7025a7aca99cd29090374d595448",
|
|
6450
|
+
"cardano/native/6954264b15bc92d6d592febeac84f14645e1ed46ca5ebb9acdb5c15f5354524950",
|
|
6451
|
+
"cardano/native/6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",
|
|
6452
|
+
"cardano/native/b0446f1c9105f0cc5bb6bd092f5c3e523e13f8a999b31c870298fa4051554944",
|
|
6453
|
+
"cardano/native/025146866af908340247fe4e9672d5ac7059f1e8534696b5f920c9e66362544843",
|
|
6454
|
+
"cardano/native/c68307e7ca850513507f1498862a57c7f4fae7ba8e84b8bc074093a944494253",
|
|
6455
|
+
"cardano/native/1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",
|
|
6456
|
+
"cardano/native/1f4b1b277c9c001c1522727506a2cfb401a0d0ade069b0241f16f07d4849",
|
|
6457
|
+
"cardano/native/8d0ae3c5b13b47907b16511a540d47436d12dcc96453c0f59089b45142524f4f4d",
|
|
6458
|
+
"cardano/native/d3558649b7874a1a596378515f9b80da63e73f324439ea113d34c9bb42454147",
|
|
6459
|
+
"cardano/native/5029eeccd52fef299509d509a8318fd7930c3dffcce1f9f39ff11ef9464743",
|
|
6460
|
+
"cardano/native/88691a70bb0fe49cf9124b4f78553c36c09fa6264844e2b2941191734575736b6f",
|
|
6461
|
+
"cardano/native/cfee97ff8359f07a0a395a72b424bc6e030503390d864b86d4e0ecf84b41495a454e",
|
|
6462
|
+
"cardano/native/e14fe3ab348f9a6198359481472601f4557b9f86984f40a186a3b1e8434845525259",
|
|
6463
|
+
"cardano/native/e98165a25cd0320b25f22d686268e58e66f855b6d85974947ccd708d414441464f58",
|
|
6464
|
+
"cardano/native/da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",
|
|
6465
|
+
"cardano/native/b34b3ea80060ace9427bda98690a73d33840e27aaa8d6edb7f0c757a634e455441",
|
|
6466
|
+
"cardano/native/300ec0d82a79acdc0616fdc0ef615e7deeddb03275e834685e9ee8a65854",
|
|
6467
|
+
"cardano/native/682fe60c9918842b3323c43b5144bc3d52a23bd2fb81345560d73f634e45574d",
|
|
6468
|
+
"cardano/native/d3a034e403b98cbdb0adbc8a3144d7779330916e190d387815bb85c650555252",
|
|
6469
|
+
"cardano/native/007394e3117755fbb0558b93c54ce3bc6c85770920044ade143dc742505443",
|
|
6470
|
+
"cardano/native/a3914cb7a564d010c7b67774ac8720a8ece3a758279b51d8a1c05cc55745444e4553444159",
|
|
6471
|
+
"cardano/native/d01794c4604f3c0e544c537bb1f4268c0e81f45880c00c09ebe4b4a74d595354",
|
|
6472
|
+
"cardano/native/29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e74",
|
|
6473
|
+
"cardano/native/8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",
|
|
6474
|
+
"cardano/native/a89568bb399d0cdc38367e47831c95186f5c79e58174e08a182323964554424643546f6b656e",
|
|
6475
|
+
"cardano/native/c88bbd1848db5ea665b1fffbefba86e8dcd723b5085348e8a8d2260f44414e41",
|
|
6476
|
+
"cardano/native/47959e79846b8bdcacb91f586408d97e2dff44f31a04f03902cba8185357454554",
|
|
6477
|
+
"cardano/native/0171c997b8853fde686763d93b36ab8e04ce947bb6aa09a9ee5c4401544f4b454e",
|
|
6478
|
+
"cardano/native/d5dec6074942b36b50975294fd801f7f28c907476b1ecc1b57c916ed524154",
|
|
6479
|
+
"cardano/native/8fef2d34078659493ce161a6c7fba4b56afefa8535296a5743f6958741414441",
|
|
6480
|
+
"cardano/native/0c78f619e54a5d00e143f66181a2c500d0c394b38a10e86cd1a23c5f41444158",
|
|
6481
|
+
"cardano/native/585cfcbdd0786e961187999e5d5d36b38d1ebc1c4112a0a95a8bd477424c43",
|
|
6482
|
+
"cardano/native/0c442180dd6163682d8e03b271caefb4944a24412bdd07adafb04ccb50494e41434f4c414441",
|
|
6483
|
+
"cardano/native/f4d97191f857096b441a410c036f63d6697dde0c71d2755dd664e3024d4b41",
|
|
6484
|
+
"cardano/native/804f5544c1962a40546827cab750a88404dc7108c0f588b72964754f56594649",
|
|
6485
|
+
"cardano/native/ae2a0aa5a24b27d9868c4a73b7c08077ac21baade5eca0fa467a2bbd58524159",
|
|
6486
|
+
"cardano/native/0fd9819a9d7fb414880883f43a42d33458f12bc5f9841cec6457dc155669527553",
|
|
6487
|
+
"cardano/native/df0172804f8418afc4e5b0a15b8fc78bdc3ca6d179405a7cd194f3b4464c49434b",
|
|
6488
|
+
"cardano/native/20cd68533b47565f3c61efb39c30fdace9963bfa4c0060b613448e3c50524f584945",
|
|
6489
|
+
"cardano/native/e9c28a71273f825b13f38244ccf1fea97c4025813610d01a7c5d681f436861726c7a20546f6b656e",
|
|
6490
|
+
"cardano/native/6787a47e9f73efe4002d763337140da27afa8eb9a39413d2c39d4286524144546f6b656e73",
|
|
6491
|
+
"cardano/native/db30c7905f598ed0154de14f970de0f61f0cb3943ed82c891968480a434c4150",
|
|
6492
|
+
"cardano/native/aea1ceb3625680e2f7a31ea1a64c9c430c34d8588bf4f8e3c7f9b1dd476f74636869",
|
|
6493
|
+
"cardano/native/14a3455f71c435a04ea1fdb50a3ef4c1cab0e79fb1565627ac66a57552415645",
|
|
6494
|
+
"cardano/native/2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",
|
|
6495
|
+
"cardano/native/4c17b7009448a33d1834b0946ea752ecd0cc61c7bb25cd9ff18cff58426c6f6f6d",
|
|
6496
|
+
"cardano/native/94cbb4fcbcaa2975779f273b263eb3b5f24a9951e446d6dc4c13586452455655",
|
|
6497
|
+
"cardano/native/63766427b4499dd678cb8b715dec3265dd292279ce7779447e3651e54b4f5a",
|
|
6498
|
+
"cardano/native/885742cd7e0dad321622b5d3ad186797bd50c44cbde8b48be1583fbd534b554c4c",
|
|
6499
|
+
"cardano/native/f7c777fdd4531cf1c477551360e45b9684073c05c2fa61334f8f9add5665726974726565546f6b656e",
|
|
6500
|
+
"cardano/native/aa2797739e4f4a1efd5346998febff59909e425b5fddb1b0ec4a24f84c6f6f6b7a",
|
|
6501
|
+
"cardano/native/dca54ecf37b0e3af2fdfd336e1d21fadcc45b3261b0f73a095631dfe444f4558",
|
|
6502
|
+
"cardano/native/25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",
|
|
6503
|
+
"cardano/native/57684adcb032c8dbc40179841bed987d8dee7472617a0e5c25ef414059617953776170",
|
|
6504
|
+
"cardano/native/c9f955eeffa84e42363b4992281d32dd2f9239153d6c66420a9acc154c4f47",
|
|
6505
|
+
"cardano/native/240fb00eff73acc51c09e81dae6628c4bedb9964151d45e3faed874f434c4157",
|
|
6506
|
+
"cardano/native/2aa9c1557fcf8e7caa049fa0911a8724a1cdaf8037fe0b431c6ac66450494759546f6b656e",
|
|
6507
|
+
"cardano/native/2c96f49b6e6e32ae69a182e85b74db4edfc9539496a13ab76d1258fa434e54",
|
|
6508
|
+
"cardano/native/b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d",
|
|
6509
|
+
"cardano/native/208a2ca888886921513cb777bb832a8dc685c04de990480151f1215053484942414441",
|
|
6510
|
+
"cardano/native/c4c00fbd8fa227442a5e7cdecde33b24588494d05a2c50fda8938c6d4b49445a",
|
|
6511
|
+
"cardano/native/dbc31b04d90b37332813cb4cee3e8f79994643d899a5366797e745ee465544",
|
|
6512
|
+
"cardano/native/d0af056c509b6b1133cd83a750b7245e561169281fde3df1cb6e2d96506f6f6c5065656b436f696e",
|
|
6513
|
+
"cardano/native/8f52f6a88acf6127bc4758a16b6047afc4da7887feae121ec217b75a534e4f57",
|
|
6514
|
+
"cardano/native/2441ab3351c3b80213a98f4e09ddcf7dabe4879c3c94cc4e7205cb6346495245",
|
|
6515
|
+
"cardano/native/c7dcfa416c127f630b263c7e0fe0564430cfa9c56bba43e1a37c6915474f4b4559",
|
|
6516
|
+
"cardano/native/97747aa3c33fdfe4b5faa7bb8b4534932c6d980cb13c14c5a547e7ca70757272414441",
|
|
6517
|
+
"cardano/native/ccb3577601d6cf0e021288871112926338bee685c6c37eeadf6dddd943617264616e6961466f756e646572426c7565",
|
|
6518
|
+
"cardano/native/ccb3577601d6cf0e021288871112926338bee685c6c37eeadf6dddd943617264616e6961466f756e646572526564",
|
|
6519
|
+
"cardano/native/1f4b1b277c9c001c1522727506a2cfb401a0d0ade069b0241f16f07d484953",
|
|
6520
|
+
"cardano/native/ccb3577601d6cf0e021288871112926338bee685c6c37eeadf6dddd943617264616e6961466f756e646572477265656e",
|
|
6521
|
+
"cardano/native/b4273f1d8d0021d188784c3d72dc514f602b7ab8cfb87e3134550c42446f6765414441",
|
|
6522
|
+
"cardano/native/133fac9e153194428eb0919be39837b42b9e977fc7298f3ff1b76ef95055444759",
|
|
6523
|
+
"cardano/native/f555c46bad0731d080c9381d7fff6f82839946a66bd070d185e1ea2f42444f4745",
|
|
6524
|
+
"cardano/native/1dd1a7dde0e1e82761325ee5f4719d0d4b7c24dfba77d9bee01eed4b4d454f57",
|
|
6525
|
+
"cardano/native/a00fdf4fb9ab6c8c2bd1533a2f14855edf12aed5ecbf96d4b5f5b9394334",
|
|
6526
|
+
"cardano/native/f4364875e75320d405ceadebdf0db63fadaff55c72d4ff6b82f0676a434152474f",
|
|
6527
|
+
"cardano/native/59e31d17e4d212ea35df6088e0395455c40f5ad463d161497a89c567426162795365616c",
|
|
6528
|
+
"cardano/native/b0af30edf2c7f11465853821137e0a6ebc395cab71ee39c24127ffb44e465443",
|
|
6529
|
+
"cardano/native/6c8642400e8437f737eb86df0fc8a8437c760f48592b1ba8f5767e81456d706f7761",
|
|
6530
|
+
"cardano/native/ca942cb8bb5d1ef750766ded355f320880539111f10efa2b1a478ff9524147",
|
|
6531
|
+
"cardano/native/0c92aabef5a8f91a36470d0762806c165c0d04aa992541e25d55486a424347",
|
|
6431
6532
|
"stellar/asset/USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
6432
6533
|
]
|
|
6433
6534
|
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "../__tests__/test-helpers/setup";
|
|
2
|
+
import { isPlatformSupportedCurrency } from "../platform/helpers";
|
|
3
|
+
import { isCryptoCurrency, listCurrencies } from "./helpers";
|
|
4
|
+
|
|
5
|
+
describe("Currencies helpers", () => {
|
|
6
|
+
test("listCurrencies without includeTokens", () => {
|
|
7
|
+
const currencies = listCurrencies(false);
|
|
8
|
+
|
|
9
|
+
currencies.forEach((currency) => {
|
|
10
|
+
expect(isCryptoCurrency(currency)).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("listCurrencies with includeTokens", () => {
|
|
15
|
+
const currencies = listCurrencies(true);
|
|
16
|
+
|
|
17
|
+
currencies.forEach((currency) => {
|
|
18
|
+
expect(isPlatformSupportedCurrency(currency)).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { makeRe } from "minimatch";
|
|
2
|
+
import { CryptoCurrency, Currency, TokenCurrency } from "../types";
|
|
3
|
+
import { listTokens, listSupportedCurrencies } from "../currencies";
|
|
4
|
+
import { PlatformSupportedCurrency } from "../platform/types";
|
|
5
|
+
import { CurrencyFilters } from "../platform/filters";
|
|
6
|
+
import { isPlatformSupportedCurrency } from "../platform/helpers";
|
|
7
|
+
|
|
8
|
+
export function isCryptoCurrency(
|
|
9
|
+
currency: Currency
|
|
10
|
+
): currency is CryptoCurrency {
|
|
11
|
+
return currency.type === "CryptoCurrency";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isTokenCurrency(currency: Currency): currency is TokenCurrency {
|
|
15
|
+
return currency.type === "TokenCurrency";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function listCurrencies(includeTokens: boolean): Currency[] {
|
|
19
|
+
const currencies = listSupportedCurrencies();
|
|
20
|
+
|
|
21
|
+
if (!includeTokens) {
|
|
22
|
+
return currencies;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const allTokens = listTokens().filter(
|
|
26
|
+
({ tokenType }) => tokenType === "erc20" || tokenType === "bep20"
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return [...currencies, ...allTokens];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function filterCurrencies(
|
|
33
|
+
currencies: PlatformSupportedCurrency[],
|
|
34
|
+
filters: CurrencyFilters
|
|
35
|
+
): Currency[] {
|
|
36
|
+
const filterCurrencyRegexes = filters.currencies
|
|
37
|
+
? filters.currencies.map((filter) => makeRe(filter))
|
|
38
|
+
: null;
|
|
39
|
+
|
|
40
|
+
return currencies.filter((currency) => {
|
|
41
|
+
if (!filters.includeTokens && isTokenCurrency(currency)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
filterCurrencyRegexes &&
|
|
47
|
+
filterCurrencyRegexes.length &&
|
|
48
|
+
!filterCurrencyRegexes.some((regex) => currency.id.match(regex))
|
|
49
|
+
) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function listAndFilterCurrencies({
|
|
58
|
+
includeTokens = false,
|
|
59
|
+
currencies,
|
|
60
|
+
}: CurrencyFilters): Currency[] {
|
|
61
|
+
const allCurrencies = listCurrencies(includeTokens).filter(
|
|
62
|
+
isPlatformSupportedCurrency
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return filterCurrencies(allCurrencies, {
|
|
66
|
+
includeTokens,
|
|
67
|
+
currencies,
|
|
68
|
+
});
|
|
69
|
+
}
|
package/src/currencies/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
getAbandonSeedAddress,
|
|
34
34
|
} from "@ledgerhq/cryptoassets";
|
|
35
35
|
export * from "./support";
|
|
36
|
+
export * from "./helpers";
|
|
36
37
|
import { parseCurrencyUnit } from "./parseCurrencyUnit";
|
|
37
38
|
import { chopCurrencyUnitDecimals } from "./chopCurrencyUnitDecimals";
|
|
38
39
|
import {
|