@metamask-previews/design-system-react 0.3.0-preview.022dda1 → 0.3.1-preview.374d60e
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 +9 -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/package.json +5 -5
- 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
|
@@ -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"]}
|