@xylabs/hex 5.0.82 → 5.0.84
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 +236 -0
- 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 +6 -0
- 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.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,5 +1,11 @@
|
|
|
1
1
|
import type { HexConfig } from '../hex/index.ts';
|
|
2
2
|
import type { Address } from './address.ts';
|
|
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
|
+
*/
|
|
3
9
|
export declare const isAddress: (value: unknown, config?: HexConfig) => value is Address;
|
|
4
10
|
/** @alpha */
|
|
5
11
|
export declare function isAddressV2(value: unknown): value is Address;
|
|
@@ -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,OAAO,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,OAG3E,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE5D"}
|
|
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,OAAO,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,OAG3E,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE5D"}
|
|
@@ -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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3F,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/address/address.ts","../../src/HexRegEx.ts","../../src/address/AddressTransformZod.ts","../../src/address/AddressValidationZod.ts","../../src/hex/as.ts","../../src/hex/from/fromHexString.ts","../../src/hex/nibble.ts","../../src/hex/is.ts","../../src/hex/from/fromArrayBuffer.ts","../../src/hex/from/fromBigInt.ts","../../src/hex/from/fromNumber.ts","../../src/hex/from/from.ts","../../src/hex/hex.ts","../../src/hex/isHexZero.ts","../../src/hex/legacy.ts","../../src/hex/to.ts","../../src/address/as.ts","../../src/address/is.ts","../../src/address/to.ts","../../src/ethAddress.ts","../../src/hash/as.ts","../../src/hash/is.ts","../../src/hash/hash.ts","../../src/hash/zod.ts","../../src/hexToBigInt.ts","../../src/zod.ts"],"sourcesContent":["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { type Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\nexport const ZERO_ADDRESS = '0000000000000000000000000000000000000000' as Address\nexport const ADDRESS_LENGTH = 40 as const\n\nexport const AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2)\n\ntype BrandedAddress = Brand<Hex, { readonly __address: true }>\n\nexport const AddressZod = z.string().regex(AddressRegEx).transform<BrandedAddress>(v => v as BrandedAddress)\n\nexport type Address = z.infer<typeof AddressZod>\n","export const HexRegExMinMax = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\nexport const HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\nexport const HexRegEx = /^[0-9a-f]+$/\nexport const HexRegExWithPrefix = /^0x[0-9a-f]+$/\n","import * as z from 'zod'\n\nimport { type Address, ADDRESS_LENGTH } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\nexport const AddressTransformZod = z.union([z.string(), z.bigint(), z.number()])\n .transform((value) => {\n switch (typeof value) {\n case 'bigint': {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n case 'string': {\n if (value.startsWith('0x')) {\n return value.slice(2)\n }\n return value\n }\n case 'number': {\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n }\n })\n .refine(x => AddressValidationZod.safeParse(x).data)\n .transform(x => x as Address)\n\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n","import * as z from 'zod'\n\nimport { HexZod } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { ADDRESS_LENGTH } from './address.ts'\n\nexport const AddressValidationZod = z.string()\n .refine(x => HexZod.safeParse(x))\n .refine(x => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) })\n .transform(v => v as Address)\n\nexport type AddressValidationZodType = z.infer<typeof AddressValidationZod>\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\n\nimport { hexFromHexString } from './from/index.ts'\nimport type { Hex } from './hex.ts'\nimport { isHex } from './is.ts'\n\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","import { isNumber } from '@xylabs/typeof'\n\nimport type { Hex, HexConfig } from '../hex.ts'\nimport { isHex } from '../is.ts'\nimport { bitsToNibbles } from '../nibble.ts'\n\nexport const hexFromHexString = (value: string, config: HexConfig = {}): Hex => {\n const {\n prefix = false, byteSize = 8, bitLength,\n } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unEvened = (value.startsWith('0x') ? value.slice(2) : value).toLowerCase()\n if (isHex(unEvened)) {\n const evenCharacters = unEvened.padStart(Math.ceil(unEvened.length / nibbleBoundary) * nibbleBoundary, '0')\n const padded = isNumber(bitLength) ? evenCharacters.padStart(bitLength / 4, '0') : evenCharacters\n return (prefix ? `0x${padded}` : padded).toLowerCase() as Hex\n } else {\n throw new Error('Received string is not a value hex')\n }\n}\n","// determine the number of nibbles for a given number of bits\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw new Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n// determine the number of nibbles for a given number of bits\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","import { HexRegEx, HexRegExWithPrefix } from '../HexRegEx.ts'\nimport type { Hex, HexConfig } from './hex.ts'\nimport { bitsToNibbles } from './nibble.ts'\n\nexport const isHex = (value: unknown, config?: HexConfig): value is Hex => {\n // Is it a string?\n if (typeof value !== 'string') return false\n\n const valueCharLength = config?.prefix ? value.length - 2 : value.length\n\n // If a bitLength specified, does it conform?\n if (config?.bitLength !== undefined && valueCharLength !== bitsToNibbles(config?.bitLength)) return false\n\n // Does it only has hex values?\n return config?.prefix ? HexRegExWithPrefix.test(value) : HexRegEx.test(value)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert an ArrayBuffer to a hex string */\nexport const hexFromArrayBuffer = (\n /** The buffer to be converted */\n buffer: ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n const unPadded = [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert a bigint to a hex string */\nexport const hexFromBigInt = (\n /** The bigint to be converted */\n value: bigint,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n): Hex => {\n const unPadded = value.toString(16)\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\n\nexport const hexFromNumber = (value: number, config?: HexConfig): Hex => {\n return hexFromBigInt(BigInt(value), config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromArrayBuffer } from './fromArrayBuffer.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\nimport { hexFromHexString } from './fromHexString.ts'\nimport { hexFromNumber } from './fromNumber.ts'\n\n/** Takes unknown value and tries our best to convert it to a hex string */\nexport const hexFrom = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n switch (typeof value) {\n case 'string': {\n return hexFromHexString(value, config)\n }\n case 'bigint': {\n return hexFromBigInt(value, config)\n }\n case 'number': {\n return hexFromNumber(value, config)\n }\n case 'object': {\n return hexFromArrayBuffer(value, config)\n }\n default: {\n throw new Error(`Invalid type: ${typeof value}`)\n }\n }\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { HexRegEx } from '../HexRegEx.ts'\n\nexport type BrandedHex = Brand<Lowercase<string>, { readonly __hex: true }>\n\nexport const HexZod = z.string().regex(HexRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHex)\n\n/** Configuration of validation and output format */\nexport interface HexConfig {\n bitLength?: number\n byteSize?: number\n prefix?: boolean\n}\n\nexport type Hex = z.infer<typeof HexZod>\n","import { isString } from '@xylabs/typeof'\n\nimport { hexFromHexString } from './from/index.ts'\n\nexport const isHexZero = (value?: string) => {\n return isString(value) ? BigInt(hexFromHexString(value, { prefix: true })) === 0n : undefined\n}\n","export const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n}\n","import { hexFrom } from './from/index.ts'\nimport type { HexConfig } from './hex.ts'\n\n/** takes any value and tries our best to convert it to a hex string */\nexport const toHex = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n) => {\n const { prefix = false } = config\n return hexFrom(value, { prefix, ...config })\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isObject } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\nimport { isAddress } from './is.ts'\n\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: false })\n break\n }\n default: {\n return isObject(assert) ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n\n/** @alpha */\nexport function asAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressValidationZod.parse(value)\n : AddressValidationZod.safeParse(value).data\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { isHex } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\nexport const isAddress = (value: unknown, config: HexConfig = {}): value is Address => {\n const { bitLength = 160, prefix = false } = config\n return isHex(value, { bitLength, prefix })\n}\n\n/** @alpha */\nexport function isAddressV2(value: unknown): value is Address {\n return AddressValidationZod.safeParse(value).success\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { hexFrom } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressTransformZod } from './AddressTransformZod.ts'\n\nexport const toAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): Address => {\n const { bitLength = 160, prefix = false } = config\n return hexFrom(value, {\n bitLength, prefix, ...config,\n }) as unknown as Address\n}\n\n/** @alpha */\nexport function toAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressTransformZod.parse(value)\n : AddressTransformZod.safeParse(value).data\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { HexConfig } from './hex/index.ts'\nimport {\n hexFrom, hexFromHexString, isHex,\n} from './hex/index.ts'\nimport { HexRegExMinMaxMixedCaseWithPrefix } from './HexRegEx.ts'\n\nexport const EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20)\n\nexport const EthAddressToStringZod = z.string().regex(EthAddressRegEx)\n\n/** @deprecated use EthAddressToStringZod */\nexport const EthAddressToStringSchema = EthAddressToStringZod\n\nexport const EthAddressFromStringZod = z.string().regex(EthAddressRegEx).transform(v => toEthAddress(v))\n\n/** @deprecated use EthAddressFromStringZod */\nexport const EthAddressFromStringSchema = EthAddressFromStringZod\n\n// using true instead of unique symbol to avoid conflicts with other versions of library\nexport type EthAddress = Brand<string, { readonly __eth_address: true }>\n\nexport const ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as EthAddress\n\nexport const toEthAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): EthAddress => {\n const { bitLength = 160, prefix = false } = config\n return `0x${hexFrom(value, {\n bitLength, prefix, ...config,\n })}` as EthAddress\n}\n\nexport const isEthAddress = (value: unknown, config: HexConfig = {}): value is EthAddress => {\n const { bitLength = 160, prefix = true } = config\n const loweredValue = typeof value === 'string' ? value.toLowerCase() : value\n return isHex(loweredValue, { bitLength, prefix })\n}\n\nexport const EthAddressZod = z.string()\n .regex(EthAddressRegEx, { message: 'Invalid address format' })\n .refine(\n isEthAddress,\n )\n\nexport function asEthAddress(value: unknown): EthAddress | undefined\nexport function asEthAddress(value: unknown, assert: AssertConfig): EthAddress\nexport function asEthAddress(value: unknown, assert?: AssertConfig): EthAddress | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: true, byteSize: 4 })\n break\n }\n default: {\n if (value !== undefined) {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n }\n return isEthAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an EthAddress [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isUndefined } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport { type Hash } from './hash.ts'\nimport { isHash } from './is.ts'\n\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return isUndefined(assert) ? undefined : assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n","import { isHex } from '../hex/index.ts'\nimport type { Hash, HashBitLength } from './hash.ts'\n\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, { bitLength })\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\nexport const HASH_LENGTH = 32 as const\n\nexport const HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH)\n\nexport const ZERO_HASH = '0000000000000000000000000000000000000000000000000000000000000000' as Hash\n\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\nexport type BrandedHash = Brand<Hex, { readonly __hash: true }>\n\nexport const HashZod = z.string()\n .regex(HashRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHash)\n\nexport type Hash = z.infer<typeof HashZod>\n","import * as z from 'zod'\n\nimport { asHash } from './as.ts'\nimport type { Hash } from './hash.ts'\nimport { HashZod } from './hash.ts'\n\nexport const HashToJsonZod = HashZod.transform<string>(v => v)\nexport const JsonToHashZod = z.string().transform<Hash>(v => asHash(v, true))\n","import { type Hex, hexFromHexString } from './hex/index.ts'\n\nexport function hexToBigInt(hex: Hex): bigint {\n return BigInt(hexFromHexString(hex, { prefix: true }))\n}\n","import * as z from 'zod'\n\nimport { toHex } from './hex/index.ts'\nimport { hexToBigInt } from './hexToBigInt.ts'\n\nexport const BigIntToJsonZod = z.bigint().nonnegative().transform(x => toHex(x))\nexport const JsonToBigIntZod = z.string().transform(x => toHex(x)).transform(x => hexToBigInt(x))\n"],"mappings":";AACA,YAAY,OAAO;;;ACDZ,IAAM,iBAAiB,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AAChG,SAAO,IAAI,OAAO,aAAa,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACjE;AAEO,IAAM,oCAAoC,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AACnH,SAAO,IAAI,OAAO,kBAAkB,WAAW,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,GAAG,IAAI,CAAC;;;ACLrE,SAAS,YAAY,KAAkB;AAC5C,SAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC;AACvD;;;ACJA,YAAYC,QAAO;AAKZ,IAAM,kBAAoB,UAAO,EAAE,YAAY,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC;AACxE,IAAM,kBAAoB,UAAO,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC,EAAE,UAAU,OAAK,YAAY,CAAC,CAAC;","names":["z","z","z","assertError","assertError","assertError","z","assertError","assertError","assertError","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../../src/address/address.ts","../../src/HexRegEx.ts","../../src/address/AddressTransformZod.ts","../../src/address/AddressValidationZod.ts","../../src/hex/as.ts","../../src/hex/from/fromHexString.ts","../../src/hex/nibble.ts","../../src/hex/is.ts","../../src/hex/from/fromArrayBuffer.ts","../../src/hex/from/fromBigInt.ts","../../src/hex/from/fromNumber.ts","../../src/hex/from/from.ts","../../src/hex/hex.ts","../../src/hex/isHexZero.ts","../../src/hex/legacy.ts","../../src/hex/to.ts","../../src/address/as.ts","../../src/address/is.ts","../../src/address/to.ts","../../src/ethAddress.ts","../../src/hash/as.ts","../../src/hash/is.ts","../../src/hash/hash.ts","../../src/hash/zod.ts","../../src/hexToBigInt.ts","../../src/zod.ts"],"sourcesContent":["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { type Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** A 160-bit zero address constant. */\nexport const ZERO_ADDRESS = '0000000000000000000000000000000000000000' as Address\n/** The character length of an address hex string (40 hex characters / 20 bytes). */\nexport const ADDRESS_LENGTH = 40 as const\n\n/** Regular expression matching a 20-byte (40 hex character) address string. */\nexport const AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2)\n\ntype BrandedAddress = Brand<Hex, { readonly __address: true }>\n\n/** Zod schema that validates and transforms a string into a branded Address type. */\nexport const AddressZod = z.string().regex(AddressRegEx).transform<BrandedAddress>(v => v as BrandedAddress)\n\n/** A validated 20-byte address string type, inferred from the AddressZod schema. */\nexport type Address = z.infer<typeof AddressZod>\n","/**\n * Creates a RegExp matching lowercase hex strings with a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating hex strings within the byte range\n */\nexport const HexRegExMinMax = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/**\n * Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating prefixed hex strings within the byte range\n */\nexport const HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/** Regular expression matching a lowercase hex string without prefix. */\nexport const HexRegEx = /^[0-9a-f]+$/\n/** Regular expression matching a lowercase hex string with a 0x prefix. */\nexport const HexRegExWithPrefix = /^0x[0-9a-f]+$/\n","import * as z from 'zod'\n\nimport { type Address, ADDRESS_LENGTH } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/** Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. */\nexport const AddressTransformZod = z.union([z.string(), z.bigint(), z.number()])\n .transform((value) => {\n switch (typeof value) {\n case 'bigint': {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n case 'string': {\n if (value.startsWith('0x')) {\n return value.slice(2)\n }\n return value\n }\n case 'number': {\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n }\n })\n .refine(x => AddressValidationZod.safeParse(x).data)\n .transform(x => x as Address)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n","import * as z from 'zod'\n\nimport { HexZod } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { ADDRESS_LENGTH } from './address.ts'\n\n/** Zod schema that validates a string is a properly formatted 40-character hex address. */\nexport const AddressValidationZod = z.string()\n .refine(x => HexZod.safeParse(x))\n .refine(x => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) })\n .transform(v => v as Address)\n\n/** The output type of AddressValidationZod after parsing. */\nexport type AddressValidationZodType = z.infer<typeof AddressValidationZod>\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\n\nimport { hexFromHexString } from './from/index.ts'\nimport type { Hex } from './hex.ts'\nimport { isHex } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hex, or undefined if coercion fails and assert is not set\n */\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","import { isNumber } from '@xylabs/typeof'\n\nimport type { Hex, HexConfig } from '../hex.ts'\nimport { isHex } from '../is.ts'\nimport { bitsToNibbles } from '../nibble.ts'\n\n/**\n * Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries.\n * @param value - The hex string to normalize (with or without 0x prefix)\n * @param config - Configuration for prefix, byteSize, and bitLength padding\n * @returns The normalized Hex string\n */\nexport const hexFromHexString = (value: string, config: HexConfig = {}): Hex => {\n const {\n prefix = false, byteSize = 8, bitLength,\n } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unEvened = (value.startsWith('0x') ? value.slice(2) : value).toLowerCase()\n if (isHex(unEvened)) {\n const evenCharacters = unEvened.padStart(Math.ceil(unEvened.length / nibbleBoundary) * nibbleBoundary, '0')\n const padded = isNumber(bitLength) ? evenCharacters.padStart(bitLength / 4, '0') : evenCharacters\n return (prefix ? `0x${padded}` : padded).toLowerCase() as Hex\n } else {\n throw new Error('Received string is not a value hex')\n }\n}\n","/**\n * Converts a bit count to the equivalent number of hex nibbles (4 bits each).\n * @param value - The number of bits (must be a multiple of 4)\n * @returns The number of nibbles\n */\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw new Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n/**\n * Converts a nibble count to the equivalent number of bits.\n * @param value - The number of nibbles\n * @returns The number of bits\n */\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","import { HexRegEx, HexRegExWithPrefix } from '../HexRegEx.ts'\nimport type { Hex, HexConfig } from './hex.ts'\nimport { bitsToNibbles } from './nibble.ts'\n\n/**\n * Type guard that checks whether a value is a valid hex string.\n * @param value - The value to check\n * @param config - Optional configuration for prefix and bit length validation\n * @returns True if the value is a valid Hex string\n */\nexport const isHex = (value: unknown, config?: HexConfig): value is Hex => {\n // Is it a string?\n if (typeof value !== 'string') return false\n\n const valueCharLength = config?.prefix ? value.length - 2 : value.length\n\n // If a bitLength specified, does it conform?\n if (config?.bitLength !== undefined && valueCharLength !== bitsToNibbles(config?.bitLength)) return false\n\n // Does it only has hex values?\n return config?.prefix ? HexRegExWithPrefix.test(value) : HexRegEx.test(value)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert an ArrayBuffer to a hex string */\nexport const hexFromArrayBuffer = (\n /** The buffer to be converted */\n buffer: ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n const unPadded = [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert a bigint to a hex string */\nexport const hexFromBigInt = (\n /** The bigint to be converted */\n value: bigint,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n): Hex => {\n const unPadded = value.toString(16)\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\n\n/**\n * Converts a number to a hex string by converting to BigInt first.\n * @param value - The number to convert\n * @param config - Optional hex output configuration\n * @returns The hex string representation\n */\nexport const hexFromNumber = (value: number, config?: HexConfig): Hex => {\n return hexFromBigInt(BigInt(value), config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromArrayBuffer } from './fromArrayBuffer.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\nimport { hexFromHexString } from './fromHexString.ts'\nimport { hexFromNumber } from './fromNumber.ts'\n\n/** Takes unknown value and tries our best to convert it to a hex string */\nexport const hexFrom = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n switch (typeof value) {\n case 'string': {\n return hexFromHexString(value, config)\n }\n case 'bigint': {\n return hexFromBigInt(value, config)\n }\n case 'number': {\n return hexFromNumber(value, config)\n }\n case 'object': {\n return hexFromArrayBuffer(value, config)\n }\n default: {\n throw new Error(`Invalid type: ${typeof value}`)\n }\n }\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { HexRegEx } from '../HexRegEx.ts'\n\n/** Branded type representing a validated lowercase hex string. */\nexport type BrandedHex = Brand<Lowercase<string>, { readonly __hex: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hex type. */\nexport const HexZod = z.string().regex(HexRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHex)\n\n/** Configuration of validation and output format */\nexport interface HexConfig {\n bitLength?: number\n byteSize?: number\n prefix?: boolean\n}\n\n/** A validated hex string type, inferred from the HexZod schema. */\nexport type Hex = z.infer<typeof HexZod>\n","import { isString } from '@xylabs/typeof'\n\nimport { hexFromHexString } from './from/index.ts'\n\n/**\n * Checks whether a hex string represents a zero value.\n * @param value - The hex string to check\n * @returns True if zero, false if non-zero, or undefined if the input is not a string\n */\nexport const isHexZero = (value?: string) => {\n return isString(value) ? BigInt(hexFromHexString(value, { prefix: true })) === 0n : undefined\n}\n","/**\n * Converts an ArrayBuffer to a hex string without padding or normalization.\n * @param buffer - The ArrayBuffer to convert\n * @returns A lowercase hex string representation of the buffer\n */\nexport const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n}\n","import { hexFrom } from './from/index.ts'\nimport type { HexConfig } from './hex.ts'\n\n/** takes any value and tries our best to convert it to a hex string */\nexport const toHex = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n) => {\n const { prefix = false } = config\n return hexFrom(value, { prefix, ...config })\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isObject } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\nimport { isAddress } from './is.ts'\n\n/**\n * Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Address, or undefined if coercion fails and assert is not set\n */\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: false })\n break\n }\n default: {\n return isObject(assert) ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n\n/** @alpha */\nexport function asAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressValidationZod.parse(value)\n : AddressValidationZod.safeParse(value).data\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { isHex } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/**\n * Type guard that checks whether a value is a valid 160-bit address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns True if the value is a valid Address\n */\nexport const isAddress = (value: unknown, config: HexConfig = {}): value is Address => {\n const { bitLength = 160, prefix = false } = config\n return isHex(value, { bitLength, prefix })\n}\n\n/** @alpha */\nexport function isAddressV2(value: unknown): value is Address {\n return AddressValidationZod.safeParse(value).success\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { hexFrom } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressTransformZod } from './AddressTransformZod.ts'\n\n/**\n * Converts a value to a 160-bit Address hex string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns The value as an Address\n */\nexport const toAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): Address => {\n const { bitLength = 160, prefix = false } = config\n return hexFrom(value, {\n bitLength, prefix, ...config,\n }) as unknown as Address\n}\n\n/** @alpha */\nexport function toAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressTransformZod.parse(value)\n : AddressTransformZod.safeParse(value).data\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { HexConfig } from './hex/index.ts'\nimport {\n hexFrom, hexFromHexString, isHex,\n} from './hex/index.ts'\nimport { HexRegExMinMaxMixedCaseWithPrefix } from './HexRegEx.ts'\n\n/** Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). */\nexport const EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20)\n\n/** Zod schema that validates a string is a properly formatted Ethereum address. */\nexport const EthAddressToStringZod = z.string().regex(EthAddressRegEx)\n\n/** @deprecated use EthAddressToStringZod */\nexport const EthAddressToStringSchema = EthAddressToStringZod\n\n/** Zod schema that validates and transforms a string into an EthAddress type. */\nexport const EthAddressFromStringZod = z.string().regex(EthAddressRegEx).transform(v => toEthAddress(v))\n\n/** @deprecated use EthAddressFromStringZod */\nexport const EthAddressFromStringSchema = EthAddressFromStringZod\n\n/** Branded type representing a validated Ethereum address with 0x prefix. */\n// using true instead of unique symbol to avoid conflicts with other versions of library\nexport type EthAddress = Brand<string, { readonly __eth_address: true }>\n\n/** The zero Ethereum address constant (0x followed by 40 zero characters). */\nexport const ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as EthAddress\n\n/**\n * Converts a value to a 0x-prefixed Ethereum address string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no inner prefix)\n * @returns The value as an EthAddress\n */\nexport const toEthAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): EthAddress => {\n const { bitLength = 160, prefix = false } = config\n return `0x${hexFrom(value, {\n bitLength, prefix, ...config,\n })}` as EthAddress\n}\n\n/**\n * Type guard that checks whether a value is a valid 0x-prefixed Ethereum address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit with prefix)\n * @returns True if the value is a valid EthAddress\n */\nexport const isEthAddress = (value: unknown, config: HexConfig = {}): value is EthAddress => {\n const { bitLength = 160, prefix = true } = config\n const loweredValue = typeof value === 'string' ? value.toLowerCase() : value\n return isHex(loweredValue, { bitLength, prefix })\n}\n\n/** Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. */\nexport const EthAddressZod = z.string()\n .regex(EthAddressRegEx, { message: 'Invalid address format' })\n .refine(\n isEthAddress,\n )\n\n/**\n * Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as EthAddress, or undefined if coercion fails and assert is not set\n */\nexport function asEthAddress(value: unknown): EthAddress | undefined\nexport function asEthAddress(value: unknown, assert: AssertConfig): EthAddress\nexport function asEthAddress(value: unknown, assert?: AssertConfig): EthAddress | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: true, byteSize: 4 })\n break\n }\n default: {\n if (value !== undefined) {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n }\n return isEthAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an EthAddress [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isUndefined } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport { type Hash } from './hash.ts'\nimport { isHash } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hash, or undefined if coercion fails and assert is not set\n */\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return isUndefined(assert) ? undefined : assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n","import { isHex } from '../hex/index.ts'\nimport type { Hash, HashBitLength } from './hash.ts'\n\n/**\n * Type guard that checks whether a value is a valid hash of the specified bit length.\n * @param value - The value to check\n * @param bitLength - The expected bit length of the hash (defaults to 256)\n * @returns True if the value is a valid Hash\n */\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, { bitLength })\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** The byte length of a standard hash (32 bytes / 256 bits). */\nexport const HASH_LENGTH = 32 as const\n\n/** Regular expression matching a 32-byte (64 hex character) hash string. */\nexport const HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH)\n\n/** A 256-bit zero hash constant. */\nexport const ZERO_HASH = '0000000000000000000000000000000000000000000000000000000000000000' as Hash\n\n/** Valid bit lengths for hash values. */\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\n/** Array of all valid hash bit lengths for runtime validation. */\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\n/**\n * Type guard that checks whether a value is a valid hash bit length.\n * @param value - The value to check\n * @returns True if the value is one of the supported HashBitLength values\n */\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\n/** Branded type representing a validated hash hex string. */\nexport type BrandedHash = Brand<Hex, { readonly __hash: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hash type. */\nexport const HashZod = z.string()\n .regex(HashRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHash)\n\n/** A validated hash string type, inferred from the HashZod schema. */\nexport type Hash = z.infer<typeof HashZod>\n","import * as z from 'zod'\n\nimport { asHash } from './as.ts'\nimport type { Hash } from './hash.ts'\nimport { HashZod } from './hash.ts'\n\n/** Zod schema that transforms a Hash to a plain string for JSON serialization. */\nexport const HashToJsonZod = HashZod.transform<string>(v => v)\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.string().transform<Hash>(v => asHash(v, true))\n","import { type Hex, hexFromHexString } from './hex/index.ts'\n\n/**\n * Converts a Hex string to a BigInt.\n * @param hex - The hex string to convert\n * @returns The BigInt representation of the hex value\n */\nexport function hexToBigInt(hex: Hex): bigint {\n return BigInt(hexFromHexString(hex, { prefix: true }))\n}\n","import * as z from 'zod'\n\nimport { toHex } from './hex/index.ts'\nimport { hexToBigInt } from './hexToBigInt.ts'\n\n/** Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. */\nexport const BigIntToJsonZod = z.bigint().nonnegative().transform(x => toHex(x))\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.string().transform(x => toHex(x)).transform(x => hexToBigInt(x))\n"],"mappings":";AACA,YAAY,OAAO;;;ACKZ,IAAM,iBAAiB,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AAChG,SAAO,IAAI,OAAO,aAAa,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACjE;AAQO,IAAM,oCAAoC,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AACnH,SAAO,IAAI,OAAO,kBAAkB,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACtE;AAGO,IAAM,WAAW;AAEjB,IAAM,qBAAqB;;;ADhB3B,IAAM,eAAe;AAErB,IAAM,iBAAiB;AAGvB,IAAM,eAAe,eAAe,iBAAiB,GAAG,iBAAiB,CAAC;AAK1E,IAAM,aAAe,SAAO,EAAE,MAAM,YAAY,EAAE,UAA0B,OAAK,CAAmB;;;AEjB3G,YAAYA,QAAO;;;ACAnB,YAAYC,QAAO;;;ACCnB,SAAS,mBAA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AAC,CAAC;","names":["z","z","z","assertError","assertError","assertError","z","assertError","assertError","assertError","z","z","z"]}
|
package/dist/neutral/zod.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. */
|
|
2
3
|
export declare const BigIntToJsonZod: z.ZodPipe<z.ZodBigInt, z.ZodTransform<import("./hex/hex.ts").BrandedHex, bigint>>;
|
|
4
|
+
/** Zod schema that parses a JSON hex string into a BigInt. */
|
|
3
5
|
export declare const JsonToBigIntZod: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<import("./hex/hex.ts").BrandedHex, string>>, z.ZodTransform<bigint, import("./hex/hex.ts").BrandedHex>>;
|
|
4
6
|
//# sourceMappingURL=zod.d.ts.map
|