@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,93 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { AccountLike } from "../types";
|
|
3
|
+
import {
|
|
4
|
+
accountToPlatformAccount,
|
|
5
|
+
currencyToPlatformCurrency,
|
|
6
|
+
} from "./converters";
|
|
7
|
+
import {
|
|
8
|
+
filterPlatformAccounts,
|
|
9
|
+
filterPlatformCurrencies,
|
|
10
|
+
AccountFilters,
|
|
11
|
+
CurrencyFilters,
|
|
12
|
+
} from "./filters";
|
|
13
|
+
import { isPlatformSupportedCurrency } from "./helpers";
|
|
14
|
+
import {
|
|
15
|
+
ListPlatformAccount,
|
|
16
|
+
ListPlatformCurrency,
|
|
17
|
+
PlatformCurrency,
|
|
18
|
+
AppManifest,
|
|
19
|
+
} from "./types";
|
|
20
|
+
import { getParentAccount } from "../account";
|
|
21
|
+
import { listCurrencies } from "../currencies";
|
|
22
|
+
|
|
23
|
+
export function usePlatformUrl(
|
|
24
|
+
manifest: AppManifest,
|
|
25
|
+
params: { background: string; text: string; loadDate?: Date },
|
|
26
|
+
inputs: Record<string, string>
|
|
27
|
+
): URL {
|
|
28
|
+
return useMemo(() => {
|
|
29
|
+
const url = new URL(manifest.url.toString());
|
|
30
|
+
|
|
31
|
+
if (inputs) {
|
|
32
|
+
for (const key in inputs) {
|
|
33
|
+
if (Object.prototype.hasOwnProperty.call(inputs, key)) {
|
|
34
|
+
url.searchParams.set(key, inputs[key]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
url.searchParams.set("backgroundColor", params.background);
|
|
40
|
+
url.searchParams.set("textColor", params.text);
|
|
41
|
+
if (params.loadDate) {
|
|
42
|
+
url.searchParams.set("loadDate", params.loadDate.valueOf().toString());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (manifest.params) {
|
|
46
|
+
url.searchParams.set("params", JSON.stringify(manifest.params));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return url;
|
|
50
|
+
}, [manifest.url, manifest.params, params, inputs]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function useListPlatformAccounts(
|
|
54
|
+
accounts: AccountLike[]
|
|
55
|
+
): ListPlatformAccount {
|
|
56
|
+
const platformAccounts = useMemo(() => {
|
|
57
|
+
return accounts.map((account) => {
|
|
58
|
+
const parentAccount = getParentAccount(account, accounts);
|
|
59
|
+
|
|
60
|
+
return accountToPlatformAccount(account, parentAccount);
|
|
61
|
+
});
|
|
62
|
+
}, [accounts]);
|
|
63
|
+
|
|
64
|
+
return useCallback(
|
|
65
|
+
(filters: AccountFilters = {}) => {
|
|
66
|
+
return filterPlatformAccounts(platformAccounts, filters);
|
|
67
|
+
},
|
|
68
|
+
[platformAccounts]
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function usePlatformCurrencies(
|
|
73
|
+
includeTokens = false
|
|
74
|
+
): PlatformCurrency[] {
|
|
75
|
+
return useMemo(
|
|
76
|
+
() =>
|
|
77
|
+
listCurrencies(includeTokens)
|
|
78
|
+
.filter(isPlatformSupportedCurrency)
|
|
79
|
+
.map(currencyToPlatformCurrency),
|
|
80
|
+
[includeTokens]
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function useListPlatformCurrencies(): ListPlatformCurrency {
|
|
85
|
+
const currencies = usePlatformCurrencies(true);
|
|
86
|
+
|
|
87
|
+
return useCallback(
|
|
88
|
+
(filters?: CurrencyFilters) => {
|
|
89
|
+
return filterPlatformCurrencies(currencies, filters || {});
|
|
90
|
+
},
|
|
91
|
+
[currencies]
|
|
92
|
+
);
|
|
93
|
+
}
|
package/src/platform/types.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SignedOperation, CryptoCurrency, TokenCurrency } from "../types";
|
|
2
|
+
import { AccountFilters, CurrencyFilters } from "./filters";
|
|
3
|
+
import {
|
|
4
|
+
Account as PlatformAccount,
|
|
5
|
+
Currency as PlatformCurrency,
|
|
6
|
+
} from "@ledgerhq/live-app-sdk";
|
|
2
7
|
|
|
3
8
|
export type {
|
|
4
9
|
Account as PlatformAccount,
|
|
5
10
|
Currency as PlatformCurrency,
|
|
6
11
|
Unit as PlatformUnit,
|
|
7
12
|
Transaction as PlatformTransaction,
|
|
13
|
+
CryptoCurrency as PlatformCryptoCurrency,
|
|
14
|
+
ERC20TokenCurrency as PlatformERC20TokenCurrency,
|
|
15
|
+
} from "@ledgerhq/live-app-sdk";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
CurrencyType as PlatformCurrencyType,
|
|
19
|
+
TokenStandard as PlatformTokenStandard,
|
|
8
20
|
} from "@ledgerhq/live-app-sdk";
|
|
9
21
|
|
|
10
22
|
export type TranslatableString = {
|
|
@@ -52,3 +64,13 @@ export type PlatformApi = {
|
|
|
52
64
|
};
|
|
53
65
|
|
|
54
66
|
export type PlatformSignedTransaction = SignedOperation;
|
|
67
|
+
|
|
68
|
+
export type ListPlatformAccount = (
|
|
69
|
+
filters?: AccountFilters
|
|
70
|
+
) => PlatformAccount[];
|
|
71
|
+
|
|
72
|
+
export type ListPlatformCurrency = (
|
|
73
|
+
filters?: CurrencyFilters
|
|
74
|
+
) => PlatformCurrency[];
|
|
75
|
+
|
|
76
|
+
export type PlatformSupportedCurrency = CryptoCurrency | TokenCurrency;
|
|
@@ -8,9 +8,6 @@ import { getCryptoCurrencyById, setSupportedCurrencies } from "../currencies";
|
|
|
8
8
|
import type { Account } from "../types/account";
|
|
9
9
|
import { emptyHistoryCache } from "../account";
|
|
10
10
|
import { setEnv } from "../env";
|
|
11
|
-
import { setPlatformVersion } from "../platform/version";
|
|
12
|
-
|
|
13
|
-
setPlatformVersion("0.0.1");
|
|
14
11
|
|
|
15
12
|
describe("walletconnect", () => {
|
|
16
13
|
const account: Account = {
|