@xylabs/hex 5.0.83 → 5.0.86
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/README.md +381 -303
- package/dist/neutral/HexRegEx.d.ts +14 -0
- package/dist/neutral/HexRegEx.d.ts.map +1 -1
- package/dist/neutral/address/AddressTransformZod.d.ts +2 -0
- package/dist/neutral/address/AddressTransformZod.d.ts.map +1 -1
- package/dist/neutral/address/AddressValidationZod.d.ts +2 -0
- package/dist/neutral/address/AddressValidationZod.d.ts.map +1 -1
- package/dist/neutral/address/address.d.ts +5 -0
- package/dist/neutral/address/address.d.ts.map +1 -1
- package/dist/neutral/address/as.d.ts +6 -0
- package/dist/neutral/address/as.d.ts.map +1 -1
- package/dist/neutral/address/is.d.ts +8 -2
- package/dist/neutral/address/is.d.ts.map +1 -1
- package/dist/neutral/address/to.d.ts +6 -0
- package/dist/neutral/address/to.d.ts.map +1 -1
- package/dist/neutral/ethAddress.d.ts +24 -0
- package/dist/neutral/ethAddress.d.ts.map +1 -1
- package/dist/neutral/hash/as.d.ts +6 -0
- package/dist/neutral/hash/as.d.ts.map +1 -1
- package/dist/neutral/hash/hash.d.ts +13 -0
- package/dist/neutral/hash/hash.d.ts.map +1 -1
- package/dist/neutral/hash/is.d.ts +6 -0
- package/dist/neutral/hash/is.d.ts.map +1 -1
- package/dist/neutral/hash/zod.d.ts +2 -0
- package/dist/neutral/hash/zod.d.ts.map +1 -1
- package/dist/neutral/hex/as.d.ts +6 -0
- package/dist/neutral/hex/as.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromHexString.d.ts +6 -0
- package/dist/neutral/hex/from/fromHexString.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromNumber.d.ts +6 -0
- package/dist/neutral/hex/from/fromNumber.d.ts.map +1 -1
- package/dist/neutral/hex/hex.d.ts +3 -0
- package/dist/neutral/hex/hex.d.ts.map +1 -1
- package/dist/neutral/hex/is.d.ts +6 -0
- package/dist/neutral/hex/is.d.ts.map +1 -1
- package/dist/neutral/hex/isHexZero.d.ts +5 -0
- package/dist/neutral/hex/isHexZero.d.ts.map +1 -1
- package/dist/neutral/hex/legacy.d.ts +5 -0
- package/dist/neutral/hex/legacy.d.ts.map +1 -1
- package/dist/neutral/hex/nibble.d.ts +10 -0
- package/dist/neutral/hex/nibble.d.ts.map +1 -1
- package/dist/neutral/hexToBigInt.d.ts +5 -0
- package/dist/neutral/hexToBigInt.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/zod.d.ts +2 -0
- package/dist/neutral/zod.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a RegExp matching lowercase hex strings with a byte length in the given range.
|
|
3
|
+
* @param minBytes - Minimum number of bytes (default 0)
|
|
4
|
+
* @param maxBytes - Maximum number of bytes
|
|
5
|
+
* @returns A RegExp for validating hex strings within the byte range
|
|
6
|
+
*/
|
|
1
7
|
export declare const HexRegExMinMax: (minBytes?: number, maxBytes?: number) => RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range.
|
|
10
|
+
* @param minBytes - Minimum number of bytes (default 0)
|
|
11
|
+
* @param maxBytes - Maximum number of bytes
|
|
12
|
+
* @returns A RegExp for validating prefixed hex strings within the byte range
|
|
13
|
+
*/
|
|
2
14
|
export declare const HexRegExMinMaxMixedCaseWithPrefix: (minBytes?: number, maxBytes?: number) => RegExp;
|
|
15
|
+
/** Regular expression matching a lowercase hex string without prefix. */
|
|
3
16
|
export declare const HexRegEx: RegExp;
|
|
17
|
+
/** Regular expression matching a lowercase hex string with a 0x prefix. */
|
|
4
18
|
export declare const HexRegExWithPrefix: RegExp;
|
|
5
19
|
//# sourceMappingURL=HexRegEx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HexRegEx.d.ts","sourceRoot":"","sources":["../../src/HexRegEx.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,iBAAY,EAAE,WAAU,MAAsC,WAE5F,CAAA;AAED,eAAO,MAAM,iCAAiC,GAAI,iBAAY,EAAE,WAAU,MAAsC,WAE/G,CAAA;AAED,eAAO,MAAM,QAAQ,QAAgB,CAAA;AACrC,eAAO,MAAM,kBAAkB,QAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"HexRegEx.d.ts","sourceRoot":"","sources":["../../src/HexRegEx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,iBAAY,EAAE,WAAU,MAAsC,WAE5F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,GAAI,iBAAY,EAAE,WAAU,MAAsC,WAE/G,CAAA;AAED,yEAAyE;AACzE,eAAO,MAAM,QAAQ,QAAgB,CAAA;AACrC,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,QAAkB,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. */
|
|
2
3
|
export declare const AddressTransformZod: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodBigInt, z.ZodNumber]>, z.ZodTransform<string, string | number | bigint>>, z.ZodTransform<Lowercase<string> & {
|
|
3
4
|
readonly __hex: true;
|
|
4
5
|
} & {
|
|
5
6
|
readonly __address: true;
|
|
6
7
|
}, string>>;
|
|
8
|
+
/** The output type of AddressTransformZod after parsing and transformation. */
|
|
7
9
|
export type AddressTransformZodType = z.infer<typeof AddressTransformZod>;
|
|
8
10
|
//# sourceMappingURL=AddressTransformZod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddressTransformZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressTransformZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,mBAAmB;;;;WAkBD,CAAA;AAE/B,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"AddressTransformZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressTransformZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,sGAAsG;AACtG,eAAO,MAAM,mBAAmB;;;;WAkBD,CAAA;AAE/B,+EAA+E;AAC/E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Zod schema that validates a string is a properly formatted 40-character hex address. */
|
|
2
3
|
export declare const AddressValidationZod: z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
3
4
|
readonly __hex: true;
|
|
4
5
|
} & {
|
|
5
6
|
readonly __address: true;
|
|
6
7
|
}, string>>;
|
|
8
|
+
/** The output type of AddressValidationZod after parsing. */
|
|
7
9
|
export type AddressValidationZodType = z.infer<typeof AddressValidationZod>;
|
|
8
10
|
//# sourceMappingURL=AddressValidationZod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddressValidationZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressValidationZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAMxB,eAAO,MAAM,oBAAoB;;;;WAGF,CAAA;AAE/B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"AddressValidationZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressValidationZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAMxB,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB;;;;WAGF,CAAA;AAE/B,6DAA6D;AAC7D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { Brand } from '@xylabs/typeof';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import { type Hex } from '../hex/index.ts';
|
|
4
|
+
/** A 160-bit zero address constant. */
|
|
4
5
|
export declare const ZERO_ADDRESS: Address;
|
|
6
|
+
/** The character length of an address hex string (40 hex characters / 20 bytes). */
|
|
5
7
|
export declare const ADDRESS_LENGTH: 40;
|
|
8
|
+
/** Regular expression matching a 20-byte (40 hex character) address string. */
|
|
6
9
|
export declare const AddressRegEx: RegExp;
|
|
7
10
|
type BrandedAddress = Brand<Hex, {
|
|
8
11
|
readonly __address: true;
|
|
9
12
|
}>;
|
|
13
|
+
/** Zod schema that validates and transforms a string into a branded Address type. */
|
|
10
14
|
export declare const AddressZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedAddress, string>>;
|
|
15
|
+
/** A validated 20-byte address string type, inferred from the AddressZod schema. */
|
|
11
16
|
export type Address = z.infer<typeof AddressZod>;
|
|
12
17
|
export {};
|
|
13
18
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/address/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAG1C,eAAO,MAAM,YAAY,EAAiD,OAAO,CAAA;AACjF,eAAO,MAAM,cAAc,EAAG,EAAW,CAAA;AAEzC,eAAO,MAAM,YAAY,QAAyD,CAAA;AAElF,KAAK,cAAc,GAAG,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE9D,eAAO,MAAM,UAAU,gEAAqF,CAAA;AAE5G,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/address/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAG1C,uCAAuC;AACvC,eAAO,MAAM,YAAY,EAAiD,OAAO,CAAA;AACjF,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAG,EAAW,CAAA;AAEzC,+EAA+E;AAC/E,eAAO,MAAM,YAAY,QAAyD,CAAA;AAElF,KAAK,cAAc,GAAG,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE9D,qFAAqF;AACrF,eAAO,MAAM,UAAU,gEAAqF,CAAA;AAE5G,oFAAoF;AACpF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { AssertConfig } from '@xylabs/error';
|
|
2
2
|
import type { Address } from './address.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.
|
|
5
|
+
* @param value - The value to coerce (must be a string)
|
|
6
|
+
* @param assert - If provided, throws on failure instead of returning undefined
|
|
7
|
+
* @returns The value as Address, or undefined if coercion fails and assert is not set
|
|
8
|
+
*/
|
|
3
9
|
export declare function asAddress(value: unknown): Address | undefined;
|
|
4
10
|
export declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
5
11
|
/** @alpha */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/address/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAI3C,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAA;AAqBxE,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,GAAG,SAAS,CAIxF"}
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/address/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAI3C;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAA;AAqBxE,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,GAAG,SAAS,CAIxF"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { HexConfig } from '../hex/index.ts';
|
|
2
2
|
import type { Address } from './address.ts';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Type guard that checks whether a value is a valid 160-bit address.
|
|
5
|
+
* @param value - The value to check
|
|
6
|
+
* @param config - Optional hex config (defaults to 160-bit, no prefix)
|
|
7
|
+
* @returns True if the value is a valid Address
|
|
8
|
+
*/
|
|
9
|
+
export declare const isAddress: (value?: unknown, config?: HexConfig) => value is Address;
|
|
4
10
|
/** @alpha */
|
|
5
|
-
export declare function isAddressV2(value
|
|
11
|
+
export declare function isAddressV2(value?: unknown): value is Address;
|
|
6
12
|
//# sourceMappingURL=is.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/address/is.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C,eAAO,MAAM,SAAS,GAAI,
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/address/is.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,OAG5E,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE7D"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { HexConfig } from '../hex/index.ts';
|
|
2
2
|
import type { Address } from './address.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a value to a 160-bit Address hex string.
|
|
5
|
+
* @param value - The value to convert (string, number, bigint, or ArrayBuffer)
|
|
6
|
+
* @param config - Optional hex config (defaults to 160-bit, no prefix)
|
|
7
|
+
* @returns The value as an Address
|
|
8
|
+
*/
|
|
3
9
|
export declare const toAddress: (value: string | number | bigint | ArrayBufferLike, config?: HexConfig) => Address;
|
|
4
10
|
/** @alpha */
|
|
5
11
|
export declare function toAddressV2(value: unknown, assert?: boolean): Address | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to.d.ts","sourceRoot":"","sources":["../../../src/address/to.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,SAAQ,SAAc,KAAG,OAKrG,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,GAAG,SAAS,CAIxF"}
|
|
1
|
+
{"version":3,"file":"to.d.ts","sourceRoot":"","sources":["../../../src/address/to.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,SAAQ,SAAc,KAAG,OAKrG,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,GAAG,SAAS,CAIxF"}
|
|
@@ -2,20 +2,44 @@ import type { AssertConfig } from '@xylabs/error';
|
|
|
2
2
|
import type { Brand } from '@xylabs/typeof';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import type { HexConfig } from './hex/index.ts';
|
|
5
|
+
/** Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). */
|
|
5
6
|
export declare const EthAddressRegEx: RegExp;
|
|
7
|
+
/** Zod schema that validates a string is a properly formatted Ethereum address. */
|
|
6
8
|
export declare const EthAddressToStringZod: z.ZodString;
|
|
7
9
|
/** @deprecated use EthAddressToStringZod */
|
|
8
10
|
export declare const EthAddressToStringSchema: z.ZodString;
|
|
11
|
+
/** Zod schema that validates and transforms a string into an EthAddress type. */
|
|
9
12
|
export declare const EthAddressFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
10
13
|
/** @deprecated use EthAddressFromStringZod */
|
|
11
14
|
export declare const EthAddressFromStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
15
|
+
/** Branded type representing a validated Ethereum address with 0x prefix. */
|
|
12
16
|
export type EthAddress = Brand<string, {
|
|
13
17
|
readonly __eth_address: true;
|
|
14
18
|
}>;
|
|
19
|
+
/** The zero Ethereum address constant (0x followed by 40 zero characters). */
|
|
15
20
|
export declare const ETH_ZERO_ADDRESS: EthAddress;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a value to a 0x-prefixed Ethereum address string.
|
|
23
|
+
* @param value - The value to convert (string, number, bigint, or ArrayBuffer)
|
|
24
|
+
* @param config - Optional hex config (defaults to 160-bit, no inner prefix)
|
|
25
|
+
* @returns The value as an EthAddress
|
|
26
|
+
*/
|
|
16
27
|
export declare const toEthAddress: (value: string | number | bigint | ArrayBufferLike, config?: HexConfig) => EthAddress;
|
|
28
|
+
/**
|
|
29
|
+
* Type guard that checks whether a value is a valid 0x-prefixed Ethereum address.
|
|
30
|
+
* @param value - The value to check
|
|
31
|
+
* @param config - Optional hex config (defaults to 160-bit with prefix)
|
|
32
|
+
* @returns True if the value is a valid EthAddress
|
|
33
|
+
*/
|
|
17
34
|
export declare const isEthAddress: (value: unknown, config?: HexConfig) => value is EthAddress;
|
|
35
|
+
/** Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. */
|
|
18
36
|
export declare const EthAddressZod: z.ZodString & z.ZodType<EthAddress, string, z.core.$ZodTypeInternals<EthAddress, string>>;
|
|
37
|
+
/**
|
|
38
|
+
* Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.
|
|
39
|
+
* @param value - The value to coerce (must be a string)
|
|
40
|
+
* @param assert - If provided, throws on failure instead of returning undefined
|
|
41
|
+
* @returns The value as EthAddress, or undefined if coercion fails and assert is not set
|
|
42
|
+
*/
|
|
19
43
|
export declare function asEthAddress(value: unknown): EthAddress | undefined;
|
|
20
44
|
export declare function asEthAddress(value: unknown, assert: AssertConfig): EthAddress;
|
|
21
45
|
//# sourceMappingURL=ethAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethAddress.d.ts","sourceRoot":"","sources":["../../src/ethAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAM/C,eAAO,MAAM,eAAe,QAA4C,CAAA;AAExE,eAAO,MAAM,qBAAqB,aAAoC,CAAA;AAEtE,4CAA4C;AAC5C,eAAO,MAAM,wBAAwB,aAAwB,CAAA;AAE7D,eAAO,MAAM,uBAAuB,4DAAoE,CAAA;AAExG,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,4DAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"ethAddress.d.ts","sourceRoot":"","sources":["../../src/ethAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAM/C,0FAA0F;AAC1F,eAAO,MAAM,eAAe,QAA4C,CAAA;AAExE,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,aAAoC,CAAA;AAEtE,4CAA4C;AAC5C,eAAO,MAAM,wBAAwB,aAAwB,CAAA;AAE7D,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,4DAAoE,CAAA;AAExG,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,4DAA0B,CAAA;AAEjE,6EAA6E;AAE7E,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAExE,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAmD,UAAU,CAAA;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,SAAQ,SAAc,KAAG,UAKxG,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,UAI9E,CAAA;AAED,8GAA8G;AAC9G,eAAO,MAAM,aAAa,2FAIvB,CAAA;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAA;AACpE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,UAAU,CAAA"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { AssertConfig } from '@xylabs/error';
|
|
2
2
|
import { type Hash } from './hash.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.
|
|
5
|
+
* @param value - The value to coerce (must be a string)
|
|
6
|
+
* @param assert - If provided, throws on failure instead of returning undefined
|
|
7
|
+
* @returns The value as Hash, or undefined if coercion fails and assert is not set
|
|
8
|
+
*/
|
|
3
9
|
export declare function asHash(value: unknown): Hash | undefined;
|
|
4
10
|
export declare function asHash(value: unknown, assert: AssertConfig): Hash;
|
|
5
11
|
//# sourceMappingURL=as.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hash/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKjD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAA;AAGrC,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AACxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hash/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKjD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAA;AAGrC;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AACxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import type { Brand } from '@xylabs/typeof';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import type { Hex } from '../hex/index.ts';
|
|
4
|
+
/** The byte length of a standard hash (32 bytes / 256 bits). */
|
|
4
5
|
export declare const HASH_LENGTH: 32;
|
|
6
|
+
/** Regular expression matching a 32-byte (64 hex character) hash string. */
|
|
5
7
|
export declare const HashRegEx: RegExp;
|
|
8
|
+
/** A 256-bit zero hash constant. */
|
|
6
9
|
export declare const ZERO_HASH: Hash;
|
|
10
|
+
/** Valid bit lengths for hash values. */
|
|
7
11
|
export type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
|
12
|
+
/** Array of all valid hash bit lengths for runtime validation. */
|
|
8
13
|
export declare const HashBitLength: HashBitLength[];
|
|
14
|
+
/**
|
|
15
|
+
* Type guard that checks whether a value is a valid hash bit length.
|
|
16
|
+
* @param value - The value to check
|
|
17
|
+
* @returns True if the value is one of the supported HashBitLength values
|
|
18
|
+
*/
|
|
9
19
|
export declare const isHashBitLength: (value: unknown) => value is HashBitLength;
|
|
20
|
+
/** Branded type representing a validated hash hex string. */
|
|
10
21
|
export type BrandedHash = Brand<Hex, {
|
|
11
22
|
readonly __hash: true;
|
|
12
23
|
}>;
|
|
24
|
+
/** Zod schema that validates and transforms a string into a branded Hash type. */
|
|
13
25
|
export declare const HashZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedHash, string>>;
|
|
26
|
+
/** A validated hash string type, inferred from the HashZod schema. */
|
|
14
27
|
export type Hash = z.infer<typeof HashZod>;
|
|
15
28
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/hash/hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAG1C,eAAO,MAAM,WAAW,EAAG,EAAW,CAAA;AAEtC,eAAO,MAAM,SAAS,QAA2C,CAAA;AAEjE,eAAO,MAAM,SAAS,EAAyE,IAAI,CAAA;AAEnG,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,aAEzD,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE/D,eAAO,MAAM,OAAO,6DACuE,CAAA;AAE3F,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/hash/hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAG1C,gEAAgE;AAChE,eAAO,MAAM,WAAW,EAAG,EAAW,CAAA;AAEtC,4EAA4E;AAC5E,eAAO,MAAM,SAAS,QAA2C,CAAA;AAEjE,oCAAoC;AACpC,eAAO,MAAM,SAAS,EAAyE,IAAI,CAAA;AAEnG,yCAAyC;AACzC,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,kEAAkE;AAClE,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,aAEzD,CAAA;AAED,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE/D,kFAAkF;AAClF,eAAO,MAAM,OAAO,6DACuE,CAAA;AAE3F,sEAAsE;AACtE,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Hash, HashBitLength } from './hash.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard that checks whether a value is a valid hash of the specified bit length.
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @param bitLength - The expected bit length of the hash (defaults to 256)
|
|
6
|
+
* @returns True if the value is a valid Hash
|
|
7
|
+
*/
|
|
2
8
|
export declare const isHash: (value: unknown, bitLength?: HashBitLength) => value is Hash;
|
|
3
9
|
//# sourceMappingURL=is.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hash/is.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,EAAE,YAAW,aAAmB,KAAG,KAAK,IAAI,IAEhF,CAAA"}
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hash/is.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,EAAE,YAAW,aAAmB,KAAG,KAAK,IAAI,IAEhF,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Zod schema that transforms a Hash to a plain string for JSON serialization. */
|
|
2
3
|
export declare const HashToJsonZod: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<import("./hash.ts").BrandedHash, string>>, z.ZodTransform<string, import("./hash.ts").BrandedHash>>;
|
|
4
|
+
/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */
|
|
3
5
|
export declare const JsonToHashZod: z.ZodPipe<z.ZodString, z.ZodTransform<import("./hash.ts").BrandedHash, string>>;
|
|
4
6
|
//# sourceMappingURL=zod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../src/hash/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAMxB,eAAO,MAAM,aAAa,qJAAoC,CAAA;AAC9D,eAAO,MAAM,aAAa,iFAAmD,CAAA"}
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../src/hash/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAMxB,kFAAkF;AAClF,eAAO,MAAM,aAAa,qJAAoC,CAAA;AAC9D,6FAA6F;AAC7F,eAAO,MAAM,aAAa,iFAAmD,CAAA"}
|
package/dist/neutral/hex/as.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { AssertConfig } from '@xylabs/error';
|
|
2
2
|
import type { Hex } from './hex.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.
|
|
5
|
+
* @param value - The value to coerce (must be a string)
|
|
6
|
+
* @param assert - If provided, throws on failure instead of returning undefined
|
|
7
|
+
* @returns The value as Hex, or undefined if coercion fails and assert is not set
|
|
8
|
+
*/
|
|
3
9
|
export declare function asHex(value: unknown): Hex | undefined;
|
|
4
10
|
export declare function asHex(value: unknown, assert: AssertConfig): Hex;
|
|
5
11
|
//# sourceMappingURL=as.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAIjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAGnC,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AACtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAA"}
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAIjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAGnC;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AACtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAA"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Hex, HexConfig } from '../hex.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries.
|
|
4
|
+
* @param value - The hex string to normalize (with or without 0x prefix)
|
|
5
|
+
* @param config - Configuration for prefix, byteSize, and bitLength padding
|
|
6
|
+
* @returns The normalized Hex string
|
|
7
|
+
*/
|
|
2
8
|
export declare const hexFromHexString: (value: string, config?: HexConfig) => Hex;
|
|
3
9
|
//# sourceMappingURL=fromHexString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromHexString.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromHexString.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAI/C,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,SAAQ,SAAc,KAAG,GAaxE,CAAA"}
|
|
1
|
+
{"version":3,"file":"fromHexString.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromHexString.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAI/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,SAAQ,SAAc,KAAG,GAaxE,CAAA"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Hex, HexConfig } from '../hex.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a number to a hex string by converting to BigInt first.
|
|
4
|
+
* @param value - The number to convert
|
|
5
|
+
* @param config - Optional hex output configuration
|
|
6
|
+
* @returns The hex string representation
|
|
7
|
+
*/
|
|
2
8
|
export declare const hexFromNumber: (value: number, config?: HexConfig) => Hex;
|
|
3
9
|
//# sourceMappingURL=fromNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromNumber.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG/C,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,SAAS,SAAS,KAAG,GAEjE,CAAA"}
|
|
1
|
+
{"version":3,"file":"fromNumber.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,SAAS,SAAS,KAAG,GAEjE,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Brand } from '@xylabs/typeof';
|
|
2
2
|
import * as z from 'zod';
|
|
3
|
+
/** Branded type representing a validated lowercase hex string. */
|
|
3
4
|
export type BrandedHex = Brand<Lowercase<string>, {
|
|
4
5
|
readonly __hex: true;
|
|
5
6
|
}>;
|
|
7
|
+
/** Zod schema that validates and transforms a string into a branded Hex type. */
|
|
6
8
|
export declare const HexZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedHex, string>>;
|
|
7
9
|
/** Configuration of validation and output format */
|
|
8
10
|
export interface HexConfig {
|
|
@@ -10,5 +12,6 @@ export interface HexConfig {
|
|
|
10
12
|
byteSize?: number;
|
|
11
13
|
prefix?: boolean;
|
|
12
14
|
}
|
|
15
|
+
/** A validated hex string type, inferred from the HexZod schema. */
|
|
13
16
|
export type Hex = z.infer<typeof HexZod>;
|
|
14
17
|
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../src/hex/hex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE3E,eAAO,MAAM,MAAM,4DAAoG,CAAA;AAEvH,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../src/hex/hex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,kEAAkE;AAClE,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE3E,iFAAiF;AACjF,eAAO,MAAM,MAAM,4DAAoG,CAAA;AAEvH,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,oEAAoE;AACpE,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA"}
|
package/dist/neutral/hex/is.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Hex, HexConfig } from './hex.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard that checks whether a value is a valid hex string.
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @param config - Optional configuration for prefix and bit length validation
|
|
6
|
+
* @returns True if the value is a valid Hex string
|
|
7
|
+
*/
|
|
2
8
|
export declare const isHex: (value: unknown, config?: HexConfig) => value is Hex;
|
|
3
9
|
//# sourceMappingURL=is.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hex/is.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG9C,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,EAAE,SAAS,SAAS,KAAG,KAAK,IAAI,GAWnE,CAAA"}
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hex/is.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG9C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,EAAE,SAAS,SAAS,KAAG,KAAK,IAAI,GAWnE,CAAA"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a hex string represents a zero value.
|
|
3
|
+
* @param value - The hex string to check
|
|
4
|
+
* @returns True if zero, false if non-zero, or undefined if the input is not a string
|
|
5
|
+
*/
|
|
1
6
|
export declare const isHexZero: (value?: string) => boolean | undefined;
|
|
2
7
|
//# sourceMappingURL=isHexZero.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isHexZero.d.ts","sourceRoot":"","sources":["../../../src/hex/isHexZero.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,wBAEvC,CAAA"}
|
|
1
|
+
{"version":3,"file":"isHexZero.d.ts","sourceRoot":"","sources":["../../../src/hex/isHexZero.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,wBAEvC,CAAA"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an ArrayBuffer to a hex string without padding or normalization.
|
|
3
|
+
* @param buffer - The ArrayBuffer to convert
|
|
4
|
+
* @returns A lowercase hex string representation of the buffer
|
|
5
|
+
*/
|
|
1
6
|
export declare const toHexLegacy: (buffer: ArrayBuffer) => string;
|
|
2
7
|
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/hex/legacy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,WAE9C,CAAA"}
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/hex/legacy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,WAE9C,CAAA"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a bit count to the equivalent number of hex nibbles (4 bits each).
|
|
3
|
+
* @param value - The number of bits (must be a multiple of 4)
|
|
4
|
+
* @returns The number of nibbles
|
|
5
|
+
*/
|
|
1
6
|
export declare const bitsToNibbles: (value: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a nibble count to the equivalent number of bits.
|
|
9
|
+
* @param value - The number of nibbles
|
|
10
|
+
* @returns The number of bits
|
|
11
|
+
*/
|
|
2
12
|
export declare const nibblesToBits: (value: number) => number;
|
|
3
13
|
//# sourceMappingURL=nibble.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nibble.d.ts","sourceRoot":"","sources":["../../../src/hex/nibble.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nibble.d.ts","sourceRoot":"","sources":["../../../src/hex/nibble.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAI7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAE7C,CAAA"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type Hex } from './hex/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Hex string to a BigInt.
|
|
4
|
+
* @param hex - The hex string to convert
|
|
5
|
+
* @returns The BigInt representation of the hex value
|
|
6
|
+
*/
|
|
2
7
|
export declare function hexToBigInt(hex: Hex): bigint;
|
|
3
8
|
//# sourceMappingURL=hexToBigInt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hexToBigInt.d.ts","sourceRoot":"","sources":["../../src/hexToBigInt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAoB,MAAM,gBAAgB,CAAA;AAE3D,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAE5C"}
|
|
1
|
+
{"version":3,"file":"hexToBigInt.d.ts","sourceRoot":"","sources":["../../src/hexToBigInt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAoB,MAAM,gBAAgB,CAAA;AAE3D;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAE5C"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -140,7 +140,7 @@ var toHex = (value, config = {}) => {
|
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
// src/address/AddressValidationZod.ts
|
|
143
|
-
var AddressValidationZod = z3.string().refine((x) => HexZod.safeParse(x)).refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) }).transform((v) => v);
|
|
143
|
+
var AddressValidationZod = z3.string().refine((x) => HexZod.safeParse(x).success).refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) }).transform((v) => v);
|
|
144
144
|
|
|
145
145
|
// src/address/AddressTransformZod.ts
|
|
146
146
|
var AddressTransformZod = z4.union([z4.string(), z4.bigint(), z4.number()]).transform((value) => {
|
|
@@ -179,7 +179,7 @@ function asAddress(value, assert) {
|
|
|
179
179
|
let stringValue = void 0;
|
|
180
180
|
switch (typeof value) {
|
|
181
181
|
case "string": {
|
|
182
|
-
stringValue = hexFromHexString(value, { prefix: false });
|
|
182
|
+
stringValue = hexFromHexString(value, { prefix: false, byteSize: 4 });
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
185
|
default: {
|