@metamask/design-system-react 0.3.0 → 0.4.0
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/CHANGELOG.md +20 -1
- package/dist/components/AvatarBase/AvatarBase.cjs +1 -1
- package/dist/components/AvatarBase/AvatarBase.cjs.map +1 -1
- package/dist/components/AvatarBase/AvatarBase.mjs +1 -1
- package/dist/components/AvatarBase/AvatarBase.mjs.map +1 -1
- package/dist/components/Icon/icons/AttachMoney.cjs +32 -0
- package/dist/components/Icon/icons/AttachMoney.cjs.map +1 -0
- package/dist/components/Icon/icons/AttachMoney.d.cts +4 -0
- package/dist/components/Icon/icons/AttachMoney.d.cts.map +1 -0
- package/dist/components/Icon/icons/AttachMoney.d.mts +4 -0
- package/dist/components/Icon/icons/AttachMoney.d.mts.map +1 -0
- package/dist/components/Icon/icons/AttachMoney.mjs +7 -0
- package/dist/components/Icon/icons/AttachMoney.mjs.map +1 -0
- package/dist/components/Icon/icons/index.cjs +2 -0
- package/dist/components/Icon/icons/index.cjs.map +1 -1
- package/dist/components/Icon/icons/index.d.cts +1 -0
- package/dist/components/Icon/icons/index.d.cts.map +1 -1
- package/dist/components/Icon/icons/index.d.mts +1 -0
- package/dist/components/Icon/icons/index.d.mts.map +1 -1
- package/dist/components/Icon/icons/index.mjs +2 -0
- package/dist/components/Icon/icons/index.mjs.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.cjs +4 -1
- package/dist/components/temp-components/Blockies/Blockies.cjs.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.d.cts.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.d.mts.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.mjs +4 -1
- package/dist/components/temp-components/Blockies/Blockies.mjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs +35 -46
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.cts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.mts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs +35 -46
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.cjs +14 -6
- package/dist/components/temp-components/Maskicon/Maskicon.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.cts +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.mts +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.mjs +15 -7
- package/dist/components/temp-components/Maskicon/Maskicon.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.cts +6 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.mts +6 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.cjs +6 -81
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.cts +0 -26
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.mts +0 -26
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.mjs +5 -77
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.mjs.map +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs +0 -67
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts +0 -24
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts +0 -24
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs +0 -61
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs.map +0 -1
|
@@ -27,11 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Jazzicon = void 0;
|
|
30
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
30
31
|
const jazzicon_1 = __importDefault(require("@metamask/jazzicon"));
|
|
31
|
-
const utils_1 = require("@metamask/utils");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
33
|
const tw_merge_1 = require("../../../utils/tw-merge.cjs");
|
|
34
|
-
const Jazzicon_utilities_1 = require("./Jazzicon.utilities.cjs");
|
|
35
34
|
/**
|
|
36
35
|
* Cache for storing generated SVG elements by `address:diameter` so
|
|
37
36
|
* we don't regenerate them repeatedly.
|
|
@@ -40,53 +39,43 @@ const iconCache = {};
|
|
|
40
39
|
const Jazzicon = ({ address, size = 32, className, ...props }) => {
|
|
41
40
|
const containerRef = (0, react_1.useRef)(null);
|
|
42
41
|
(0, react_1.useEffect)(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
if (!containerRef.current) {
|
|
43
|
+
return () => {
|
|
44
|
+
// No cleanup needed if container ref was null
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Clear any existing content
|
|
48
|
+
while (containerRef.current.firstChild) {
|
|
49
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
50
|
+
}
|
|
51
|
+
// Check the cache
|
|
52
|
+
const cacheKey = `${address.toLowerCase()}:${size}`;
|
|
53
|
+
if (iconCache[cacheKey]) {
|
|
54
|
+
// If cached, just append a clone
|
|
55
|
+
const clone = iconCache[cacheKey].cloneNode(true);
|
|
56
|
+
containerRef.current.appendChild(clone);
|
|
57
|
+
return () => {
|
|
58
|
+
if (containerRef.current) {
|
|
59
|
+
while (containerRef.current.firstChild) {
|
|
60
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
// Create Jazzicon
|
|
76
|
-
const newIcon = (0, jazzicon_1.default)(size, seed);
|
|
77
|
-
// Cache it
|
|
78
|
-
iconCache[cacheKey] = newIcon;
|
|
79
|
-
// Append a fresh clone
|
|
80
|
-
if (!isCancelled && containerRef.current) {
|
|
81
|
-
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
generateJazzicon().catch(() => {
|
|
85
|
-
// Silently ignore errors during async generation
|
|
86
|
-
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Extract the account address from CAIP-10 format if needed
|
|
66
|
+
const accountAddress = (0, design_system_shared_1.extractAccountAddress)(address);
|
|
67
|
+
// Generate appropriate seed based on address format
|
|
68
|
+
const seed = (0, design_system_shared_1.generateIconSeed)(accountAddress);
|
|
69
|
+
// Create Jazzicon
|
|
70
|
+
const newIcon = (0, jazzicon_1.default)(size, seed);
|
|
71
|
+
// Cache it
|
|
72
|
+
iconCache[cacheKey] = newIcon;
|
|
73
|
+
// Append a fresh clone
|
|
74
|
+
if (containerRef.current) {
|
|
75
|
+
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
76
|
+
}
|
|
87
77
|
// Cleanup
|
|
88
78
|
return () => {
|
|
89
|
-
isCancelled = true;
|
|
90
79
|
if (containerRef.current) {
|
|
91
80
|
while (containerRef.current.firstChild) {
|
|
92
81
|
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAC1C
|
|
1
|
+
{"version":3,"file":"Jazzicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAGwC;AACxC,kEAA0C;AAC1C,+CAAiD;AAEjD,0DAAkD;AAIlD;;;GAGG;AACH,MAAM,SAAS,GAAmC,EAAE,CAAC;AAE9C,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAElD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,8CAA8C;YAChD,CAAC,CAAC;SACH;QAED,6BAA6B;QAC7B,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;YACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SACnE;QAED,kBAAkB;QAClB,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;QACpD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;YACvB,iCAAiC;YACjC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAmB,CAAC;YACpE,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxC,OAAO,GAAG,EAAE;gBACV,IAAI,YAAY,CAAC,OAAO,EAAE;oBACxB,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;wBACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;qBACnE;iBACF;YACH,CAAC,CAAC;SACH;QAED,4DAA4D;QAC5D,MAAM,cAAc,GAAG,IAAA,4CAAqB,EAAC,OAAO,CAAC,CAAC;QAEtD,oDAAoD;QACpD,MAAM,IAAI,GAAG,IAAA,uCAAgB,EAAC,cAAc,CAAC,CAAC;QAE9C,kBAAkB;QAClB,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,IAAI,EAAE,IAAI,CAAmB,CAAC;QAEvD,WAAW;QACX,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAyB,CAAC;QAEhD,uBAAuB;QACvB,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3D;QAED,UAAU;QACV,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;oBACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;iBACnE;aACF;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,uCACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,IAAA,kBAAO,EAAC,4BAA4B,EAAE,SAAS,CAAC,KACvD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AArEW,QAAA,QAAQ,YAqEnB;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import {\n extractAccountAddress,\n generateIconSeed,\n} from '@metamask/design-system-shared';\nimport jazzicon from '@metamask/jazzicon';\nimport React, { useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../../utils/tw-merge';\n\nimport type { JazziconProps } from './Jazzicon.types';\n\n/**\n * Cache for storing generated SVG elements by `address:diameter` so\n * we don't regenerate them repeatedly.\n */\nconst iconCache: Record<string, HTMLDivElement> = {};\n\nexport const Jazzicon = ({\n address,\n size = 32,\n className,\n ...props\n}: JazziconProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) {\n return () => {\n // No cleanup needed if container ref was null\n };\n }\n\n // Clear any existing content\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n\n // Check the cache\n const cacheKey = `${address.toLowerCase()}:${size}`;\n if (iconCache[cacheKey]) {\n // If cached, just append a clone\n const clone = iconCache[cacheKey].cloneNode(true) as HTMLDivElement;\n containerRef.current.appendChild(clone);\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }\n\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n // Generate appropriate seed based on address format\n const seed = generateIconSeed(accountAddress);\n\n // Create Jazzicon\n const newIcon = jazzicon(size, seed) as HTMLDivElement;\n\n // Cache it\n iconCache[cacheKey] = newIcon as HTMLDivElement;\n\n // Append a fresh clone\n if (containerRef.current) {\n containerRef.current.appendChild(newIcon.cloneNode(true));\n }\n\n // Cleanup\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }, [address, size]);\n\n return (\n <div\n ref={containerRef}\n className={twMerge('flex [&>div]:!rounded-none', className)}\n {...props}\n />\n );\n};\n\nJazzicon.displayName = 'Jazzicon';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Jazzicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,cAAc;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAQtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAgEf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Jazzicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,cAAc;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAQtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAgEf,CAAC"}
|
|
@@ -4,13 +4,12 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
+
import { extractAccountAddress, generateIconSeed } from "@metamask/design-system-shared";
|
|
7
8
|
import $jazzicon from "@metamask/jazzicon";
|
|
8
9
|
const jazzicon = $importDefault($jazzicon);
|
|
9
|
-
import { KnownCaipNamespace } from "@metamask/utils";
|
|
10
10
|
import $React, { useEffect, useRef } from "react";
|
|
11
11
|
const React = $importDefault($React);
|
|
12
12
|
import { twMerge } from "../../../utils/tw-merge.mjs";
|
|
13
|
-
import { generateSeedEthereum, generateSeedNonEthereum, getCaipNamespaceFromAddress } from "./Jazzicon.utilities.mjs";
|
|
14
13
|
/**
|
|
15
14
|
* Cache for storing generated SVG elements by `address:diameter` so
|
|
16
15
|
* we don't regenerate them repeatedly.
|
|
@@ -19,53 +18,43 @@ const iconCache = {};
|
|
|
19
18
|
export const Jazzicon = ({ address, size = 32, className, ...props }) => {
|
|
20
19
|
const containerRef = useRef(null);
|
|
21
20
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
if (!containerRef.current) {
|
|
22
|
+
return () => {
|
|
23
|
+
// No cleanup needed if container ref was null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Clear any existing content
|
|
27
|
+
while (containerRef.current.firstChild) {
|
|
28
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
29
|
+
}
|
|
30
|
+
// Check the cache
|
|
31
|
+
const cacheKey = `${address.toLowerCase()}:${size}`;
|
|
32
|
+
if (iconCache[cacheKey]) {
|
|
33
|
+
// If cached, just append a clone
|
|
34
|
+
const clone = iconCache[cacheKey].cloneNode(true);
|
|
35
|
+
containerRef.current.appendChild(clone);
|
|
36
|
+
return () => {
|
|
37
|
+
if (containerRef.current) {
|
|
38
|
+
while (containerRef.current.firstChild) {
|
|
39
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
// Create Jazzicon
|
|
55
|
-
const newIcon = jazzicon(size, seed);
|
|
56
|
-
// Cache it
|
|
57
|
-
iconCache[cacheKey] = newIcon;
|
|
58
|
-
// Append a fresh clone
|
|
59
|
-
if (!isCancelled && containerRef.current) {
|
|
60
|
-
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
generateJazzicon().catch(() => {
|
|
64
|
-
// Silently ignore errors during async generation
|
|
65
|
-
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Extract the account address from CAIP-10 format if needed
|
|
45
|
+
const accountAddress = extractAccountAddress(address);
|
|
46
|
+
// Generate appropriate seed based on address format
|
|
47
|
+
const seed = generateIconSeed(accountAddress);
|
|
48
|
+
// Create Jazzicon
|
|
49
|
+
const newIcon = jazzicon(size, seed);
|
|
50
|
+
// Cache it
|
|
51
|
+
iconCache[cacheKey] = newIcon;
|
|
52
|
+
// Append a fresh clone
|
|
53
|
+
if (containerRef.current) {
|
|
54
|
+
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
55
|
+
}
|
|
66
56
|
// Cleanup
|
|
67
57
|
return () => {
|
|
68
|
-
isCancelled = true;
|
|
69
58
|
if (containerRef.current) {
|
|
70
59
|
while (containerRef.current.firstChild) {
|
|
71
60
|
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Jazzicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EACjB,uCAAuC;AACxC,OAAO,SAAQ,2BAA2B;;AAC1C,OAAO,QAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc;;AAEjD,OAAO,EAAE,OAAO,EAAE,oCAAgC;AAIlD;;;GAGG;AACH,MAAM,SAAS,GAAmC,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,8CAA8C;YAChD,CAAC,CAAC;SACH;QAED,6BAA6B;QAC7B,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;YACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SACnE;QAED,kBAAkB;QAClB,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;QACpD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;YACvB,iCAAiC;YACjC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAmB,CAAC;YACpE,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxC,OAAO,GAAG,EAAE;gBACV,IAAI,YAAY,CAAC,OAAO,EAAE;oBACxB,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;wBACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;qBACnE;iBACF;YACH,CAAC,CAAC;SACH;QAED,4DAA4D;QAC5D,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAEtD,oDAAoD;QACpD,MAAM,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAE9C,kBAAkB;QAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAmB,CAAC;QAEvD,WAAW;QACX,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAyB,CAAC;QAEhD,uBAAuB;QACvB,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3D;QAED,UAAU;QACV,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;oBACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;iBACnE;aACF;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,OAAO,CAAC,4BAA4B,EAAE,SAAS,CAAC,KACvD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import {\n extractAccountAddress,\n generateIconSeed,\n} from '@metamask/design-system-shared';\nimport jazzicon from '@metamask/jazzicon';\nimport React, { useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../../utils/tw-merge';\n\nimport type { JazziconProps } from './Jazzicon.types';\n\n/**\n * Cache for storing generated SVG elements by `address:diameter` so\n * we don't regenerate them repeatedly.\n */\nconst iconCache: Record<string, HTMLDivElement> = {};\n\nexport const Jazzicon = ({\n address,\n size = 32,\n className,\n ...props\n}: JazziconProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) {\n return () => {\n // No cleanup needed if container ref was null\n };\n }\n\n // Clear any existing content\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n\n // Check the cache\n const cacheKey = `${address.toLowerCase()}:${size}`;\n if (iconCache[cacheKey]) {\n // If cached, just append a clone\n const clone = iconCache[cacheKey].cloneNode(true) as HTMLDivElement;\n containerRef.current.appendChild(clone);\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }\n\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n // Generate appropriate seed based on address format\n const seed = generateIconSeed(accountAddress);\n\n // Create Jazzicon\n const newIcon = jazzicon(size, seed) as HTMLDivElement;\n\n // Cache it\n iconCache[cacheKey] = newIcon as HTMLDivElement;\n\n // Append a fresh clone\n if (containerRef.current) {\n containerRef.current.appendChild(newIcon.cloneNode(true));\n }\n\n // Cleanup\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }, [address, size]);\n\n return (\n <div\n ref={containerRef}\n className={twMerge('flex [&>div]:!rounded-none', className)}\n {...props}\n />\n );\n};\n\nJazzicon.displayName = 'Jazzicon';\n"]}
|
|
@@ -24,11 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Maskicon = void 0;
|
|
27
|
-
const dompurify = __importStar(require("dompurify"));
|
|
28
27
|
const react_1 = __importStar(require("react"));
|
|
29
28
|
const Maskicon_utilities_1 = require("./Maskicon.utilities.cjs");
|
|
30
|
-
const
|
|
31
|
-
const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
29
|
+
const Maskicon = ({ address, size = 32, className, ...props }) => {
|
|
32
30
|
const [svgString, setSvgString] = (0, react_1.useState)('');
|
|
33
31
|
(0, react_1.useEffect)(() => {
|
|
34
32
|
let cancelled = false;
|
|
@@ -43,10 +41,20 @@ const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
|
43
41
|
cancelled = true;
|
|
44
42
|
};
|
|
45
43
|
}, [address, size]);
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const dataUri = (0, react_1.useMemo)(() => {
|
|
45
|
+
if (!svgString) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
// Normalize whitespace and encode the SVG for safe data URI usage
|
|
49
|
+
const cleanedSvg = svgString.replace(/\s+/gu, ' ').trim();
|
|
50
|
+
const encoded = encodeURIComponent(cleanedSvg);
|
|
51
|
+
return `data:image/svg+xml,${encoded}`;
|
|
52
|
+
}, [svgString]);
|
|
53
|
+
if (!dataUri) {
|
|
54
|
+
// Return an img element with transparent placeholder to maintain consistent typing
|
|
55
|
+
return (react_1.default.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E", ...props }));
|
|
48
56
|
}
|
|
49
|
-
return (react_1.default.createElement("
|
|
57
|
+
return (react_1.default.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: dataUri, ...props }));
|
|
50
58
|
};
|
|
51
59
|
exports.Maskicon = Maskicon;
|
|
52
60
|
exports.Maskicon.displayName = 'Maskicon';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"Maskicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAG5D,iEAAsD;AAE/C,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IAE/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,mCAAmC;QACnC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAc,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,SAAS,EAAE;gBACd,YAAY,CAAC,MAAM,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC3B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,EAAE,CAAC;SACX;QACD,kEAAkE;QAClE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/C,OAAO,sBAAsB,OAAO,EAAE,CAAC;IACzC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAI,CAAC,OAAO,EAAE;QACZ,mFAAmF;QACnF,OAAO,CACL,uCACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAC,kEAAkE,KAClE,KAAK,GACT,CACH,CAAC;KACH;IAED,OAAO,CACL,uCACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,OAAO,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAxDW,QAAA,QAAQ,YAwDnB;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nexport const Maskicon = ({\n address,\n size = 32,\n className,\n ...props\n}: MaskiconProps) => {\n const [svgString, setSvgString] = useState('');\n\n useEffect(() => {\n let cancelled = false;\n // eslint-disable-next-line no-void\n void (async () => {\n const newSvg = await getMaskiconSVG(address, size);\n if (!cancelled) {\n setSvgString(newSvg);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [address, size]);\n\n const dataUri = useMemo(() => {\n if (!svgString) {\n return '';\n }\n // Normalize whitespace and encode the SVG for safe data URI usage\n const cleanedSvg = svgString.replace(/\\s+/gu, ' ').trim();\n const encoded = encodeURIComponent(cleanedSvg);\n return `data:image/svg+xml,${encoded}`;\n }, [svgString]);\n\n if (!dataUri) {\n // Return an img element with transparent placeholder to maintain consistent typing\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E\"\n {...props}\n />\n );\n }\n\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src={dataUri}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MaskiconProps } from "./Maskicon.types.cjs";
|
|
3
3
|
export declare const Maskicon: {
|
|
4
|
-
({ address, size,
|
|
4
|
+
({ address, size, className, ...props }: MaskiconProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=Maskicon.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Maskicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,cAAc;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAGtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAmDf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MaskiconProps } from "./Maskicon.types.mjs";
|
|
3
3
|
export declare const Maskicon: {
|
|
4
|
-
({ address, size,
|
|
4
|
+
({ address, size, className, ...props }: MaskiconProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=Maskicon.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Maskicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,cAAc;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAGtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAmDf,CAAC"}
|
|
@@ -4,12 +4,10 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
-
import
|
|
8
|
-
import $React, { useEffect, useState } from "react";
|
|
7
|
+
import $React, { useEffect, useMemo, useState } from "react";
|
|
9
8
|
const React = $importDefault($React);
|
|
10
9
|
import { getMaskiconSVG } from "./Maskicon.utilities.mjs";
|
|
11
|
-
const
|
|
12
|
-
export const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
10
|
+
export const Maskicon = ({ address, size = 32, className, ...props }) => {
|
|
13
11
|
const [svgString, setSvgString] = useState('');
|
|
14
12
|
useEffect(() => {
|
|
15
13
|
let cancelled = false;
|
|
@@ -24,10 +22,20 @@ export const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
|
24
22
|
cancelled = true;
|
|
25
23
|
};
|
|
26
24
|
}, [address, size]);
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const dataUri = useMemo(() => {
|
|
26
|
+
if (!svgString) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
// Normalize whitespace and encode the SVG for safe data URI usage
|
|
30
|
+
const cleanedSvg = svgString.replace(/\s+/gu, ' ').trim();
|
|
31
|
+
const encoded = encodeURIComponent(cleanedSvg);
|
|
32
|
+
return `data:image/svg+xml,${encoded}`;
|
|
33
|
+
}, [svgString]);
|
|
34
|
+
if (!dataUri) {
|
|
35
|
+
// Return an img element with transparent placeholder to maintain consistent typing
|
|
36
|
+
return (React.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E", ...props }));
|
|
29
37
|
}
|
|
30
|
-
return (React.createElement("
|
|
38
|
+
return (React.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: dataUri, ...props }));
|
|
31
39
|
};
|
|
32
40
|
Maskicon.displayName = 'Maskicon';
|
|
33
41
|
//# sourceMappingURL=Maskicon.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Maskicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc;;AAG5D,OAAO,EAAE,cAAc,EAAE,iCAA6B;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE/C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,mCAAmC;QACnC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,SAAS,EAAE;gBACd,YAAY,CAAC,MAAM,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,EAAE,CAAC;SACX;QACD,kEAAkE;QAClE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/C,OAAO,sBAAsB,OAAO,EAAE,CAAC;IACzC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAI,CAAC,OAAO,EAAE;QACZ,mFAAmF;QACnF,OAAO,CACL,6BACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAC,kEAAkE,KAClE,KAAK,GACT,CACH,CAAC;KACH;IAED,OAAO,CACL,6BACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,OAAO,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nexport const Maskicon = ({\n address,\n size = 32,\n className,\n ...props\n}: MaskiconProps) => {\n const [svgString, setSvgString] = useState('');\n\n useEffect(() => {\n let cancelled = false;\n // eslint-disable-next-line no-void\n void (async () => {\n const newSvg = await getMaskiconSVG(address, size);\n if (!cancelled) {\n setSvgString(newSvg);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [address, size]);\n\n const dataUri = useMemo(() => {\n if (!svgString) {\n return '';\n }\n // Normalize whitespace and encode the SVG for safe data URI usage\n const cleanedSvg = svgString.replace(/\\s+/gu, ' ').trim();\n const encoded = encodeURIComponent(cleanedSvg);\n return `data:image/svg+xml,${encoded}`;\n }, [svgString]);\n\n if (!dataUri) {\n // Return an img element with transparent placeholder to maintain consistent typing\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E\"\n {...props}\n />\n );\n }\n\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src={dataUri}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = ComponentProps<'
|
|
1
|
+
{"version":3,"file":"Maskicon.types.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {\n /**\n * Required address used as a unique identifier to generate the Maskicon.\n */\n address: string;\n /**\n * Optional prop to control the size of the Maskicon.\n * This will set both width and height.\n */\n size?: number;\n /**\n * Optional CSS class name to apply to the Maskicon.\n */\n className?: string;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
|
|
@@ -2,15 +2,20 @@ import type { ComponentProps } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* Maskicon component props.
|
|
4
4
|
*/
|
|
5
|
-
export type MaskiconProps = ComponentProps<'
|
|
5
|
+
export type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Required address used as a unique identifier to generate the Maskicon.
|
|
8
8
|
*/
|
|
9
9
|
address: string;
|
|
10
10
|
/**
|
|
11
11
|
* Optional prop to control the size of the Maskicon.
|
|
12
|
+
* This will set both width and height.
|
|
12
13
|
*/
|
|
13
14
|
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional CSS class name to apply to the Maskicon.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
14
19
|
/**
|
|
15
20
|
* Optional prop to add a test id to the icon
|
|
16
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"Maskicon.types.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IAC5E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -2,15 +2,20 @@ import type { ComponentProps } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* Maskicon component props.
|
|
4
4
|
*/
|
|
5
|
-
export type MaskiconProps = ComponentProps<'
|
|
5
|
+
export type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Required address used as a unique identifier to generate the Maskicon.
|
|
8
8
|
*/
|
|
9
9
|
address: string;
|
|
10
10
|
/**
|
|
11
11
|
* Optional prop to control the size of the Maskicon.
|
|
12
|
+
* This will set both width and height.
|
|
12
13
|
*/
|
|
13
14
|
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional CSS class name to apply to the Maskicon.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
14
19
|
/**
|
|
15
20
|
* Optional prop to add a test id to the icon
|
|
16
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"Maskicon.types.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IAC5E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = ComponentProps<'
|
|
1
|
+
{"version":3,"file":"Maskicon.types.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {\n /**\n * Required address used as a unique identifier to generate the Maskicon.\n */\n address: string;\n /**\n * Optional prop to control the size of the Maskicon.\n * This will set both width and height.\n */\n size?: number;\n /**\n * Optional CSS class name to apply to the Maskicon.\n */\n className?: string;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
|
|
@@ -1,78 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMaskiconSVG = exports.createMaskiconSVG = exports.seedToString = exports.sdbmHash =
|
|
4
|
-
const
|
|
5
|
-
const addresses_1 = require("@solana/addresses");
|
|
6
|
-
// /////////////////////////////////////////////////////
|
|
7
|
-
// Address validation
|
|
8
|
-
// /////////////////////////////////////////////////////
|
|
9
|
-
/**
|
|
10
|
-
* Generates a numeric seed for Ethereum (eip155) addresses.
|
|
11
|
-
*
|
|
12
|
-
* @param address The Ethereum address to generate a seed from
|
|
13
|
-
* @returns A numeric seed derived from the address
|
|
14
|
-
*/
|
|
15
|
-
function generateSeedEthereum(address) {
|
|
16
|
-
// Example: parse the first 8 chars of the address after '0x'
|
|
17
|
-
const addr = address.slice(2, 10);
|
|
18
|
-
return parseInt(addr, 16);
|
|
19
|
-
}
|
|
20
|
-
exports.generateSeedEthereum = generateSeedEthereum;
|
|
21
|
-
/**
|
|
22
|
-
* Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).
|
|
23
|
-
*
|
|
24
|
-
* @param address The non-Ethereum address to generate a seed from
|
|
25
|
-
* @returns An array of numbers representing the byte-array seed
|
|
26
|
-
*/
|
|
27
|
-
function generateSeedNonEthereum(address) {
|
|
28
|
-
return Array.from((0, utils_1.stringToBytes)(address.normalize('NFKC').toLowerCase()));
|
|
29
|
-
}
|
|
30
|
-
exports.generateSeedNonEthereum = generateSeedNonEthereum;
|
|
31
|
-
/**
|
|
32
|
-
* Dynamically checks if the address is Bitcoin or Solana; otherwise defaults to Ethereum.
|
|
33
|
-
* Returns a Promise that resolves to one of the known CAIP-2 namespaces.
|
|
34
|
-
*
|
|
35
|
-
* In this update, if the address starts with "0x", we'll assume it's Ethereum (Eip155)
|
|
36
|
-
* and avoid the dynamic import that can cause the "Requiring unknown module '2021'" error.
|
|
37
|
-
*
|
|
38
|
-
* @param address The address to check and determine its namespace
|
|
39
|
-
* @returns A promise that resolves to the detected CAIP-2 namespace
|
|
40
|
-
*/
|
|
41
|
-
async function getCaipNamespaceFromAddress(address) {
|
|
42
|
-
// If the address starts with '0x', assume Ethereum.
|
|
43
|
-
if (address.startsWith('0x')) {
|
|
44
|
-
return utils_1.KnownCaipNamespace.Eip155;
|
|
45
|
-
}
|
|
46
|
-
// Check for CAIP-10 formatted addresses
|
|
47
|
-
if (address.includes(':')) {
|
|
48
|
-
const [namespace] = address.split(':');
|
|
49
|
-
const nsLower = namespace.toLowerCase();
|
|
50
|
-
if (nsLower === 'bip122') {
|
|
51
|
-
return utils_1.KnownCaipNamespace.Bip122;
|
|
52
|
-
}
|
|
53
|
-
if (nsLower === 'solana') {
|
|
54
|
-
return utils_1.KnownCaipNamespace.Solana;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Attempt to use bitcoin-address-validation if available.
|
|
58
|
-
try {
|
|
59
|
-
const { validate, Network } = await import("bitcoin-address-validation");
|
|
60
|
-
if (validate(address, Network.mainnet) ||
|
|
61
|
-
validate(address, Network.testnet)) {
|
|
62
|
-
return utils_1.KnownCaipNamespace.Bip122;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
// If the import fails, fall through.
|
|
67
|
-
}
|
|
68
|
-
// Fallback: if it looks like a Solana address, return Solana.
|
|
69
|
-
if ((0, addresses_1.isAddress)(address)) {
|
|
70
|
-
return utils_1.KnownCaipNamespace.Solana;
|
|
71
|
-
}
|
|
72
|
-
// Default to Ethereum.
|
|
73
|
-
return utils_1.KnownCaipNamespace.Eip155;
|
|
74
|
-
}
|
|
75
|
-
exports.getCaipNamespaceFromAddress = getCaipNamespaceFromAddress;
|
|
3
|
+
exports.getMaskiconSVG = exports.createMaskiconSVG = exports.seedToString = exports.sdbmHash = void 0;
|
|
4
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
76
5
|
// /////////////////////////////////////////////////////
|
|
77
6
|
// Maskicon SVG Creation
|
|
78
7
|
// /////////////////////////////////////////////////////
|
|
@@ -266,14 +195,10 @@ async function getMaskiconSVG(address, size) {
|
|
|
266
195
|
if (svgCache[cacheKey]) {
|
|
267
196
|
return svgCache[cacheKey];
|
|
268
197
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
seed = generateSeedNonEthereum(address);
|
|
276
|
-
}
|
|
198
|
+
// Extract the account address from CAIP-10 format if needed
|
|
199
|
+
const accountAddress = (0, design_system_shared_1.extractAccountAddress)(address);
|
|
200
|
+
// Generate appropriate seed based on address format
|
|
201
|
+
const seed = (0, design_system_shared_1.generateIconSeed)(accountAddress);
|
|
277
202
|
const svgString = createMaskiconSVG(seed, size);
|
|
278
203
|
svgCache[cacheKey] = svgString;
|
|
279
204
|
return svgString;
|