@ledgerhq/live-common 25.0.0-next.0 → 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/bot/specs.d.ts +1 -0
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +6 -1
- package/lib/bot/specs.js.map +1 -1
- package/lib/countervalues/api/api.d.ts.map +1 -1
- package/lib/countervalues/api/api.js +25 -13
- package/lib/countervalues/api/api.js.map +1 -1
- package/lib/countervalues/logic.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.d.ts +1 -1
- package/lib/countervalues/logic.integration.test.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.js +78 -2
- package/lib/countervalues/logic.integration.test.js.map +1 -1
- package/lib/countervalues/logic.js +5 -1
- package/lib/countervalues/logic.js.map +1 -1
- package/lib/countervalues/modules/index.d.ts +1 -1
- package/lib/countervalues/modules/index.d.ts.map +1 -1
- package/lib/countervalues/modules/index.js +3 -1
- package/lib/countervalues/modules/index.js.map +1 -1
- package/lib/countervalues/types.d.ts +1 -0
- package/lib/countervalues/types.d.ts.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/env.d.ts +10 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/errors.d.ts +1 -2
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +3 -4
- package/lib/errors.js.map +1 -1
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
- package/lib/families/stellar/api/horizon.d.ts +29 -7
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +114 -58
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/api/index.d.ts +1 -1
- package/lib/families/stellar/api/index.d.ts.map +1 -1
- package/lib/families/stellar/api/index.js +5 -1
- package/lib/families/stellar/api/index.js.map +1 -1
- package/lib/families/stellar/bridge/mock.d.ts.map +1 -1
- package/lib/families/stellar/bridge/mock.js +4 -1
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/stellar/bridge.integration.test.js +12 -4
- package/lib/families/stellar/bridge.integration.test.js.map +1 -1
- package/lib/families/stellar/cli-transaction.d.ts +3 -1
- package/lib/families/stellar/cli-transaction.d.ts.map +1 -1
- package/lib/families/stellar/cli-transaction.js +48 -2
- package/lib/families/stellar/cli-transaction.js.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts +7 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.js +12 -1
- package/lib/families/stellar/deviceTransactionConfig.js.map +1 -1
- package/lib/families/stellar/errors.d.ts +12 -0
- package/lib/families/stellar/errors.d.ts.map +1 -0
- package/lib/families/stellar/errors.js +16 -0
- package/lib/families/stellar/errors.js.map +1 -0
- package/lib/families/stellar/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-buildTransaction.js +34 -16
- package/lib/families/stellar/js-buildTransaction.js.map +1 -1
- package/lib/families/stellar/js-createTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-createTransaction.js +4 -1
- package/lib/families/stellar/js-createTransaction.js.map +1 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js +2 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.js +127 -57
- package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.js +25 -7
- package/lib/families/stellar/js-prepareTransaction.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +33 -6
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/stellar/js-synchronization.d.ts +1 -1
- package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
- package/lib/families/stellar/js-synchronization.js +42 -16
- package/lib/families/stellar/js-synchronization.js.map +1 -1
- package/lib/families/stellar/logic.d.ts +21 -14
- package/lib/families/stellar/logic.d.ts.map +1 -1
- package/lib/families/stellar/logic.js +158 -57
- package/lib/families/stellar/logic.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +182 -7
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +60 -28
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/tokens.d.ts +11 -0
- package/lib/families/stellar/tokens.d.ts.map +1 -0
- package/lib/families/stellar/tokens.js +82 -0
- package/lib/families/stellar/tokens.js.map +1 -0
- package/lib/families/stellar/transaction.d.ts +2 -2
- package/lib/families/stellar/transaction.d.ts.map +1 -1
- package/lib/families/stellar/transaction.js +32 -6
- package/lib/families/stellar/transaction.js.map +1 -1
- package/lib/families/stellar/types.d.ts +45 -0
- package/lib/families/stellar/types.d.ts.map +1 -1
- package/lib/families/stellar/types.js +7 -1
- package/lib/families/stellar/types.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +1 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/transaction.d.ts +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/bot/specs.ts +7 -1
- package/src/countervalues/api/api.ts +25 -8
- package/src/countervalues/logic.integration.test.ts +71 -1
- package/src/countervalues/logic.ts +3 -1
- package/src/countervalues/modules/index.ts +3 -1
- package/src/countervalues/types.ts +2 -0
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1 -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/env.ts +5 -0
- package/src/errors.ts +1 -6
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +765 -339
- package/src/families/stellar/api/horizon.ts +115 -33
- package/src/families/stellar/api/index.ts +4 -0
- package/src/families/stellar/bridge/mock.ts +3 -0
- package/src/families/stellar/bridge.integration.test.ts +10 -2
- package/src/families/stellar/cli-transaction.ts +75 -2
- package/src/families/stellar/deviceTransactionConfig.ts +22 -0
- package/src/families/stellar/errors.ts +34 -0
- package/src/families/stellar/js-buildTransaction.ts +56 -16
- package/src/families/stellar/js-createTransaction.ts +3 -0
- package/src/families/stellar/js-estimateMaxSpendable.ts +1 -1
- package/src/families/stellar/js-getTransactionStatus.ts +152 -60
- package/src/families/stellar/js-prepareTransaction.ts +4 -3
- package/src/families/stellar/js-signOperation.ts +37 -6
- package/src/families/stellar/js-synchronization.ts +53 -11
- package/src/families/stellar/logic.ts +198 -62
- package/src/families/stellar/specs.ts +227 -8
- package/src/families/stellar/speculos-deviceActions.ts +66 -22
- package/src/families/stellar/tokens.ts +118 -0
- package/src/families/stellar/transaction.ts +31 -3
- package/src/families/stellar/types.ts +52 -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,102 @@
|
|
|
1
|
+
import { makeRe } from "minimatch";
|
|
2
|
+
import { PlatformAccount, PlatformCurrency, AppManifest } from "./types";
|
|
3
|
+
import { isPlatformTokenCurrency } from "./helpers";
|
|
4
|
+
import semver from "semver";
|
|
5
|
+
|
|
6
|
+
export type FilterParams = {
|
|
7
|
+
branches?: string[];
|
|
8
|
+
platform?: string;
|
|
9
|
+
private?: boolean;
|
|
10
|
+
version?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type AccountFilters = {
|
|
14
|
+
currencies?: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function filterPlatformAccounts(
|
|
18
|
+
accounts: PlatformAccount[],
|
|
19
|
+
filters: AccountFilters
|
|
20
|
+
): PlatformAccount[] {
|
|
21
|
+
const filterCurrencyRegexes = filters.currencies
|
|
22
|
+
? filters.currencies.map((filter) => makeRe(filter))
|
|
23
|
+
: null;
|
|
24
|
+
|
|
25
|
+
return accounts.filter((account) => {
|
|
26
|
+
if (
|
|
27
|
+
filterCurrencyRegexes &&
|
|
28
|
+
!filterCurrencyRegexes.some((regex) => account.currency.match(regex))
|
|
29
|
+
) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type CurrencyFilters = {
|
|
37
|
+
includeTokens?: boolean;
|
|
38
|
+
currencies?: string[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function filterPlatformCurrencies(
|
|
42
|
+
currencies: PlatformCurrency[],
|
|
43
|
+
filters: CurrencyFilters
|
|
44
|
+
): PlatformCurrency[] {
|
|
45
|
+
const filterCurrencyRegexes = filters.currencies
|
|
46
|
+
? filters.currencies.map((filter) => makeRe(filter))
|
|
47
|
+
: null;
|
|
48
|
+
|
|
49
|
+
return currencies.filter((currency) => {
|
|
50
|
+
if (!filters.includeTokens && isPlatformTokenCurrency(currency)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
filterCurrencyRegexes &&
|
|
56
|
+
!filterCurrencyRegexes.some((regex) => currency.id.match(regex))
|
|
57
|
+
) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function matchVersion(filterParams: FilterParams, manifest: AppManifest) {
|
|
66
|
+
return (
|
|
67
|
+
!filterParams.version ||
|
|
68
|
+
semver.satisfies(filterParams.version, manifest.apiVersion)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function matchBranches(filterParams: FilterParams, manifest: AppManifest) {
|
|
73
|
+
return (
|
|
74
|
+
!filterParams.branches || filterParams.branches.includes(manifest.branch)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function matchPlatform(filterParams: FilterParams, manifest: AppManifest) {
|
|
79
|
+
return (
|
|
80
|
+
!filterParams.platform ||
|
|
81
|
+
manifest.platform === "all" ||
|
|
82
|
+
filterParams.platform === manifest.platform
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function matchPrivate(filterParams: FilterParams, manifest: AppManifest) {
|
|
87
|
+
return filterParams.private === true || !(manifest.private === true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function filterPlatformApps(
|
|
91
|
+
appManifests: AppManifest[],
|
|
92
|
+
filterParams: FilterParams
|
|
93
|
+
): AppManifest[] {
|
|
94
|
+
return appManifests.filter((appManifest: AppManifest) => {
|
|
95
|
+
return (
|
|
96
|
+
matchBranches(filterParams, appManifest) &&
|
|
97
|
+
matchPlatform(filterParams, appManifest) &&
|
|
98
|
+
matchPrivate(filterParams, appManifest) &&
|
|
99
|
+
matchVersion(filterParams, appManifest)
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isCryptoCurrency, isTokenCurrency } from "../currencies";
|
|
2
|
+
import { Currency } from "../types";
|
|
3
|
+
import {
|
|
4
|
+
PlatformCurrency,
|
|
5
|
+
PlatformSupportedCurrency,
|
|
6
|
+
PlatformERC20TokenCurrency,
|
|
7
|
+
PlatformCryptoCurrency,
|
|
8
|
+
PlatformCurrencyType,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
export function isPlatformSupportedCurrency(
|
|
12
|
+
currency: Currency
|
|
13
|
+
): currency is PlatformSupportedCurrency {
|
|
14
|
+
return isCryptoCurrency(currency) || isTokenCurrency(currency);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isPlatformCryptoCurrency(
|
|
18
|
+
currency: PlatformCurrency
|
|
19
|
+
): currency is PlatformCryptoCurrency {
|
|
20
|
+
return currency.type === PlatformCurrencyType.CryptoCurrency;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isPlatformTokenCurrency(
|
|
24
|
+
currency: PlatformCurrency
|
|
25
|
+
): currency is PlatformERC20TokenCurrency {
|
|
26
|
+
return currency.type === PlatformCurrencyType.TokenCurrency;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isPlatformERC20TokenCurrency(
|
|
30
|
+
currency: PlatformCurrency
|
|
31
|
+
): currency is PlatformERC20TokenCurrency {
|
|
32
|
+
return (currency as PlatformERC20TokenCurrency).standard === "ERC20";
|
|
33
|
+
}
|
package/src/platform/logic.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { AppManifest, AppPlatform, AppBranch } from "./types";
|
|
3
|
-
import { getPlatformVersion } from "./version";
|
|
4
|
-
|
|
5
|
-
export function translateContent(content: any, locale = "en") {
|
|
1
|
+
export function translateContent(content: any, locale = "en"): string {
|
|
6
2
|
if (!content || typeof content !== "object") return content;
|
|
7
3
|
return content[locale] || content.en;
|
|
8
4
|
}
|
|
9
|
-
|
|
10
|
-
export function isSupported(manifest: AppManifest) {
|
|
11
|
-
return semver.satisfies(
|
|
12
|
-
semver.coerce(getPlatformVersion()) || "",
|
|
13
|
-
manifest.apiVersion
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function matchBranches(manifest: AppManifest, branches: AppBranch[]) {
|
|
18
|
-
return branches.indexOf(manifest.branch) > -1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function matchPlatform(manifest: AppManifest, platform: AppPlatform) {
|
|
22
|
-
return manifest.platform === "all" || manifest.platform === platform;
|
|
23
|
-
}
|