@ledgerhq/live-common 25.0.0-next.2 → 25.0.0-next.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/__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/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/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 +3 -2
- 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/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/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
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/platform/react.ts"],"names":[],"mappings":";;;AAAA,+BAA6C;AAE7C,2CAGsB;AACtB,qCAKmB;AACnB,qCAAwD;AAOxD,sCAA8C;AAC9C,4CAA+C;AAE/C,SAAgB,cAAc,CAC5B,QAAqB,EACrB,MAA6D,EAC7D,MAA8B;IAE9B,OAAO,IAAA,eAAO,EAAC;QACb,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE7C,IAAI,MAAM,EAAE;YACV,KAAK,IAAM,GAAG,IAAI,MAAM,EAAE;gBACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;oBACrD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;iBACxC;aACF;SACF;QAED,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3D,GAAG,CAAC,YAAY,CAAC,GAAG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C1B,MAAM,CAAC,qCAA2B,CAAC;aACnC,GAAG,CAAC,uCAA0B,CAAC;IAFlC,CAEkC,EACpC,CAAC,aAAa,CAAC,CAChB,CAAC;AACJ,CAAC;AAVD,sDAUC;AAED,SAAgB,yBAAyB;IACvC,IAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,IAAA,mBAAW,EAChB,UAAC,OAAyB;QACxB,OAAO,IAAA,kCAAwB,EAAC,UAAU,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;AACJ,CAAC;AATD,8DASC"}
|
package/lib/platform/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
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,EAC7B,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,OAAO,IAAI,eAAe,EAC1B,QAAQ,IAAI,gBAAgB,EAC5B,IAAI,IAAI,YAAY,EACpB,WAAW,IAAI,mBAAmB,EAClC,cAAc,IAAI,sBAAsB,EACxC,kBAAkB,IAAI,0BAA0B,GACjD,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,IAAI,oBAAoB,EACpC,aAAa,IAAI,qBAAqB,GACvC,MAAM,wBAAwB,CAAC;AAEhC,oBAAY,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CAAC;AAEF,oBAAY,WAAW,GACnB,SAAS,GACT,QAAQ,GACR,KAAK,CAAC;AAEV,oBAAY,SAAS,GAAG,QAAQ,GAAG,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE,oBAAY,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC3B,OAAO,EAAE;QACP,gBAAgB,EAAE,kBAAkB,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,gDAA0B;AAC1B,oCAA6C;AAC7C,iCAA2C;AAE3C,4CAA8E;AAE9E,sCAA+C;AAC/C,8BAAgC;AAEhC,QAAQ,CAAC,eAAe,EAAE;IACxB,IAAM,OAAO,GAAY;QACvB,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,2DAA2D;QAC/D,cAAc,EAAE,EAAE;QAClB,gBAAgB,EAAE,gBAAgB;QAClC,QAAQ,EAAE,IAAA,kCAAqB,EAAC,UAAU,CAAC;QAC3C,cAAc,EAAE,EAAE;QAClB,KAAK,EAAE,CAAC;QACR,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,EAAE;QAClB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC;QACzB,gBAAgB,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC;QAClC,YAAY,EAAE,IAAI,IAAI,EAAE;QACxB,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,IAAA,kCAAqB,EAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,eAAe,EAAE,CAAC;QAClB,UAAU,EAAE,EAAE;QACd,iBAAiB,EAAE,EAAE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E,EAAE,CAAC;qBACnD,CAAC,CAAC;oBACW,qBAAM,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,EAAA;;oBAAnE,WAAW,GAAG,SAAqD,CAAC;oBACpE,OAAO,WAAW,CAAC,WAAW,CAAC;oBAC/B,OAAO,WAAW,CAAC,QAAQ,CAAC;oBAC5B,KAAA,MAAM,CAAA;oBACJ,qBAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE;4BAC9B,EAAE,EAAE,kBAAkB;4BACtB,MAAM,EAAE,qBAAqB;4BAC7B,MAAM,EAAE,CAAC,GAAG,CAAC;yBACd,CAAC,EAAA;;oBALJ,kBACE,SAIE,EACH,CAAC,aAAa,CAAC;wBACd,IAAI,EAAE,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.3",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -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;
|
|
@@ -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 {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { listAndFilterCurrencies } from "./helpers";
|
|
3
|
+
import { Currency } from "../types";
|
|
4
|
+
import { CurrencyFilters } from "../platform/filters";
|
|
5
|
+
|
|
6
|
+
export function useFilteredCurrencies({
|
|
7
|
+
includeTokens,
|
|
8
|
+
currencies,
|
|
9
|
+
}: CurrencyFilters): Currency[] {
|
|
10
|
+
return useMemo(() => {
|
|
11
|
+
return listAndFilterCurrencies({
|
|
12
|
+
includeTokens,
|
|
13
|
+
currencies,
|
|
14
|
+
});
|
|
15
|
+
}, [currencies, includeTokens]);
|
|
16
|
+
}
|
|
@@ -10,7 +10,7 @@ const manifest: AppManifest[] = [
|
|
|
10
10
|
supportUrl: "https://paraswap.io",
|
|
11
11
|
icon: "https://cdn.live.ledger.com/icons/platform/paraswap.png",
|
|
12
12
|
platform: "all",
|
|
13
|
-
apiVersion: "0.0.1",
|
|
13
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
14
14
|
manifestVersion: "1",
|
|
15
15
|
branch: "stable",
|
|
16
16
|
params: ["accountId"],
|
|
@@ -56,7 +56,7 @@ const manifest: AppManifest[] = [
|
|
|
56
56
|
homepageUrl: "https://lido.fi/",
|
|
57
57
|
icon: "https://cdn.live.ledger.com/icons/platform/lido.png",
|
|
58
58
|
platform: "all",
|
|
59
|
-
apiVersion: "0.0.1",
|
|
59
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
60
60
|
manifestVersion: "1",
|
|
61
61
|
branch: "stable",
|
|
62
62
|
categories: ["staking", "defi"],
|
|
@@ -79,7 +79,7 @@ const manifest: AppManifest[] = [
|
|
|
79
79
|
homepageUrl: "https://www.sendwyre.com/",
|
|
80
80
|
icon: "https://cdn.live.ledger.com/icons/platform/wyre.png",
|
|
81
81
|
platform: "all",
|
|
82
|
-
apiVersion: "0.0.1",
|
|
82
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
83
83
|
manifestVersion: "1",
|
|
84
84
|
branch: "stable",
|
|
85
85
|
categories: ["exchange", "buy"],
|
|
@@ -109,7 +109,7 @@ const manifest: AppManifest[] = [
|
|
|
109
109
|
homepageUrl: "https://zerion.io/",
|
|
110
110
|
icon: "https://cdn.live.ledger.com/icons/platform/zerion.png",
|
|
111
111
|
platform: "all",
|
|
112
|
-
apiVersion: "0.0.1",
|
|
112
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
113
113
|
manifestVersion: "1",
|
|
114
114
|
branch: "stable",
|
|
115
115
|
categories: ["portfolio", "defi"],
|
|
@@ -132,7 +132,7 @@ const manifest: AppManifest[] = [
|
|
|
132
132
|
homepageUrl: "https://rainbow.me",
|
|
133
133
|
icon: "https://cdn.live.ledger.com/icons/platform/rainbow.png",
|
|
134
134
|
platform: "all",
|
|
135
|
-
apiVersion: "0.0.1",
|
|
135
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
136
136
|
manifestVersion: "1",
|
|
137
137
|
branch: "stable",
|
|
138
138
|
categories: ["nft"],
|
|
@@ -155,7 +155,7 @@ const manifest: AppManifest[] = [
|
|
|
155
155
|
homepageUrl: "https://aave.com/",
|
|
156
156
|
icon: "https://cdn.live.ledger.com/icons/platform/aave.png",
|
|
157
157
|
platform: "all",
|
|
158
|
-
apiVersion: "0.0.1",
|
|
158
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
159
159
|
manifestVersion: "1",
|
|
160
160
|
branch: "soon",
|
|
161
161
|
categories: ["lend"],
|
|
@@ -178,7 +178,7 @@ const manifest: AppManifest[] = [
|
|
|
178
178
|
homepageUrl: "https://compound.finance/",
|
|
179
179
|
icon: "https://cdn.live.ledger.com/icons/platform/compound.png",
|
|
180
180
|
platform: "all",
|
|
181
|
-
apiVersion: "0.0.1",
|
|
181
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
182
182
|
manifestVersion: "1",
|
|
183
183
|
branch: "soon",
|
|
184
184
|
categories: ["lend", "compound"],
|
|
@@ -201,7 +201,7 @@ const manifest: AppManifest[] = [
|
|
|
201
201
|
homepageUrl: "https://www.deversifi.com/",
|
|
202
202
|
icon: "https://cdn.live.ledger.com/icons/platform/deversifi.png",
|
|
203
203
|
platform: "all",
|
|
204
|
-
apiVersion: "0.0.1",
|
|
204
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
205
205
|
manifestVersion: "1",
|
|
206
206
|
branch: "soon",
|
|
207
207
|
categories: ["dex"],
|
|
@@ -224,7 +224,7 @@ const manifest: AppManifest[] = [
|
|
|
224
224
|
homepageUrl: "https://1inch.io/",
|
|
225
225
|
icon: "https://cdn.live.ledger.com/icons/platform/1inch.png",
|
|
226
226
|
platform: "all",
|
|
227
|
-
apiVersion: "0.0.1",
|
|
227
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
228
228
|
manifestVersion: "1",
|
|
229
229
|
branch: "soon",
|
|
230
230
|
categories: ["swap", "defi"],
|
|
@@ -247,7 +247,7 @@ const manifest: AppManifest[] = [
|
|
|
247
247
|
homepageUrl: "https://developers.ledger.com/",
|
|
248
248
|
icon: "https://cdn.live.ledger.com/icons/platform/debugger.png",
|
|
249
249
|
platform: "all",
|
|
250
|
-
apiVersion: "0.0.1",
|
|
250
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
251
251
|
manifestVersion: "1",
|
|
252
252
|
branch: "debug",
|
|
253
253
|
categories: ["tools"],
|
|
@@ -274,7 +274,7 @@ const manifest: AppManifest[] = [
|
|
|
274
274
|
homepageUrl: "https://developers.ledger.com/",
|
|
275
275
|
icon: "",
|
|
276
276
|
platform: "all",
|
|
277
|
-
apiVersion: "0.0.1",
|
|
277
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
278
278
|
manifestVersion: "1",
|
|
279
279
|
branch: "stable",
|
|
280
280
|
categories: ["tools"],
|