@metamask-previews/design-system-react 0.3.1-preview.c4d6431 → 0.5.0-preview.01a59b9
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 +30 -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/Box/Box.cjs +4 -2
- package/dist/components/Box/Box.cjs.map +1 -1
- package/dist/components/Box/Box.d.cts.map +1 -1
- package/dist/components/Box/Box.d.mts.map +1 -1
- package/dist/components/Box/Box.mjs +4 -2
- package/dist/components/Box/Box.mjs.map +1 -1
- package/dist/components/Box/Box.types.cjs.map +1 -1
- package/dist/components/Box/Box.types.d.cts +7 -0
- package/dist/components/Box/Box.types.d.cts.map +1 -1
- package/dist/components/Box/Box.types.d.mts +7 -0
- package/dist/components/Box/Box.types.d.mts.map +1 -1
- package/dist/components/Box/Box.types.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/Text/Text.types.cjs.map +1 -1
- package/dist/components/Text/Text.types.d.cts +1 -1
- package/dist/components/Text/Text.types.d.mts +1 -1
- package/dist/components/Text/Text.types.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.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 +2 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +2 -1
- package/dist/types/index.mjs.map +1 -1
- package/package.json +7 -11
- 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
- package/dist/types/make-props-optional.cjs +0 -3
- package/dist/types/make-props-optional.cjs.map +0 -1
- package/dist/types/make-props-optional.d.cts +0 -4
- package/dist/types/make-props-optional.d.cts.map +0 -1
- package/dist/types/make-props-optional.d.mts +0 -4
- package/dist/types/make-props-optional.d.mts.map +0 -1
- package/dist/types/make-props-optional.mjs +0 -2
- package/dist/types/make-props-optional.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/design-system-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-preview.01a59b9",
|
|
4
4
|
"description": "Design system react ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@metamask-previews/design-system-shared": "0.1.1-preview.01a59b9",
|
|
53
54
|
"@metamask/jazzicon": "^2.0.0",
|
|
54
55
|
"@radix-ui/react-slot": "^1.1.0",
|
|
55
56
|
"blo": "^2.0.0",
|
|
@@ -58,10 +59,9 @@
|
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@figma/code-connect": "^1.0.0",
|
|
60
61
|
"@jest/globals": "^29.7.0",
|
|
61
|
-
"@metamask-previews/design-system-tailwind-preset": "0.6.1-preview.
|
|
62
|
-
"@metamask/auto-changelog": "^5.0
|
|
63
|
-
"@metamask/utils": "^11.
|
|
64
|
-
"@solana/addresses": "^2.0.0",
|
|
62
|
+
"@metamask-previews/design-system-tailwind-preset": "0.6.1-preview.01a59b9",
|
|
63
|
+
"@metamask/auto-changelog": "^5.1.0",
|
|
64
|
+
"@metamask/utils": "^11.8.1",
|
|
65
65
|
"@storybook/react": "^9.0.17",
|
|
66
66
|
"@svgr/cli": "^8.1.0",
|
|
67
67
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"@types/node": "^16.18.54",
|
|
72
72
|
"@types/react": "^18.2.0",
|
|
73
73
|
"@types/react-dom": "^18.2.0",
|
|
74
|
-
"bitcoin-address-validation": ">=2.0.0",
|
|
75
74
|
"deepmerge": "^4.2.2",
|
|
76
75
|
"jest": "^29.7.0",
|
|
77
76
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -83,12 +82,9 @@
|
|
|
83
82
|
"peerDependencies": {
|
|
84
83
|
"@metamask/design-system-tailwind-preset": "^0.6.0",
|
|
85
84
|
"@metamask/design-tokens": "^8.1.0",
|
|
86
|
-
"@metamask/utils": "^11.
|
|
87
|
-
"@solana/addresses": "^2.0.0",
|
|
88
|
-
"bitcoin-address-validation": ">=2.0.0",
|
|
85
|
+
"@metamask/utils": "^11.8.1",
|
|
89
86
|
"react": "^17.0.0 || ^18.0.0",
|
|
90
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
91
|
-
"tailwindcss": "^3.0.0"
|
|
87
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
92
88
|
},
|
|
93
89
|
"engines": {
|
|
94
90
|
"node": "^18.18 || >=20"
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCaipNamespaceFromAddress = exports.generateSeedNonEthereum = exports.generateSeedEthereum = void 0;
|
|
4
|
-
const utils_1 = require("@metamask/utils");
|
|
5
|
-
const addresses_1 = require("@solana/addresses");
|
|
6
|
-
/**
|
|
7
|
-
* Generates a numeric seed for Ethereum (eip155) addresses.
|
|
8
|
-
*
|
|
9
|
-
* @param address - The Ethereum address to generate a seed from
|
|
10
|
-
* @returns A numeric seed for jazzicon generation
|
|
11
|
-
*/
|
|
12
|
-
function generateSeedEthereum(address) {
|
|
13
|
-
// Example: parse the first 8 chars of the address after '0x'
|
|
14
|
-
const addr = address.slice(2, 10);
|
|
15
|
-
return parseInt(addr, 16);
|
|
16
|
-
}
|
|
17
|
-
exports.generateSeedEthereum = generateSeedEthereum;
|
|
18
|
-
/**
|
|
19
|
-
* Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).
|
|
20
|
-
*
|
|
21
|
-
* @param address - The address to generate a byte array seed from
|
|
22
|
-
* @returns An array of numbers representing the bytes of the address
|
|
23
|
-
*/
|
|
24
|
-
function generateSeedNonEthereum(address) {
|
|
25
|
-
return Array.from((0, utils_1.stringToBytes)(address.normalize('NFKC').toLowerCase()));
|
|
26
|
-
}
|
|
27
|
-
exports.generateSeedNonEthereum = generateSeedNonEthereum;
|
|
28
|
-
/**
|
|
29
|
-
* Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.
|
|
30
|
-
* Returns a Promise that resolves to one of the known CAIP-2 namespaces.
|
|
31
|
-
*
|
|
32
|
-
* @param address - The address to determine the CAIP namespace for
|
|
33
|
-
* @returns A Promise that resolves to a KnownCaipNamespace
|
|
34
|
-
*/
|
|
35
|
-
async function getCaipNamespaceFromAddress(address) {
|
|
36
|
-
// Check for CAIP-10 formatted addresses
|
|
37
|
-
if (address.includes(':')) {
|
|
38
|
-
const [namespace] = address.split(':');
|
|
39
|
-
if (namespace.toLowerCase() === 'bip122') {
|
|
40
|
-
return utils_1.KnownCaipNamespace.Bip122;
|
|
41
|
-
}
|
|
42
|
-
if (namespace.toLowerCase() === 'solana') {
|
|
43
|
-
return utils_1.KnownCaipNamespace.Solana;
|
|
44
|
-
}
|
|
45
|
-
if (namespace.toLowerCase() === 'eip155') {
|
|
46
|
-
return utils_1.KnownCaipNamespace.Eip155;
|
|
47
|
-
}
|
|
48
|
-
// Add other namespaces as needed.
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const { validate, Network } = await import("bitcoin-address-validation");
|
|
52
|
-
if (validate(address, Network.mainnet) ||
|
|
53
|
-
validate(address, Network.testnet)) {
|
|
54
|
-
return utils_1.KnownCaipNamespace.Bip122;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// If the import fails or 'validate' is not available, fall through
|
|
59
|
-
}
|
|
60
|
-
if ((0, addresses_1.isAddress)(address)) {
|
|
61
|
-
return utils_1.KnownCaipNamespace.Solana;
|
|
62
|
-
}
|
|
63
|
-
// Default to Ethereum
|
|
64
|
-
return utils_1.KnownCaipNamespace.Eip155;
|
|
65
|
-
}
|
|
66
|
-
exports.getCaipNamespaceFromAddress = getCaipNamespaceFromAddress;
|
|
67
|
-
//# sourceMappingURL=Jazzicon.utilities.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.utilities.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.utilities.ts"],"names":[],"mappings":";;;AAAA,2CAAoE;AACpE,iDAAiE;AAEjE;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,6DAA6D;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAJD,oDAIC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5E,CAAC;AAFD,0DAEC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,2BAA2B,CAC/C,OAAe;IAEf,wCAAwC;IACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,0BAAkB,CAAC,MAAM,CAAC;SAClC;QACD,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,0BAAkB,CAAC,MAAM,CAAC;SAClC;QACD,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,0BAAkB,CAAC,MAAM,CAAC;SAClC;QACD,kCAAkC;KACnC;IAED,IAAI;QACF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,8BAA8B,CAAC;QACzE,IACE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;YAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAClC;YACA,OAAO,0BAAkB,CAAC,MAAM,CAAC;SAClC;KACF;IAAC,MAAM;QACN,mEAAmE;KACpE;IAED,IAAI,IAAA,qBAAe,EAAC,OAAO,CAAC,EAAE;QAC5B,OAAO,0BAAkB,CAAC,MAAM,CAAC;KAClC;IAED,sBAAsB;IACtB,OAAO,0BAAkB,CAAC,MAAM,CAAC;AACnC,CAAC;AApCD,kEAoCC","sourcesContent":["import { stringToBytes, KnownCaipNamespace } from '@metamask/utils';\nimport { isAddress as isSolanaAddress } from '@solana/addresses';\n\n/**\n * Generates a numeric seed for Ethereum (eip155) addresses.\n *\n * @param address - The Ethereum address to generate a seed from\n * @returns A numeric seed for jazzicon generation\n */\nexport function generateSeedEthereum(address: string): number {\n // Example: parse the first 8 chars of the address after '0x'\n const addr = address.slice(2, 10);\n return parseInt(addr, 16);\n}\n\n/**\n * Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).\n *\n * @param address - The address to generate a byte array seed from\n * @returns An array of numbers representing the bytes of the address\n */\nexport function generateSeedNonEthereum(address: string): number[] {\n return Array.from(stringToBytes(address.normalize('NFKC').toLowerCase()));\n}\n\n/**\n * Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.\n * Returns a Promise that resolves to one of the known CAIP-2 namespaces.\n *\n * @param address - The address to determine the CAIP namespace for\n * @returns A Promise that resolves to a KnownCaipNamespace\n */\nexport async function getCaipNamespaceFromAddress(\n address: string,\n): Promise<KnownCaipNamespace> {\n // Check for CAIP-10 formatted addresses\n if (address.includes(':')) {\n const [namespace] = address.split(':');\n if (namespace.toLowerCase() === 'bip122') {\n return KnownCaipNamespace.Bip122;\n }\n if (namespace.toLowerCase() === 'solana') {\n return KnownCaipNamespace.Solana;\n }\n if (namespace.toLowerCase() === 'eip155') {\n return KnownCaipNamespace.Eip155;\n }\n // Add other namespaces as needed.\n }\n\n try {\n const { validate, Network } = await import('bitcoin-address-validation');\n if (\n validate(address, Network.mainnet) ||\n validate(address, Network.testnet)\n ) {\n return KnownCaipNamespace.Bip122;\n }\n } catch {\n // If the import fails or 'validate' is not available, fall through\n }\n\n if (isSolanaAddress(address)) {\n return KnownCaipNamespace.Solana;\n }\n\n // Default to Ethereum\n return KnownCaipNamespace.Eip155;\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { KnownCaipNamespace } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Generates a numeric seed for Ethereum (eip155) addresses.
|
|
4
|
-
*
|
|
5
|
-
* @param address - The Ethereum address to generate a seed from
|
|
6
|
-
* @returns A numeric seed for jazzicon generation
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateSeedEthereum(address: string): number;
|
|
9
|
-
/**
|
|
10
|
-
* Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).
|
|
11
|
-
*
|
|
12
|
-
* @param address - The address to generate a byte array seed from
|
|
13
|
-
* @returns An array of numbers representing the bytes of the address
|
|
14
|
-
*/
|
|
15
|
-
export declare function generateSeedNonEthereum(address: string): number[];
|
|
16
|
-
/**
|
|
17
|
-
* Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.
|
|
18
|
-
* Returns a Promise that resolves to one of the known CAIP-2 namespaces.
|
|
19
|
-
*
|
|
20
|
-
* @param address - The address to determine the CAIP namespace for
|
|
21
|
-
* @returns A Promise that resolves to a KnownCaipNamespace
|
|
22
|
-
*/
|
|
23
|
-
export declare function getCaipNamespaceFromAddress(address: string): Promise<KnownCaipNamespace>;
|
|
24
|
-
//# sourceMappingURL=Jazzicon.utilities.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.utilities.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAE,wBAAwB;AAGpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAkC7B"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { KnownCaipNamespace } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Generates a numeric seed for Ethereum (eip155) addresses.
|
|
4
|
-
*
|
|
5
|
-
* @param address - The Ethereum address to generate a seed from
|
|
6
|
-
* @returns A numeric seed for jazzicon generation
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateSeedEthereum(address: string): number;
|
|
9
|
-
/**
|
|
10
|
-
* Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).
|
|
11
|
-
*
|
|
12
|
-
* @param address - The address to generate a byte array seed from
|
|
13
|
-
* @returns An array of numbers representing the bytes of the address
|
|
14
|
-
*/
|
|
15
|
-
export declare function generateSeedNonEthereum(address: string): number[];
|
|
16
|
-
/**
|
|
17
|
-
* Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.
|
|
18
|
-
* Returns a Promise that resolves to one of the known CAIP-2 namespaces.
|
|
19
|
-
*
|
|
20
|
-
* @param address - The address to determine the CAIP namespace for
|
|
21
|
-
* @returns A Promise that resolves to a KnownCaipNamespace
|
|
22
|
-
*/
|
|
23
|
-
export declare function getCaipNamespaceFromAddress(address: string): Promise<KnownCaipNamespace>;
|
|
24
|
-
//# sourceMappingURL=Jazzicon.utilities.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.utilities.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAE,wBAAwB;AAGpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAkC7B"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { stringToBytes, KnownCaipNamespace } from "@metamask/utils";
|
|
2
|
-
import { isAddress as isSolanaAddress } from "@solana/addresses";
|
|
3
|
-
/**
|
|
4
|
-
* Generates a numeric seed for Ethereum (eip155) addresses.
|
|
5
|
-
*
|
|
6
|
-
* @param address - The Ethereum address to generate a seed from
|
|
7
|
-
* @returns A numeric seed for jazzicon generation
|
|
8
|
-
*/
|
|
9
|
-
export function generateSeedEthereum(address) {
|
|
10
|
-
// Example: parse the first 8 chars of the address after '0x'
|
|
11
|
-
const addr = address.slice(2, 10);
|
|
12
|
-
return parseInt(addr, 16);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).
|
|
16
|
-
*
|
|
17
|
-
* @param address - The address to generate a byte array seed from
|
|
18
|
-
* @returns An array of numbers representing the bytes of the address
|
|
19
|
-
*/
|
|
20
|
-
export function generateSeedNonEthereum(address) {
|
|
21
|
-
return Array.from(stringToBytes(address.normalize('NFKC').toLowerCase()));
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.
|
|
25
|
-
* Returns a Promise that resolves to one of the known CAIP-2 namespaces.
|
|
26
|
-
*
|
|
27
|
-
* @param address - The address to determine the CAIP namespace for
|
|
28
|
-
* @returns A Promise that resolves to a KnownCaipNamespace
|
|
29
|
-
*/
|
|
30
|
-
export async function getCaipNamespaceFromAddress(address) {
|
|
31
|
-
// Check for CAIP-10 formatted addresses
|
|
32
|
-
if (address.includes(':')) {
|
|
33
|
-
const [namespace] = address.split(':');
|
|
34
|
-
if (namespace.toLowerCase() === 'bip122') {
|
|
35
|
-
return KnownCaipNamespace.Bip122;
|
|
36
|
-
}
|
|
37
|
-
if (namespace.toLowerCase() === 'solana') {
|
|
38
|
-
return KnownCaipNamespace.Solana;
|
|
39
|
-
}
|
|
40
|
-
if (namespace.toLowerCase() === 'eip155') {
|
|
41
|
-
return KnownCaipNamespace.Eip155;
|
|
42
|
-
}
|
|
43
|
-
// Add other namespaces as needed.
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const { validate, Network } = await import("bitcoin-address-validation");
|
|
47
|
-
if (validate(address, Network.mainnet) ||
|
|
48
|
-
validate(address, Network.testnet)) {
|
|
49
|
-
return KnownCaipNamespace.Bip122;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// If the import fails or 'validate' is not available, fall through
|
|
54
|
-
}
|
|
55
|
-
if (isSolanaAddress(address)) {
|
|
56
|
-
return KnownCaipNamespace.Solana;
|
|
57
|
-
}
|
|
58
|
-
// Default to Ethereum
|
|
59
|
-
return KnownCaipNamespace.Eip155;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=Jazzicon.utilities.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.utilities.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,wBAAwB;AACpE,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,0BAA0B;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,6DAA6D;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAe;IAEf,wCAAwC;IACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,kBAAkB,CAAC,MAAM,CAAC;SAClC;QACD,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,kBAAkB,CAAC,MAAM,CAAC;SAClC;QACD,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YACxC,OAAO,kBAAkB,CAAC,MAAM,CAAC;SAClC;QACD,kCAAkC;KACnC;IAED,IAAI;QACF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,8BAA8B,CAAC;QACzE,IACE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;YAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAClC;YACA,OAAO,kBAAkB,CAAC,MAAM,CAAC;SAClC;KACF;IAAC,MAAM;QACN,mEAAmE;KACpE;IAED,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE;QAC5B,OAAO,kBAAkB,CAAC,MAAM,CAAC;KAClC;IAED,sBAAsB;IACtB,OAAO,kBAAkB,CAAC,MAAM,CAAC;AACnC,CAAC","sourcesContent":["import { stringToBytes, KnownCaipNamespace } from '@metamask/utils';\nimport { isAddress as isSolanaAddress } from '@solana/addresses';\n\n/**\n * Generates a numeric seed for Ethereum (eip155) addresses.\n *\n * @param address - The Ethereum address to generate a seed from\n * @returns A numeric seed for jazzicon generation\n */\nexport function generateSeedEthereum(address: string): number {\n // Example: parse the first 8 chars of the address after '0x'\n const addr = address.slice(2, 10);\n return parseInt(addr, 16);\n}\n\n/**\n * Generates a byte-array seed for non-Ethereum addresses (Solana, Bitcoin, etc.).\n *\n * @param address - The address to generate a byte array seed from\n * @returns An array of numbers representing the bytes of the address\n */\nexport function generateSeedNonEthereum(address: string): number[] {\n return Array.from(stringToBytes(address.normalize('NFKC').toLowerCase()));\n}\n\n/**\n * Dynamically checks if the address is Bitcoin or Solana; otherwise default to Ethereum.\n * Returns a Promise that resolves to one of the known CAIP-2 namespaces.\n *\n * @param address - The address to determine the CAIP namespace for\n * @returns A Promise that resolves to a KnownCaipNamespace\n */\nexport async function getCaipNamespaceFromAddress(\n address: string,\n): Promise<KnownCaipNamespace> {\n // Check for CAIP-10 formatted addresses\n if (address.includes(':')) {\n const [namespace] = address.split(':');\n if (namespace.toLowerCase() === 'bip122') {\n return KnownCaipNamespace.Bip122;\n }\n if (namespace.toLowerCase() === 'solana') {\n return KnownCaipNamespace.Solana;\n }\n if (namespace.toLowerCase() === 'eip155') {\n return KnownCaipNamespace.Eip155;\n }\n // Add other namespaces as needed.\n }\n\n try {\n const { validate, Network } = await import('bitcoin-address-validation');\n if (\n validate(address, Network.mainnet) ||\n validate(address, Network.testnet)\n ) {\n return KnownCaipNamespace.Bip122;\n }\n } catch {\n // If the import fails or 'validate' is not available, fall through\n }\n\n if (isSolanaAddress(address)) {\n return KnownCaipNamespace.Solana;\n }\n\n // Default to Ethereum\n return KnownCaipNamespace.Eip155;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-props-optional.cjs","sourceRoot":"","sources":["../../src/types/make-props-optional.ts"],"names":[],"mappings":"","sourcesContent":["export type MakePropsOptional<Props> = {\n [K in keyof Props]?: Props[K];\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-props-optional.d.cts","sourceRoot":"","sources":["../../src/types/make-props-optional.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAAI;KACpC,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-props-optional.d.mts","sourceRoot":"","sources":["../../src/types/make-props-optional.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAAI;KACpC,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-props-optional.mjs","sourceRoot":"","sources":["../../src/types/make-props-optional.ts"],"names":[],"mappings":"","sourcesContent":["export type MakePropsOptional<Props> = {\n [K in keyof Props]?: Props[K];\n};\n"]}
|