@ledgerhq/live-common 34.54.0-nightly.20251129023709 → 34.54.0-nightly.20251203101856
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__/test-helpers/bridge.js +1 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/__tests__/test-helpers/environment.js +1 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/account/index.d.ts +1 -0
- package/lib/account/index.d.ts.map +1 -1
- package/lib/account/index.js +4 -1
- package/lib/account/index.js.map +1 -1
- package/lib/account/recentAddresses.d.ts +10 -0
- package/lib/account/recentAddresses.d.ts.map +1 -0
- package/lib/account/recentAddresses.js +60 -0
- package/lib/account/recentAddresses.js.map +1 -0
- package/lib/e2e/index.d.ts +9 -3
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib/exchange/swap/postSwapState.js +10 -6
- package/lib/exchange/swap/postSwapState.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +3 -1
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
- package/lib/families/bitcoin/walletApiAdapter.js +3 -0
- package/lib/families/bitcoin/walletApiAdapter.js.map +1 -1
- package/lib/families/polkadot/config.js +1 -1
- package/lib/families/polkadot/config.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +3 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/helpers/cryptoIconSize.d.ts +3 -0
- package/lib/helpers/cryptoIconSize.d.ts.map +1 -0
- package/lib/helpers/cryptoIconSize.js +40 -0
- package/lib/helpers/cryptoIconSize.js.map +1 -0
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.d.ts.map +1 -1
- package/lib/helpers.js +15 -0
- package/lib/helpers.js.map +1 -1
- package/lib/hooks/useHtmlLinkSegments.d.ts +19 -0
- package/lib/hooks/useHtmlLinkSegments.d.ts.map +1 -0
- package/lib/hooks/useHtmlLinkSegments.js +128 -0
- package/lib/hooks/useHtmlLinkSegments.js.map +1 -0
- package/lib/hw/getAppAndVersion.d.ts +3 -1
- package/lib/hw/getAppAndVersion.d.ts.map +1 -1
- package/lib/hw/getAppAndVersion.js +2 -2
- package/lib/hw/getAppAndVersion.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +4 -0
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/__tests__/test-helpers/environment.js +1 -0
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/account/index.d.ts +1 -0
- package/lib-es/account/index.d.ts.map +1 -1
- package/lib-es/account/index.js +1 -0
- package/lib-es/account/index.js.map +1 -1
- package/lib-es/account/recentAddresses.d.ts +10 -0
- package/lib-es/account/recentAddresses.d.ts.map +1 -0
- package/lib-es/account/recentAddresses.js +55 -0
- package/lib-es/account/recentAddresses.js.map +1 -0
- package/lib-es/e2e/index.d.ts +9 -3
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib-es/exchange/swap/postSwapState.js +10 -6
- package/lib-es/exchange/swap/postSwapState.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +3 -1
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
- package/lib-es/families/bitcoin/walletApiAdapter.js +3 -0
- package/lib-es/families/bitcoin/walletApiAdapter.js.map +1 -1
- package/lib-es/families/polkadot/config.js +1 -1
- package/lib-es/families/polkadot/config.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +3 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/helpers/cryptoIconSize.d.ts +3 -0
- package/lib-es/helpers/cryptoIconSize.d.ts.map +1 -0
- package/lib-es/helpers/cryptoIconSize.js +35 -0
- package/lib-es/helpers/cryptoIconSize.js.map +1 -0
- package/lib-es/helpers.d.ts +1 -0
- package/lib-es/helpers.d.ts.map +1 -1
- package/lib-es/helpers.js +1 -0
- package/lib-es/helpers.js.map +1 -1
- package/lib-es/hooks/useHtmlLinkSegments.d.ts +19 -0
- package/lib-es/hooks/useHtmlLinkSegments.d.ts.map +1 -0
- package/lib-es/hooks/useHtmlLinkSegments.js +121 -0
- package/lib-es/hooks/useHtmlLinkSegments.js.map +1 -0
- package/lib-es/hw/getAppAndVersion.d.ts +3 -1
- package/lib-es/hw/getAppAndVersion.d.ts.map +1 -1
- package/lib-es/hw/getAppAndVersion.js +2 -2
- package/lib-es/hw/getAppAndVersion.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +4 -0
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/package.json +56 -64
- package/src/__tests__/test-helpers/bridge.ts +1 -1
- package/src/__tests__/test-helpers/environment.ts +1 -0
- package/src/account/index.ts +6 -0
- package/src/account/recentAddresses.test.ts +104 -0
- package/src/account/recentAddresses.ts +84 -0
- package/src/exchange/swap/postSwapState.ts +10 -5
- package/src/exchange/swap/types.ts +3 -1
- package/src/families/bitcoin/walletApiAdapter.test.ts +36 -0
- package/src/families/bitcoin/walletApiAdapter.ts +4 -0
- package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +73 -4
- package/src/families/cosmos/datasets/__snapshots__/cryptoOrg.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/injective.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/osmosis.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/persistence.integration.test.ts.snap +4 -4
- package/src/families/cosmos/datasets/__snapshots__/stargaze.integration.test.ts.snap +2 -2
- package/src/families/polkadot/__snapshots__/bridge.integration.test.ts.snap +6 -3653
- package/src/families/polkadot/config.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +3 -1
- package/src/helpers/cryptoIconSize.ts +25 -0
- package/src/helpers.ts +2 -0
- package/src/hooks/__tests__/useHtmlLinkSegments.test.ts +105 -0
- package/src/hooks/useHtmlLinkSegments.ts +158 -0
- package/src/hw/getAppAndVersion.ts +2 -1
- package/src/wallet-api/Exchange/server.ts +5 -0
- package/lib/currencies/cryptoIcons.d.ts +0 -3
- package/lib/currencies/cryptoIcons.d.ts.map +0 -1
- package/lib/currencies/cryptoIcons.js +0 -24
- package/lib/currencies/cryptoIcons.js.map +0 -1
- package/lib/react.d.ts +0 -16
- package/lib/react.d.ts.map +0 -1
- package/lib/react.js +0 -64
- package/lib/react.js.map +0 -1
- package/lib/reactNative.d.ts +0 -16
- package/lib/reactNative.d.ts.map +0 -1
- package/lib/reactNative.js +0 -43
- package/lib/reactNative.js.map +0 -1
- package/lib-es/currencies/cryptoIcons.d.ts +0 -3
- package/lib-es/currencies/cryptoIcons.d.ts.map +0 -1
- package/lib-es/currencies/cryptoIcons.js +0 -20
- package/lib-es/currencies/cryptoIcons.js.map +0 -1
- package/lib-es/react.d.ts +0 -16
- package/lib-es/react.d.ts.map +0 -1
- package/lib-es/react.js +0 -33
- package/lib-es/react.js.map +0 -1
- package/lib-es/reactNative.d.ts +0 -16
- package/lib-es/reactNative.d.ts.map +0 -1
- package/lib-es/reactNative.js +0 -15
- package/lib-es/reactNative.js.map +0 -1
- package/react.js +0 -1
- package/reactNative.js +0 -1
- package/src/currencies/cryptoIcons.test.ts +0 -54
- package/src/currencies/cryptoIcons.ts +0 -21
- package/src/react.tsx +0 -43
- package/src/reactNative.ts +0 -23
- package/src/reactNativeSvg.d.ts +0 -19
|
@@ -57,7 +57,7 @@ export const polkadotConfig: Record<string, ConfigInfo> = {
|
|
|
57
57
|
url: "https://polkadot-metadata-shortener.api.live.ledger.com/node/metadata/hash",
|
|
58
58
|
id: "dot-hub",
|
|
59
59
|
},
|
|
60
|
-
hasBeenMigrated:
|
|
60
|
+
hasBeenMigrated: true,
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
config_currency_westend: {
|
|
@@ -596,6 +596,7 @@ export const DEFAULT_FEATURES: Features = {
|
|
|
596
596
|
postOnboarding: true,
|
|
597
597
|
},
|
|
598
598
|
},
|
|
599
|
+
lwmLedgerSyncOptimisation: DEFAULT_FEATURE,
|
|
599
600
|
lldNanoSUpsellBanners: {
|
|
600
601
|
...DEFAULT_FEATURE,
|
|
601
602
|
params: {
|
|
@@ -680,8 +681,8 @@ export const DEFAULT_FEATURES: Features = {
|
|
|
680
681
|
chains: ["ethereum", "polygon", "base", "arbitrum"],
|
|
681
682
|
},
|
|
682
683
|
},
|
|
683
|
-
ldmkConnectApp: DEFAULT_FEATURE,
|
|
684
684
|
ldmkSolanaSigner: DEFAULT_FEATURE,
|
|
685
|
+
ldmkConnectApp: DEFAULT_FEATURE,
|
|
685
686
|
lldNetworkBasedAddAccount: DEFAULT_FEATURE,
|
|
686
687
|
llmDatadog: {
|
|
687
688
|
...DEFAULT_FEATURE,
|
|
@@ -731,6 +732,7 @@ export const DEFAULT_FEATURES: Features = {
|
|
|
731
732
|
},
|
|
732
733
|
},
|
|
733
734
|
zcashShielded: DEFAULT_FEATURE,
|
|
735
|
+
llmNanoOnboardingFundWallet: DEFAULT_FEATURE,
|
|
734
736
|
};
|
|
735
737
|
|
|
736
738
|
// Firebase SDK treat JSON values as strings
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Utility to map any size to valid crypto-icons sizes
|
|
2
|
+
// For React Native (returns numbers)
|
|
3
|
+
export const getValidCryptoIconSizeNative = (size: number): 16 | 20 | 24 | 32 | 40 | 48 | 56 => {
|
|
4
|
+
if (size <= 16) return 16;
|
|
5
|
+
if (size <= 20) return 20;
|
|
6
|
+
if (size <= 24) return 24;
|
|
7
|
+
if (size <= 32) return 32;
|
|
8
|
+
if (size <= 40) return 40;
|
|
9
|
+
if (size <= 48) return 48;
|
|
10
|
+
return 56;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Utility to map any size to valid crypto-icons sizes
|
|
14
|
+
// For React/Web (returns strings with "px")
|
|
15
|
+
export const getValidCryptoIconSize = (
|
|
16
|
+
size: number,
|
|
17
|
+
): "16px" | "20px" | "24px" | "32px" | "40px" | "48px" | "56px" => {
|
|
18
|
+
if (size <= 16) return "16px";
|
|
19
|
+
if (size <= 20) return "20px";
|
|
20
|
+
if (size <= 24) return "24px";
|
|
21
|
+
if (size <= 32) return "32px";
|
|
22
|
+
if (size <= 40) return "40px";
|
|
23
|
+
if (size <= 48) return "48px";
|
|
24
|
+
return "56px";
|
|
25
|
+
};
|
package/src/helpers.ts
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildHtmlDisplaySegments,
|
|
3
|
+
splitHtmlLinkSegments,
|
|
4
|
+
validateLedgerUrl,
|
|
5
|
+
} from "../useHtmlLinkSegments";
|
|
6
|
+
|
|
7
|
+
describe("splitHtmlLinkSegments", () => {
|
|
8
|
+
it("returns an empty array when input is empty", () => {
|
|
9
|
+
expect(splitHtmlLinkSegments("")).toEqual([]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("returns only text segments when there are no anchors", () => {
|
|
13
|
+
const segments = splitHtmlLinkSegments("simple text without links");
|
|
14
|
+
expect(segments).toEqual([{ type: "text", content: "simple text without links" }]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("splits text into text and link segments", () => {
|
|
18
|
+
const segments = splitHtmlLinkSegments('Hello <a href="https://ledger.com">Ledger</a> !');
|
|
19
|
+
|
|
20
|
+
expect(segments).toEqual([
|
|
21
|
+
{ type: "text", content: "Hello " },
|
|
22
|
+
{ type: "link", label: "Ledger", href: "https://ledger.com" },
|
|
23
|
+
{ type: "text", content: " !" },
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("keeps whitespace-only text segments", () => {
|
|
28
|
+
const segments = splitHtmlLinkSegments(
|
|
29
|
+
'<a href="https://ledger.com">Ledger</a> <a href="https://support.ledger.com">Support</a>',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(segments).toEqual([
|
|
33
|
+
{ type: "link", label: "Ledger", href: "https://ledger.com" },
|
|
34
|
+
{ type: "text", content: " " },
|
|
35
|
+
{ type: "link", label: "Support", href: "https://support.ledger.com" },
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("buildHtmlDisplaySegments", () => {
|
|
41
|
+
it("keeps valid ledger links clickable", () => {
|
|
42
|
+
const segments = buildHtmlDisplaySegments(
|
|
43
|
+
'Visit <a href="https://support.ledger.com">support</a> docs',
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(segments).toEqual([
|
|
47
|
+
{ type: "text", content: "Visit " },
|
|
48
|
+
{ type: "link", href: "https://support.ledger.com", label: "support" },
|
|
49
|
+
{ type: "text", content: " docs" },
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("falls back to text segments for non-ledger links", () => {
|
|
54
|
+
const segments = buildHtmlDisplaySegments('Check <a href="https://example.com">here</a>');
|
|
55
|
+
|
|
56
|
+
expect(segments).toEqual([
|
|
57
|
+
{ type: "text", content: "Check " },
|
|
58
|
+
{ type: "text", content: "here" },
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("ignores invalid protocols", () => {
|
|
63
|
+
const segments = buildHtmlDisplaySegments('Bad <a href="javascript:alert(1)">click</a>');
|
|
64
|
+
|
|
65
|
+
expect(segments).toEqual([
|
|
66
|
+
{ type: "text", content: "Bad " },
|
|
67
|
+
{ type: "text", content: "click" },
|
|
68
|
+
]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("validateLedgerUrl", () => {
|
|
73
|
+
it("accepts ledger http(s) URLs", () => {
|
|
74
|
+
expect(validateLedgerUrl("https://ledger.com")).toEqual({
|
|
75
|
+
isHttp: true,
|
|
76
|
+
isAllowedLedgerDomain: true,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(validateLedgerUrl("https://support.ledger.com/hc/en-us")).toEqual({
|
|
80
|
+
isHttp: true,
|
|
81
|
+
isAllowedLedgerDomain: true,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("rejects non-http protocols", () => {
|
|
86
|
+
expect(validateLedgerUrl("ledgerlive://settings")).toEqual({
|
|
87
|
+
isHttp: false,
|
|
88
|
+
isAllowedLedgerDomain: false,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("rejects non-ledger domains", () => {
|
|
93
|
+
expect(validateLedgerUrl("https://example.com")).toEqual({
|
|
94
|
+
isHttp: true,
|
|
95
|
+
isAllowedLedgerDomain: false,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("rejects invalid URLs", () => {
|
|
100
|
+
expect(validateLedgerUrl("not a url")).toEqual({
|
|
101
|
+
isHttp: false,
|
|
102
|
+
isAllowedLedgerDomain: false,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
export type HtmlLinkSegment =
|
|
4
|
+
| {
|
|
5
|
+
type: "text";
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
| {
|
|
9
|
+
type: "link";
|
|
10
|
+
label: string;
|
|
11
|
+
href: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ANCHOR_OPEN_REGEX = /<a\b[^>]*>/gi;
|
|
15
|
+
const HREF_ATTR_REGEX = /href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s'">]+))/i;
|
|
16
|
+
const CLOSING_ANCHOR = "</a>";
|
|
17
|
+
|
|
18
|
+
export const splitHtmlLinkSegments = (input: string): HtmlLinkSegment[] => {
|
|
19
|
+
const segments: HtmlLinkSegment[] = [];
|
|
20
|
+
|
|
21
|
+
if (!input) {
|
|
22
|
+
return segments;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const lowerInput = input.toLowerCase();
|
|
26
|
+
let cursor = 0;
|
|
27
|
+
ANCHOR_OPEN_REGEX.lastIndex = 0;
|
|
28
|
+
|
|
29
|
+
const extractHrefValue = (tag: string): string | null => {
|
|
30
|
+
const match = HREF_ATTR_REGEX.exec(tag);
|
|
31
|
+
if (!match) return null;
|
|
32
|
+
return match[1] ?? match[2] ?? match[3] ?? null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let match: RegExpExecArray | null;
|
|
36
|
+
while ((match = ANCHOR_OPEN_REGEX.exec(input)) !== null) {
|
|
37
|
+
const startIndex = match.index;
|
|
38
|
+
const tag = match[0];
|
|
39
|
+
const contentStartIndex = startIndex + tag.length;
|
|
40
|
+
const closingIndex = lowerInput.indexOf(CLOSING_ANCHOR, contentStartIndex);
|
|
41
|
+
|
|
42
|
+
if (closingIndex === -1) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (startIndex > cursor) {
|
|
47
|
+
const textBefore = input.slice(cursor, startIndex);
|
|
48
|
+
if (textBefore) {
|
|
49
|
+
segments.push({
|
|
50
|
+
type: "text",
|
|
51
|
+
content: textBefore,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const href = extractHrefValue(tag);
|
|
57
|
+
if (href) {
|
|
58
|
+
const label = input.slice(contentStartIndex, closingIndex);
|
|
59
|
+
segments.push({
|
|
60
|
+
type: "link",
|
|
61
|
+
href,
|
|
62
|
+
label,
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
const fallbackText = input.slice(startIndex, closingIndex + CLOSING_ANCHOR.length);
|
|
66
|
+
segments.push({
|
|
67
|
+
type: "text",
|
|
68
|
+
content: fallbackText,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
cursor = closingIndex + CLOSING_ANCHOR.length;
|
|
73
|
+
ANCHOR_OPEN_REGEX.lastIndex = cursor;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (cursor < input.length) {
|
|
77
|
+
const textAfter = input.slice(cursor);
|
|
78
|
+
if (textAfter) {
|
|
79
|
+
segments.push({
|
|
80
|
+
type: "text",
|
|
81
|
+
content: textAfter,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return segments;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const validateLedgerUrl = (
|
|
90
|
+
href: string,
|
|
91
|
+
): { isHttp: boolean; isAllowedLedgerDomain: boolean } => {
|
|
92
|
+
try {
|
|
93
|
+
const url = new URL(href);
|
|
94
|
+
const isHttp = url.protocol === "http:" || url.protocol === "https:";
|
|
95
|
+
|
|
96
|
+
if (!isHttp) {
|
|
97
|
+
return {
|
|
98
|
+
isHttp: false,
|
|
99
|
+
isAllowedLedgerDomain: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const hostname = url.hostname.toLowerCase();
|
|
104
|
+
const isAllowedLedgerDomain = hostname === "ledger.com" || hostname.endsWith(".ledger.com");
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
isHttp,
|
|
108
|
+
isAllowedLedgerDomain,
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
return {
|
|
112
|
+
isHttp: false,
|
|
113
|
+
isAllowedLedgerDomain: false,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const buildHtmlDisplaySegments = (input: string): HtmlLinkSegment[] => {
|
|
119
|
+
return splitHtmlLinkSegments(input).map(segment => {
|
|
120
|
+
if (segment.type === "link") {
|
|
121
|
+
const { isHttp, isAllowedLedgerDomain } = validateLedgerUrl(segment.href);
|
|
122
|
+
|
|
123
|
+
if (isHttp && isAllowedLedgerDomain) {
|
|
124
|
+
return segment;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
type: "text",
|
|
129
|
+
content: segment.label,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return segment;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const useHtmlLinkSegments = (
|
|
138
|
+
html?: string | null,
|
|
139
|
+
): {
|
|
140
|
+
segments: HtmlLinkSegment[];
|
|
141
|
+
hasLinks: boolean;
|
|
142
|
+
} => {
|
|
143
|
+
return useMemo(() => {
|
|
144
|
+
if (!html) {
|
|
145
|
+
return {
|
|
146
|
+
segments: [],
|
|
147
|
+
hasLinks: false,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const segments = buildHtmlDisplaySegments(html);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
segments,
|
|
155
|
+
hasLinks: segments.some(segment => segment.type === "link"),
|
|
156
|
+
};
|
|
157
|
+
}, [html]);
|
|
158
|
+
};
|
|
@@ -2,12 +2,13 @@ import { GetAppAndVersionUnsupportedFormat } from "../errors";
|
|
|
2
2
|
import Transport from "@ledgerhq/hw-transport";
|
|
3
3
|
export default async (
|
|
4
4
|
transport: Transport,
|
|
5
|
+
{ abortTimeoutMs }: { abortTimeoutMs?: number } = {},
|
|
5
6
|
): Promise<{
|
|
6
7
|
name: string;
|
|
7
8
|
version: string;
|
|
8
9
|
flags: number | Buffer;
|
|
9
10
|
}> => {
|
|
10
|
-
const r = await transport.send(0xb0, 0x01, 0x00, 0x00);
|
|
11
|
+
const r = await transport.send(0xb0, 0x01, 0x00, 0x00, undefined, undefined, { abortTimeoutMs });
|
|
11
12
|
let i = 0;
|
|
12
13
|
const format = r[i++];
|
|
13
14
|
|
|
@@ -53,6 +53,8 @@ import { getSwapStepFromError } from "../../exchange/error";
|
|
|
53
53
|
import { postSwapCancelled } from "../../exchange/swap";
|
|
54
54
|
import { DeviceModelId } from "@ledgerhq/types-devices";
|
|
55
55
|
import { setBroadcastTransaction } from "../../exchange/swap/setBroadcastTransaction";
|
|
56
|
+
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/index";
|
|
57
|
+
import { padHexString } from "@ledgerhq/hw-app-eth";
|
|
56
58
|
|
|
57
59
|
export { ExchangeType };
|
|
58
60
|
|
|
@@ -599,6 +601,9 @@ export const handlers = ({
|
|
|
599
601
|
fromAmount,
|
|
600
602
|
seedIdFrom: mainFromAccount.seedIdentifier,
|
|
601
603
|
seedIdTo: toParentAccount?.seedIdentifier || (toAccount as Account)?.seedIdentifier,
|
|
604
|
+
data: (transaction as EvmTransaction).data
|
|
605
|
+
? `0x${padHexString((transaction as EvmTransaction).data?.toString("hex") || "")}`
|
|
606
|
+
: "0x",
|
|
602
607
|
});
|
|
603
608
|
|
|
604
609
|
reject(error);
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
export declare function inferCryptoCurrencyIcon<Icon>(iconsRegistry: Record<string, Icon>, currency: CryptoCurrency | TokenCurrency): Icon | null | undefined;
|
|
3
|
-
//# sourceMappingURL=cryptoIcons.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoIcons.d.ts","sourceRoot":"","sources":["../../src/currencies/cryptoIcons.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElF,wBAAgB,uBAAuB,CAAC,IAAI,EAC1C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACnC,QAAQ,EAAE,cAAc,GAAG,aAAa,GACvC,IAAI,GAAG,IAAI,GAAG,SAAS,CAazB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// logic that infer a crypto icons slug from a currency
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.inferCryptoCurrencyIcon = void 0;
|
|
5
|
-
function inferCryptoCurrencyIcon(iconsRegistry, currency) {
|
|
6
|
-
if (currency.type === "TokenCurrency") {
|
|
7
|
-
// FIXME DEPRECATED (ongoing hack due to ticker collision)
|
|
8
|
-
if (currency.disableCountervalue)
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
// we allow the icons to define a CURRENCY_{id} format (check in libs/ui/crypto-icons compiled files, they get uppercased. we will improve in future)
|
|
13
|
-
const maybeIconById = iconsRegistry[`currency_${currency.id}`.toUpperCase()];
|
|
14
|
-
if (maybeIconById)
|
|
15
|
-
return maybeIconById;
|
|
16
|
-
}
|
|
17
|
-
// otherwise we fallback by a token lookup
|
|
18
|
-
let id = currency.ticker.toUpperCase();
|
|
19
|
-
if (!isNaN(parseInt(id.charAt(0), 10)))
|
|
20
|
-
id = `_${id}`; // fix variable name leading with a numerical value
|
|
21
|
-
return iconsRegistry[id];
|
|
22
|
-
}
|
|
23
|
-
exports.inferCryptoCurrencyIcon = inferCryptoCurrencyIcon;
|
|
24
|
-
//# sourceMappingURL=cryptoIcons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoIcons.js","sourceRoot":"","sources":["../../src/currencies/cryptoIcons.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;AAIvD,SAAgB,uBAAuB,CACrC,aAAmC,EACnC,QAAwC;IAExC,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE;QACrC,0DAA0D;QAC1D,IAAI,QAAQ,CAAC,mBAAmB;YAAE,OAAO,IAAI,CAAC;KAC/C;SAAM;QACL,qJAAqJ;QACrJ,MAAM,aAAa,GAAG,aAAa,CAAC,YAAY,QAAQ,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7E,IAAI,aAAa;YAAE,OAAO,aAAa,CAAC;KACzC;IACD,0CAA0C;IAC1C,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAAE,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,mDAAmD;IAC1G,OAAO,aAAa,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC;AAhBD,0DAgBC"}
|
package/lib/react.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
-
type Icon = React.ComponentType<{
|
|
4
|
-
size: number;
|
|
5
|
-
color?: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
9
|
-
*/
|
|
10
|
-
export declare function getCryptoCurrencyIcon(currency: CryptoCurrency): Icon | null | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
13
|
-
*/
|
|
14
|
-
export declare function getTokenCurrencyIcon(token: TokenCurrency): Icon | null | undefined;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=react.d.ts.map
|
package/lib/react.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlF,KAAK,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAsBH;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAEvF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAElF"}
|
package/lib/react.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getTokenCurrencyIcon = exports.getCryptoCurrencyIcon = void 0;
|
|
30
|
-
const react_1 = __importDefault(require("react"));
|
|
31
|
-
const icons = __importStar(require("@ledgerhq/crypto-icons-ui/react"));
|
|
32
|
-
const cryptoIcons_1 = require("./currencies/cryptoIcons");
|
|
33
|
-
const polyfillMappingCache = new WeakMap();
|
|
34
|
-
/**
|
|
35
|
-
* thin wrapper from the crypto-icons lib to the format expected by ledger-live-common
|
|
36
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
37
|
-
*/
|
|
38
|
-
function polyfillIconComponent(IconComponent) {
|
|
39
|
-
if (!IconComponent)
|
|
40
|
-
return IconComponent;
|
|
41
|
-
if (polyfillMappingCache.has(IconComponent))
|
|
42
|
-
return polyfillMappingCache.get(IconComponent);
|
|
43
|
-
const PolyfillIconComponent = (props) => props.color === undefined ? (
|
|
44
|
-
// in the previous behavior, we were fallbacking on "currentColor"
|
|
45
|
-
// if you need this behavior, it will be preferrable to explicit set it. as we will drop this polyfill implementation.
|
|
46
|
-
react_1.default.createElement(IconComponent, { ...props, color: "currentColor" })) : (react_1.default.createElement(IconComponent, { ...props }));
|
|
47
|
-
polyfillMappingCache.set(IconComponent, PolyfillIconComponent);
|
|
48
|
-
return PolyfillIconComponent;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
52
|
-
*/
|
|
53
|
-
function getCryptoCurrencyIcon(currency) {
|
|
54
|
-
return polyfillIconComponent((0, cryptoIcons_1.inferCryptoCurrencyIcon)(icons, currency));
|
|
55
|
-
}
|
|
56
|
-
exports.getCryptoCurrencyIcon = getCryptoCurrencyIcon;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
59
|
-
*/
|
|
60
|
-
function getTokenCurrencyIcon(token) {
|
|
61
|
-
return polyfillIconComponent((0, cryptoIcons_1.inferCryptoCurrencyIcon)(icons, token));
|
|
62
|
-
}
|
|
63
|
-
exports.getTokenCurrencyIcon = getTokenCurrencyIcon;
|
|
64
|
-
//# sourceMappingURL=react.js.map
|
package/lib/react.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,uEAAyD;AACzD,0DAAmE;AAOnE,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAc,CAAC;AACvD;;;GAGG;AACH,SAAS,qBAAqB,CAAC,aAAsC;IACnE,IAAI,CAAC,aAAa;QAAE,OAAO,aAAa,CAAC;IACzC,IAAI,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC;QAAE,OAAO,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC5F,MAAM,qBAAqB,GAAG,CAAC,KAAuC,EAAE,EAAE,CACxE,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IAC1B,kEAAkE;IAClE,sHAAsH;IACtH,8BAAC,aAAa,OAAK,KAAK,EAAE,KAAK,EAAC,cAAc,GAAG,CAClD,CAAC,CAAC,CAAC,CACF,8BAAC,aAAa,OAAK,KAAK,GAAI,CAC7B,CAAC;IACJ,oBAAoB,CAAC,GAAG,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;IAC/D,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,QAAwB;IAC5D,OAAO,qBAAqB,CAAC,IAAA,qCAAuB,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzE,CAAC;AAFD,sDAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAoB;IACvD,OAAO,qBAAqB,CAAC,IAAA,qCAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,oDAEC"}
|
package/lib/reactNative.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
-
type Icon = React.ComponentType<{
|
|
4
|
-
size: number;
|
|
5
|
-
color: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
9
|
-
*/
|
|
10
|
-
export declare function getCryptoCurrencyIcon(currency: CryptoCurrency): Icon | null | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
13
|
-
*/
|
|
14
|
-
export declare function getTokenCurrencyIcon(token: TokenCurrency): Icon | null | undefined;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=reactNative.d.ts.map
|
package/lib/reactNative.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactNative.d.ts","sourceRoot":"","sources":["../src/reactNative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlF,KAAK,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAEvF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAElF"}
|
package/lib/reactNative.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getTokenCurrencyIcon = exports.getCryptoCurrencyIcon = void 0;
|
|
27
|
-
const icons = __importStar(require("@ledgerhq/crypto-icons-ui/native"));
|
|
28
|
-
const cryptoIcons_1 = require("./currencies/cryptoIcons");
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
31
|
-
*/
|
|
32
|
-
function getCryptoCurrencyIcon(currency) {
|
|
33
|
-
return (0, cryptoIcons_1.inferCryptoCurrencyIcon)(icons, currency);
|
|
34
|
-
}
|
|
35
|
-
exports.getCryptoCurrencyIcon = getCryptoCurrencyIcon;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
38
|
-
*/
|
|
39
|
-
function getTokenCurrencyIcon(token) {
|
|
40
|
-
return (0, cryptoIcons_1.inferCryptoCurrencyIcon)(icons, token);
|
|
41
|
-
}
|
|
42
|
-
exports.getTokenCurrencyIcon = getTokenCurrencyIcon;
|
|
43
|
-
//# sourceMappingURL=reactNative.js.map
|
package/lib/reactNative.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactNative.js","sourceRoot":"","sources":["../src/reactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wEAA0D;AAE1D,0DAAmE;AAOnE;;GAEG;AACH,SAAgB,qBAAqB,CAAC,QAAwB;IAC5D,OAAO,IAAA,qCAAuB,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAFD,sDAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAoB;IACvD,OAAO,IAAA,qCAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAFD,oDAEC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
export declare function inferCryptoCurrencyIcon<Icon>(iconsRegistry: Record<string, Icon>, currency: CryptoCurrency | TokenCurrency): Icon | null | undefined;
|
|
3
|
-
//# sourceMappingURL=cryptoIcons.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoIcons.d.ts","sourceRoot":"","sources":["../../src/currencies/cryptoIcons.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElF,wBAAgB,uBAAuB,CAAC,IAAI,EAC1C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACnC,QAAQ,EAAE,cAAc,GAAG,aAAa,GACvC,IAAI,GAAG,IAAI,GAAG,SAAS,CAazB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// logic that infer a crypto icons slug from a currency
|
|
2
|
-
export function inferCryptoCurrencyIcon(iconsRegistry, currency) {
|
|
3
|
-
if (currency.type === "TokenCurrency") {
|
|
4
|
-
// FIXME DEPRECATED (ongoing hack due to ticker collision)
|
|
5
|
-
if (currency.disableCountervalue)
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
// we allow the icons to define a CURRENCY_{id} format (check in libs/ui/crypto-icons compiled files, they get uppercased. we will improve in future)
|
|
10
|
-
const maybeIconById = iconsRegistry[`currency_${currency.id}`.toUpperCase()];
|
|
11
|
-
if (maybeIconById)
|
|
12
|
-
return maybeIconById;
|
|
13
|
-
}
|
|
14
|
-
// otherwise we fallback by a token lookup
|
|
15
|
-
let id = currency.ticker.toUpperCase();
|
|
16
|
-
if (!isNaN(parseInt(id.charAt(0), 10)))
|
|
17
|
-
id = `_${id}`; // fix variable name leading with a numerical value
|
|
18
|
-
return iconsRegistry[id];
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=cryptoIcons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoIcons.js","sourceRoot":"","sources":["../../src/currencies/cryptoIcons.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAIvD,MAAM,UAAU,uBAAuB,CACrC,aAAmC,EACnC,QAAwC;IAExC,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE;QACrC,0DAA0D;QAC1D,IAAI,QAAQ,CAAC,mBAAmB;YAAE,OAAO,IAAI,CAAC;KAC/C;SAAM;QACL,qJAAqJ;QACrJ,MAAM,aAAa,GAAG,aAAa,CAAC,YAAY,QAAQ,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7E,IAAI,aAAa;YAAE,OAAO,aAAa,CAAC;KACzC;IACD,0CAA0C;IAC1C,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAAE,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,mDAAmD;IAC1G,OAAO,aAAa,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC"}
|
package/lib-es/react.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
-
type Icon = React.ComponentType<{
|
|
4
|
-
size: number;
|
|
5
|
-
color?: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
9
|
-
*/
|
|
10
|
-
export declare function getCryptoCurrencyIcon(currency: CryptoCurrency): Icon | null | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
13
|
-
*/
|
|
14
|
-
export declare function getTokenCurrencyIcon(token: TokenCurrency): Icon | null | undefined;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=react.d.ts.map
|
package/lib-es/react.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlF,KAAK,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAsBH;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAEvF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAElF"}
|
package/lib-es/react.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import * as icons from "@ledgerhq/crypto-icons-ui/react";
|
|
3
|
-
import { inferCryptoCurrencyIcon } from "./currencies/cryptoIcons";
|
|
4
|
-
const polyfillMappingCache = new WeakMap();
|
|
5
|
-
/**
|
|
6
|
-
* thin wrapper from the crypto-icons lib to the format expected by ledger-live-common
|
|
7
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
8
|
-
*/
|
|
9
|
-
function polyfillIconComponent(IconComponent) {
|
|
10
|
-
if (!IconComponent)
|
|
11
|
-
return IconComponent;
|
|
12
|
-
if (polyfillMappingCache.has(IconComponent))
|
|
13
|
-
return polyfillMappingCache.get(IconComponent);
|
|
14
|
-
const PolyfillIconComponent = (props) => props.color === undefined ? (
|
|
15
|
-
// in the previous behavior, we were fallbacking on "currentColor"
|
|
16
|
-
// if you need this behavior, it will be preferrable to explicit set it. as we will drop this polyfill implementation.
|
|
17
|
-
React.createElement(IconComponent, { ...props, color: "currentColor" })) : (React.createElement(IconComponent, { ...props }));
|
|
18
|
-
polyfillMappingCache.set(IconComponent, PolyfillIconComponent);
|
|
19
|
-
return PolyfillIconComponent;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
23
|
-
*/
|
|
24
|
-
export function getCryptoCurrencyIcon(currency) {
|
|
25
|
-
return polyfillIconComponent(inferCryptoCurrencyIcon(icons, currency));
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
|
|
29
|
-
*/
|
|
30
|
-
export function getTokenCurrencyIcon(token) {
|
|
31
|
-
return polyfillIconComponent(inferCryptoCurrencyIcon(icons, token));
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=react.js.map
|
package/lib-es/react.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAc,CAAC;AACvD;;;GAGG;AACH,SAAS,qBAAqB,CAAC,aAAsC;IACnE,IAAI,CAAC,aAAa;QAAE,OAAO,aAAa,CAAC;IACzC,IAAI,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC;QAAE,OAAO,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC5F,MAAM,qBAAqB,GAAG,CAAC,KAAuC,EAAE,EAAE,CACxE,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IAC1B,kEAAkE;IAClE,sHAAsH;IACtH,oBAAC,aAAa,OAAK,KAAK,EAAE,KAAK,EAAC,cAAc,GAAG,CAClD,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,OAAK,KAAK,GAAI,CAC7B,CAAC;IACJ,oBAAoB,CAAC,GAAG,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;IAC/D,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAwB;IAC5D,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAoB;IACvD,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC"}
|