@metamask-previews/utils 11.12.1-preview-9962b7e
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 +584 -0
- package/LICENSE +15 -0
- package/README.md +106 -0
- package/dist/assert.d.ts +61 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +115 -0
- package/dist/assert.js.map +1 -0
- package/dist/base64.d.ts +25 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +30 -0
- package/dist/base64.js.map +1 -0
- package/dist/bytes.d.ts +198 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +406 -0
- package/dist/bytes.js.map +1 -0
- package/dist/caip-types.d.ts +294 -0
- package/dist/caip-types.d.ts.map +1 -0
- package/dist/caip-types.js +369 -0
- package/dist/caip-types.js.map +1 -0
- package/dist/checksum.d.ts +2 -0
- package/dist/checksum.d.ts.map +1 -0
- package/dist/checksum.js +4 -0
- package/dist/checksum.js.map +1 -0
- package/dist/coercers.d.ts +97 -0
- package/dist/coercers.d.ts.map +1 -0
- package/dist/coercers.js +159 -0
- package/dist/coercers.js.map +1 -0
- package/dist/collections.d.ts +39 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +105 -0
- package/dist/collections.js.map +1 -0
- package/dist/encryption-types.d.ts +7 -0
- package/dist/encryption-types.d.ts.map +1 -0
- package/dist/encryption-types.js +2 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +121 -0
- package/dist/errors.js.map +1 -0
- package/dist/fs.d.ts +133 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +210 -0
- package/dist/fs.js.map +1 -0
- package/dist/hashing.d.ts +28 -0
- package/dist/hashing.d.ts.map +1 -0
- package/dist/hashing.js +59 -0
- package/dist/hashing.js.map +1 -0
- package/dist/hex.d.ts +117 -0
- package/dist/hex.d.ts.map +1 -0
- package/dist/hex.js +174 -0
- package/dist/hex.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +398 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +402 -0
- package/dist/json.js.map +1 -0
- package/dist/keyring.d.ts +243 -0
- package/dist/keyring.d.ts.map +1 -0
- package/dist/keyring.js +2 -0
- package/dist/keyring.js.map +1 -0
- package/dist/logging.d.ts +30 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +35 -0
- package/dist/logging.js.map +1 -0
- package/dist/misc.d.ts +127 -0
- package/dist/misc.d.ts.map +1 -0
- package/dist/misc.js +142 -0
- package/dist/misc.js.map +1 -0
- package/dist/mnemonic.d.ts +14 -0
- package/dist/mnemonic.d.ts.map +1 -0
- package/dist/mnemonic.js +25 -0
- package/dist/mnemonic.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/number.d.ts +74 -0
- package/dist/number.d.ts.map +1 -0
- package/dist/number.js +95 -0
- package/dist/number.js.map +1 -0
- package/dist/opaque.d.ts +6 -0
- package/dist/opaque.d.ts.map +1 -0
- package/dist/opaque.js +2 -0
- package/dist/opaque.js.map +1 -0
- package/dist/promise.d.ts +45 -0
- package/dist/promise.d.ts.map +1 -0
- package/dist/promise.js +40 -0
- package/dist/promise.js.map +1 -0
- package/dist/superstruct.d.ts +20 -0
- package/dist/superstruct.d.ts.map +1 -0
- package/dist/superstruct.js +24 -0
- package/dist/superstruct.js.map +1 -0
- package/dist/time.d.ts +49 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +62 -0
- package/dist/time.js.map +1 -0
- package/dist/transaction-types.d.ts +117 -0
- package/dist/transaction-types.d.ts.map +1 -0
- package/dist/transaction-types.js +2 -0
- package/dist/transaction-types.js.map +1 -0
- package/dist/unitsConversion.d.ts +80 -0
- package/dist/unitsConversion.d.ts.map +1 -0
- package/dist/unitsConversion.js +209 -0
- package/dist/unitsConversion.js.map +1 -0
- package/dist/versions.d.ts +101 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +85 -0
- package/dist/versions.js.map +1 -0
- package/package.json +122 -0
package/dist/hex.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Struct } from '@metamask/superstruct';
|
|
2
|
+
export type Hex = `0x${string}`;
|
|
3
|
+
export declare const HexStruct: Struct<string, null>;
|
|
4
|
+
export declare const StrictHexStruct: Struct<Hex, null>;
|
|
5
|
+
export declare const HexAddressStruct: Struct<Hex, null>;
|
|
6
|
+
export declare const HexChecksumAddressStruct: Struct<Hex, null>;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a string is a valid hex string.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The value to check.
|
|
11
|
+
* @returns Whether the value is a valid hex string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isHexString(value: unknown): value is string;
|
|
14
|
+
/**
|
|
15
|
+
* Strictly check if a string is a valid hex string. A valid hex string must
|
|
16
|
+
* start with the "0x"-prefix.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to check.
|
|
19
|
+
* @returns Whether the value is a valid hex string.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isStrictHexString(value: unknown): value is Hex;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a string is a valid hex address.
|
|
24
|
+
*
|
|
25
|
+
* @param value - The value to check.
|
|
26
|
+
* @returns Whether the value is a valid hex address.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isHexAddress(value: unknown): value is Hex;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a string is a valid hex checksum address.
|
|
31
|
+
*
|
|
32
|
+
* @param value - The value to check.
|
|
33
|
+
* @returns Whether the value is a valid hex checksum address.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isHexChecksumAddress(value: unknown): value is Hex;
|
|
36
|
+
/**
|
|
37
|
+
* Assert that a value is a valid hex string.
|
|
38
|
+
*
|
|
39
|
+
* @param value - The value to check.
|
|
40
|
+
* @throws If the value is not a valid hex string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function assertIsHexString(value: unknown): asserts value is string;
|
|
43
|
+
/**
|
|
44
|
+
* Assert that a value is a valid hex string. A valid hex string must start with
|
|
45
|
+
* the "0x"-prefix.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to check.
|
|
48
|
+
* @throws If the value is not a valid hex string.
|
|
49
|
+
*/
|
|
50
|
+
export declare function assertIsStrictHexString(value: unknown): asserts value is Hex;
|
|
51
|
+
/**
|
|
52
|
+
* Encode a passed hex string as an ERC-55 mixed-case checksum address.
|
|
53
|
+
* This is the unmemoized version, primarily used for testing.
|
|
54
|
+
*
|
|
55
|
+
* @param hexAddress - The hex address to encode.
|
|
56
|
+
* @returns The address encoded according to ERC-55.
|
|
57
|
+
* @see https://eips.ethereum.org/EIPS/eip-55
|
|
58
|
+
*/
|
|
59
|
+
export declare function getChecksumAddressUnmemoized(hexAddress: Hex): Hex;
|
|
60
|
+
/**
|
|
61
|
+
* Encode a passed hex string as an ERC-55 mixed-case checksum address.
|
|
62
|
+
* This function is memoized for performance.
|
|
63
|
+
*
|
|
64
|
+
* @param hexAddress - The hex address to encode.
|
|
65
|
+
* @returns The address encoded according to ERC-55.
|
|
66
|
+
* @see https://eips.ethereum.org/EIPS/eip-55
|
|
67
|
+
*/
|
|
68
|
+
export declare const getChecksumAddress: typeof getChecksumAddressUnmemoized & import("lodash").MemoizedFunction;
|
|
69
|
+
/**
|
|
70
|
+
* Validate that the passed hex string is a valid ERC-55 mixed-case
|
|
71
|
+
* checksum address.
|
|
72
|
+
*
|
|
73
|
+
* @param possibleChecksum - The hex address to check.
|
|
74
|
+
* @returns True if the address is a checksum address.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isValidChecksumAddressUnmemoized(possibleChecksum: Hex): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Validate that the passed hex string is a valid ERC-55 mixed-case
|
|
79
|
+
* checksum address.
|
|
80
|
+
*
|
|
81
|
+
* @param possibleChecksum - The hex address to check.
|
|
82
|
+
* @returns True if the address is a checksum address.
|
|
83
|
+
*/
|
|
84
|
+
export declare const isValidChecksumAddress: typeof isValidChecksumAddressUnmemoized & import("lodash").MemoizedFunction;
|
|
85
|
+
/**
|
|
86
|
+
* Validate that the passed prefixed hex string is an all-lowercase
|
|
87
|
+
* hex address, or a valid mixed-case checksum address.
|
|
88
|
+
*
|
|
89
|
+
* @param possibleAddress - Input parameter to check against.
|
|
90
|
+
* @returns Whether or not the input is a valid hex address.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isValidHexAddressUnmemoized(possibleAddress: Hex): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Validate that the passed prefixed hex string is an all-lowercase
|
|
95
|
+
* hex address, or a valid mixed-case checksum address.
|
|
96
|
+
*
|
|
97
|
+
* @param possibleAddress - Input parameter to check against.
|
|
98
|
+
* @returns Whether or not the input is a valid hex address.
|
|
99
|
+
*/
|
|
100
|
+
export declare const isValidHexAddress: typeof isValidHexAddressUnmemoized & import("lodash").MemoizedFunction;
|
|
101
|
+
/**
|
|
102
|
+
* Add the `0x`-prefix to a hexadecimal string. If the string already has the
|
|
103
|
+
* prefix, it is returned as-is.
|
|
104
|
+
*
|
|
105
|
+
* @param hexadecimal - The hexadecimal string to add the prefix to.
|
|
106
|
+
* @returns The prefixed hexadecimal string.
|
|
107
|
+
*/
|
|
108
|
+
export declare function add0x(hexadecimal: string): Hex;
|
|
109
|
+
/**
|
|
110
|
+
* Remove the `0x`-prefix from a hexadecimal string. If the string doesn't have
|
|
111
|
+
* the prefix, it is returned as-is.
|
|
112
|
+
*
|
|
113
|
+
* @param hexadecimal - The hexadecimal string to remove the prefix from.
|
|
114
|
+
* @returns The un-prefixed hexadecimal string.
|
|
115
|
+
*/
|
|
116
|
+
export declare function remove0x(hex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,CAAC;AAExE;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,gBAAgB,EAAE,GAAG,WAMrE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,6EAA4C,CAAC;AAEhF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,GAAG,WAI/D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,wEAAuC,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAU9C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMpD"}
|
package/dist/hex.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { pattern, string } from '@metamask/superstruct';
|
|
2
|
+
import { keccak_256 as keccak256 } from '@noble/hashes/sha3';
|
|
3
|
+
import memoize from 'lodash/memoize.js';
|
|
4
|
+
import { assert } from './assert.js';
|
|
5
|
+
// Use native regexes instead of superstruct for maximum performance.
|
|
6
|
+
// Pre-compiled regex for maximum performance - avoids recompilation on each call
|
|
7
|
+
const HEX_REGEX = /^(?:0x)?[0-9a-f]+$/iu;
|
|
8
|
+
const STRICT_HEX_REGEX = /^0x[0-9a-f]+$/iu;
|
|
9
|
+
const HEX_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/u;
|
|
10
|
+
const HEX_CHECKSUM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/u;
|
|
11
|
+
export const HexStruct = pattern(string(), HEX_REGEX);
|
|
12
|
+
export const StrictHexStruct = pattern(string(), STRICT_HEX_REGEX);
|
|
13
|
+
export const HexAddressStruct = pattern(string(), HEX_ADDRESS_REGEX);
|
|
14
|
+
export const HexChecksumAddressStruct = pattern(string(), HEX_CHECKSUM_ADDRESS_REGEX);
|
|
15
|
+
const isString = (value) => typeof value === 'string';
|
|
16
|
+
/**
|
|
17
|
+
* Check if a string is a valid hex string.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to check.
|
|
20
|
+
* @returns Whether the value is a valid hex string.
|
|
21
|
+
*/
|
|
22
|
+
export function isHexString(value) {
|
|
23
|
+
return isString(value) && HEX_REGEX.test(value);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Strictly check if a string is a valid hex string. A valid hex string must
|
|
27
|
+
* start with the "0x"-prefix.
|
|
28
|
+
*
|
|
29
|
+
* @param value - The value to check.
|
|
30
|
+
* @returns Whether the value is a valid hex string.
|
|
31
|
+
*/
|
|
32
|
+
export function isStrictHexString(value) {
|
|
33
|
+
return isString(value) && STRICT_HEX_REGEX.test(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if a string is a valid hex address.
|
|
37
|
+
*
|
|
38
|
+
* @param value - The value to check.
|
|
39
|
+
* @returns Whether the value is a valid hex address.
|
|
40
|
+
*/
|
|
41
|
+
export function isHexAddress(value) {
|
|
42
|
+
return isString(value) && HEX_ADDRESS_REGEX.test(value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a string is a valid hex checksum address.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to check.
|
|
48
|
+
* @returns Whether the value is a valid hex checksum address.
|
|
49
|
+
*/
|
|
50
|
+
export function isHexChecksumAddress(value) {
|
|
51
|
+
return isString(value) && HEX_CHECKSUM_ADDRESS_REGEX.test(value);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Assert that a value is a valid hex string.
|
|
55
|
+
*
|
|
56
|
+
* @param value - The value to check.
|
|
57
|
+
* @throws If the value is not a valid hex string.
|
|
58
|
+
*/
|
|
59
|
+
export function assertIsHexString(value) {
|
|
60
|
+
assert(isHexString(value), 'Value must be a hexadecimal string.');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Assert that a value is a valid hex string. A valid hex string must start with
|
|
64
|
+
* the "0x"-prefix.
|
|
65
|
+
*
|
|
66
|
+
* @param value - The value to check.
|
|
67
|
+
* @throws If the value is not a valid hex string.
|
|
68
|
+
*/
|
|
69
|
+
export function assertIsStrictHexString(value) {
|
|
70
|
+
assert(isStrictHexString(value), 'Value must be a hexadecimal string, starting with "0x".');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Encode a passed hex string as an ERC-55 mixed-case checksum address.
|
|
74
|
+
* This is the unmemoized version, primarily used for testing.
|
|
75
|
+
*
|
|
76
|
+
* @param hexAddress - The hex address to encode.
|
|
77
|
+
* @returns The address encoded according to ERC-55.
|
|
78
|
+
* @see https://eips.ethereum.org/EIPS/eip-55
|
|
79
|
+
*/
|
|
80
|
+
export function getChecksumAddressUnmemoized(hexAddress) {
|
|
81
|
+
assert(isHexChecksumAddress(hexAddress), 'Invalid hex address.');
|
|
82
|
+
const address = remove0x(hexAddress).toLowerCase();
|
|
83
|
+
const hashBytes = keccak256(address);
|
|
84
|
+
const { length } = address;
|
|
85
|
+
const result = new Array(length); // Pre-allocate array
|
|
86
|
+
for (let i = 0; i < length; i++) {
|
|
87
|
+
/* eslint-disable no-bitwise */
|
|
88
|
+
const byteIndex = i >> 1; // Faster than Math.floor(i / 2)
|
|
89
|
+
const nibbleIndex = i & 1; // Faster than i % 2
|
|
90
|
+
const byte = hashBytes[byteIndex];
|
|
91
|
+
const nibble = nibbleIndex === 0 ? byte >> 4 : byte & 0x0f;
|
|
92
|
+
/* eslint-enable no-bitwise */
|
|
93
|
+
result[i] = nibble >= 8 ? address[i].toUpperCase() : address[i];
|
|
94
|
+
}
|
|
95
|
+
return `0x${result.join('')}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Encode a passed hex string as an ERC-55 mixed-case checksum address.
|
|
99
|
+
* This function is memoized for performance.
|
|
100
|
+
*
|
|
101
|
+
* @param hexAddress - The hex address to encode.
|
|
102
|
+
* @returns The address encoded according to ERC-55.
|
|
103
|
+
* @see https://eips.ethereum.org/EIPS/eip-55
|
|
104
|
+
*/
|
|
105
|
+
export const getChecksumAddress = memoize(getChecksumAddressUnmemoized);
|
|
106
|
+
/**
|
|
107
|
+
* Validate that the passed hex string is a valid ERC-55 mixed-case
|
|
108
|
+
* checksum address.
|
|
109
|
+
*
|
|
110
|
+
* @param possibleChecksum - The hex address to check.
|
|
111
|
+
* @returns True if the address is a checksum address.
|
|
112
|
+
*/
|
|
113
|
+
export function isValidChecksumAddressUnmemoized(possibleChecksum) {
|
|
114
|
+
if (!isHexChecksumAddress(possibleChecksum)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return getChecksumAddress(possibleChecksum) === possibleChecksum;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Validate that the passed hex string is a valid ERC-55 mixed-case
|
|
121
|
+
* checksum address.
|
|
122
|
+
*
|
|
123
|
+
* @param possibleChecksum - The hex address to check.
|
|
124
|
+
* @returns True if the address is a checksum address.
|
|
125
|
+
*/
|
|
126
|
+
export const isValidChecksumAddress = memoize(isValidChecksumAddressUnmemoized);
|
|
127
|
+
/**
|
|
128
|
+
* Validate that the passed prefixed hex string is an all-lowercase
|
|
129
|
+
* hex address, or a valid mixed-case checksum address.
|
|
130
|
+
*
|
|
131
|
+
* @param possibleAddress - Input parameter to check against.
|
|
132
|
+
* @returns Whether or not the input is a valid hex address.
|
|
133
|
+
*/
|
|
134
|
+
export function isValidHexAddressUnmemoized(possibleAddress) {
|
|
135
|
+
return (isHexAddress(possibleAddress) || isValidChecksumAddress(possibleAddress));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validate that the passed prefixed hex string is an all-lowercase
|
|
139
|
+
* hex address, or a valid mixed-case checksum address.
|
|
140
|
+
*
|
|
141
|
+
* @param possibleAddress - Input parameter to check against.
|
|
142
|
+
* @returns Whether or not the input is a valid hex address.
|
|
143
|
+
*/
|
|
144
|
+
export const isValidHexAddress = memoize(isValidHexAddressUnmemoized);
|
|
145
|
+
/**
|
|
146
|
+
* Add the `0x`-prefix to a hexadecimal string. If the string already has the
|
|
147
|
+
* prefix, it is returned as-is.
|
|
148
|
+
*
|
|
149
|
+
* @param hexadecimal - The hexadecimal string to add the prefix to.
|
|
150
|
+
* @returns The prefixed hexadecimal string.
|
|
151
|
+
*/
|
|
152
|
+
export function add0x(hexadecimal) {
|
|
153
|
+
if (hexadecimal.startsWith('0x')) {
|
|
154
|
+
return hexadecimal;
|
|
155
|
+
}
|
|
156
|
+
if (hexadecimal.startsWith('0X')) {
|
|
157
|
+
return `0x${hexadecimal.substring(2)}`;
|
|
158
|
+
}
|
|
159
|
+
return `0x${hexadecimal}`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Remove the `0x`-prefix from a hexadecimal string. If the string doesn't have
|
|
163
|
+
* the prefix, it is returned as-is.
|
|
164
|
+
*
|
|
165
|
+
* @param hexadecimal - The hexadecimal string to remove the prefix from.
|
|
166
|
+
* @returns The un-prefixed hexadecimal string.
|
|
167
|
+
*/
|
|
168
|
+
export function remove0x(hexadecimal) {
|
|
169
|
+
if (hexadecimal.startsWith('0x') || hexadecimal.startsWith('0X')) {
|
|
170
|
+
return hexadecimal.substring(2);
|
|
171
|
+
}
|
|
172
|
+
return hexadecimal;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=hex.js.map
|
package/dist/hex.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,qEAAqE;AACrE,iFAAiF;AACjF,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,gBAAgB,GAAG,iBAAiB,C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C;AACrB,CAAC","sourcesContent":["import { pattern, string } from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\nimport memoize from 'lodash/memoize.js';\n\nimport { assert } from './assert.js';\n\nexport type Hex = `0x${string}`;\n\n// Use native regexes instead of superstruct for maximum performance.\n// Pre-compiled regex for maximum performance - avoids recompilation on each call\nconst HEX_REGEX = /^(?:0x)?[0-9a-f]+$/iu;\nconst STRICT_HEX_REGEX = /^0x[0-9a-f]+$/iu;\nconst HEX_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/u;\nconst HEX_CHECKSUM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/u;\n\nexport const HexStruct = pattern(string(), HEX_REGEX);\nexport const StrictHexStruct = pattern(string(), STRICT_HEX_REGEX) as Struct<\n Hex,\n null\n>;\nexport const HexAddressStruct = pattern(string(), HEX_ADDRESS_REGEX) as Struct<\n Hex,\n null\n>;\nexport const HexChecksumAddressStruct = pattern(\n string(),\n HEX_CHECKSUM_ADDRESS_REGEX,\n) as Struct<Hex, null>;\n\nconst isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Check if a string is a valid hex string.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isHexString(value: unknown): value is string {\n return isString(value) && HEX_REGEX.test(value);\n}\n\n/**\n * Strictly check if a string is a valid hex string. A valid hex string must\n * start with the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isStrictHexString(value: unknown): value is Hex {\n return isString(value) && STRICT_HEX_REGEX.test(value);\n}\n\n/**\n * Check if a string is a valid hex address.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex address.\n */\nexport function isHexAddress(value: unknown): value is Hex {\n return isString(value) && HEX_ADDRESS_REGEX.test(value);\n}\n\n/**\n * Check if a string is a valid hex checksum address.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex checksum address.\n */\nexport function isHexChecksumAddress(value: unknown): value is Hex {\n return isString(value) && HEX_CHECKSUM_ADDRESS_REGEX.test(value);\n}\n\n/**\n * Assert that a value is a valid hex string.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsHexString(value: unknown): asserts value is string {\n assert(isHexString(value), 'Value must be a hexadecimal string.');\n}\n\n/**\n * Assert that a value is a valid hex string. A valid hex string must start with\n * the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsStrictHexString(value: unknown): asserts value is Hex {\n assert(\n isStrictHexString(value),\n 'Value must be a hexadecimal string, starting with \"0x\".',\n );\n}\n\n/**\n * Encode a passed hex string as an ERC-55 mixed-case checksum address.\n * This is the unmemoized version, primarily used for testing.\n *\n * @param hexAddress - The hex address to encode.\n * @returns The address encoded according to ERC-55.\n * @see https://eips.ethereum.org/EIPS/eip-55\n */\nexport function getChecksumAddressUnmemoized(hexAddress: Hex): Hex {\n assert(isHexChecksumAddress(hexAddress), 'Invalid hex address.');\n const address = remove0x(hexAddress).toLowerCase();\n\n const hashBytes = keccak256(address);\n const { length } = address;\n const result = new Array(length); // Pre-allocate array\n\n for (let i = 0; i < length; i++) {\n /* eslint-disable no-bitwise */\n const byteIndex = i >> 1; // Faster than Math.floor(i / 2)\n const nibbleIndex = i & 1; // Faster than i % 2\n const byte = hashBytes[byteIndex] as number;\n const nibble = nibbleIndex === 0 ? byte >> 4 : byte & 0x0f;\n /* eslint-enable no-bitwise */\n\n result[i] = nibble >= 8 ? (address[i] as string).toUpperCase() : address[i];\n }\n\n return `0x${result.join('')}`;\n}\n\n/**\n * Encode a passed hex string as an ERC-55 mixed-case checksum address.\n * This function is memoized for performance.\n *\n * @param hexAddress - The hex address to encode.\n * @returns The address encoded according to ERC-55.\n * @see https://eips.ethereum.org/EIPS/eip-55\n */\nexport const getChecksumAddress = memoize(getChecksumAddressUnmemoized);\n\n/**\n * Validate that the passed hex string is a valid ERC-55 mixed-case\n * checksum address.\n *\n * @param possibleChecksum - The hex address to check.\n * @returns True if the address is a checksum address.\n */\nexport function isValidChecksumAddressUnmemoized(possibleChecksum: Hex) {\n if (!isHexChecksumAddress(possibleChecksum)) {\n return false;\n }\n\n return getChecksumAddress(possibleChecksum) === possibleChecksum;\n}\n\n/**\n * Validate that the passed hex string is a valid ERC-55 mixed-case\n * checksum address.\n *\n * @param possibleChecksum - The hex address to check.\n * @returns True if the address is a checksum address.\n */\nexport const isValidChecksumAddress = memoize(isValidChecksumAddressUnmemoized);\n\n/**\n * Validate that the passed prefixed hex string is an all-lowercase\n * hex address, or a valid mixed-case checksum address.\n *\n * @param possibleAddress - Input parameter to check against.\n * @returns Whether or not the input is a valid hex address.\n */\nexport function isValidHexAddressUnmemoized(possibleAddress: Hex) {\n return (\n isHexAddress(possibleAddress) || isValidChecksumAddress(possibleAddress)\n );\n}\n\n/**\n * Validate that the passed prefixed hex string is an all-lowercase\n * hex address, or a valid mixed-case checksum address.\n *\n * @param possibleAddress - Input parameter to check against.\n * @returns Whether or not the input is a valid hex address.\n */\nexport const isValidHexAddress = memoize(isValidHexAddressUnmemoized);\n\n/**\n * Add the `0x`-prefix to a hexadecimal string. If the string already has the\n * prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to add the prefix to.\n * @returns The prefixed hexadecimal string.\n */\nexport function add0x(hexadecimal: string): Hex {\n if (hexadecimal.startsWith('0x')) {\n return hexadecimal as Hex;\n }\n\n if (hexadecimal.startsWith('0X')) {\n return `0x${hexadecimal.substring(2)}`;\n }\n\n return `0x${hexadecimal}`;\n}\n\n/**\n * Remove the `0x`-prefix from a hexadecimal string. If the string doesn't have\n * the prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to remove the prefix from.\n * @returns The un-prefixed hexadecimal string.\n */\nexport function remove0x(hexadecimal: string): string {\n if (hexadecimal.startsWith('0x') || hexadecimal.startsWith('0X')) {\n return hexadecimal.substring(2);\n }\n\n return hexadecimal;\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './assert.js';
|
|
2
|
+
export * from './base64.js';
|
|
3
|
+
export * from './bytes.js';
|
|
4
|
+
export * from './caip-types.js';
|
|
5
|
+
export * from './checksum.js';
|
|
6
|
+
export * from './coercers.js';
|
|
7
|
+
export * from './collections.js';
|
|
8
|
+
export type * from './encryption-types.js';
|
|
9
|
+
export * from './errors.js';
|
|
10
|
+
export * from './hashing.js';
|
|
11
|
+
export type { Hex } from './hex.js';
|
|
12
|
+
export { HexStruct, StrictHexStruct, HexAddressStruct, HexChecksumAddressStruct, isHexString, isStrictHexString, isHexAddress, isHexChecksumAddress, assertIsHexString, assertIsStrictHexString, isValidHexAddress, getChecksumAddress, isValidChecksumAddress, add0x, remove0x, } from './hex.js';
|
|
13
|
+
export * from './json.js';
|
|
14
|
+
export type * from './keyring.js';
|
|
15
|
+
export * from './logging.js';
|
|
16
|
+
export * from './misc.js';
|
|
17
|
+
export * from './mnemonic.js';
|
|
18
|
+
export * from './number.js';
|
|
19
|
+
export type * from './opaque.js';
|
|
20
|
+
export * from './promise.js';
|
|
21
|
+
export * from './superstruct.js';
|
|
22
|
+
export * from './time.js';
|
|
23
|
+
export type * from './transaction-types.js';
|
|
24
|
+
export * from './versions.js';
|
|
25
|
+
export { toWei, fromWei, numberToString, getValueOfUnit, unitMap, } from './unitsConversion.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,uBAAuB,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,EACL,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,cAAc,WAAW,CAAC;AAC1B,mBAAmB,cAAc,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,aAAa,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './assert.js';
|
|
2
|
+
export * from './base64.js';
|
|
3
|
+
export * from './bytes.js';
|
|
4
|
+
export * from './caip-types.js';
|
|
5
|
+
export * from './checksum.js';
|
|
6
|
+
export * from './coercers.js';
|
|
7
|
+
export * from './collections.js';
|
|
8
|
+
export * from './errors.js';
|
|
9
|
+
export * from './hashing.js';
|
|
10
|
+
export { HexStruct, StrictHexStruct, HexAddressStruct, HexChecksumAddressStruct, isHexString, isStrictHexString, isHexAddress, isHexChecksumAddress, assertIsHexString, assertIsStrictHexString, isValidHexAddress, getChecksumAddress, isValidChecksumAddress, add0x, remove0x, } from './hex.js';
|
|
11
|
+
export * from './json.js';
|
|
12
|
+
export * from './logging.js';
|
|
13
|
+
export * from './misc.js';
|
|
14
|
+
export * from './mnemonic.js';
|
|
15
|
+
export * from './number.js';
|
|
16
|
+
export * from './promise.js';
|
|
17
|
+
export * from './superstruct.js';
|
|
18
|
+
export * from './time.js';
|
|
19
|
+
export * from './versions.js';
|
|
20
|
+
export { toWei, fromWei, numberToString, getValueOfUnit, unitMap, } from './unitsConversion.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,EACL,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAE1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,sBAAsB,CAAC","sourcesContent":["export * from './assert.js';\nexport * from './base64.js';\nexport * from './bytes.js';\nexport * from './caip-types.js';\nexport * from './checksum.js';\nexport * from './coercers.js';\nexport * from './collections.js';\nexport type * from './encryption-types.js';\nexport * from './errors.js';\nexport * from './hashing.js';\nexport type { Hex } from './hex.js';\nexport {\n HexStruct,\n StrictHexStruct,\n HexAddressStruct,\n HexChecksumAddressStruct,\n isHexString,\n isStrictHexString,\n isHexAddress,\n isHexChecksumAddress,\n assertIsHexString,\n assertIsStrictHexString,\n isValidHexAddress,\n getChecksumAddress,\n isValidChecksumAddress,\n add0x,\n remove0x,\n} from './hex.js';\nexport * from './json.js';\nexport type * from './keyring.js';\nexport * from './logging.js';\nexport * from './misc.js';\nexport * from './mnemonic.js';\nexport * from './number.js';\nexport type * from './opaque.js';\nexport * from './promise.js';\nexport * from './superstruct.js';\nexport * from './time.js';\nexport type * from './transaction-types.js';\nexport * from './versions.js';\nexport {\n toWei,\n fromWei,\n numberToString,\n getValueOfUnit,\n unitMap,\n} from './unitsConversion.js';\n"]}
|