@xylabs/hex 5.1.5 → 6.0.0

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.
@@ -1,6 +1,6 @@
1
- import * as z from 'zod';
1
+ import * as z from 'zod/mini';
2
2
  /** Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. */
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
+ export declare const AddressTransformZod: z.ZodMiniPipe<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBigInt<bigint>, z.ZodMiniNumber<number>]>, z.ZodMiniTransform<string, string | number | bigint>>, z.ZodMiniTransform<Lowercase<string> & {
4
4
  readonly __hex: true;
5
5
  } & {
6
6
  readonly __address: true;
@@ -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,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
+ {"version":3,"file":"AddressTransformZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressTransformZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAK7B,sGAAsG;AACtG,eAAO,MAAM,mBAAmB;;;;WAc/B,CAAA;AAED,+EAA+E;AAC/E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import * as z from 'zod';
1
+ import * as z from 'zod/mini';
2
2
  /** Zod schema that validates a string is a properly formatted 40-character hex address. */
3
- export declare const AddressValidationZod: z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
3
+ export declare const AddressValidationZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<Lowercase<string> & {
4
4
  readonly __hex: true;
5
5
  } & {
6
6
  readonly __address: true;
@@ -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,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB;;;;WAGF,CAAA;AAE/B,6DAA6D;AAC7D,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,UAAU,CAAA;AAM7B,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB;;;;WAMhC,CAAA;AAED,6DAA6D;AAC7D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { Brand } from '@xylabs/typeof';
2
- import * as z from 'zod';
2
+ import * as z from 'zod/mini';
3
3
  import { type Hex } from '../hex/index.ts';
4
4
  /** A 160-bit zero address constant. */
5
5
  export declare const ZERO_ADDRESS: Address;
@@ -11,7 +11,7 @@ type BrandedAddress = Brand<Hex, {
11
11
  readonly __address: true;
12
12
  }>;
13
13
  /** Zod schema that validates and transforms a string into a branded Address type. */
14
- export declare const AddressZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedAddress, string>>;
14
+ export declare const AddressZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<BrandedAddress, string>>;
15
15
  /** A validated 20-byte address string type, inferred from the AddressZod schema. */
16
16
  export type Address = z.infer<typeof AddressZod>;
17
17
  export {};
@@ -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,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
+ {"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,UAAU,CAAA;AAE7B,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,oFAGtB,CAAA;AAED,oFAAoF;AACpF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA"}
@@ -1,17 +1,17 @@
1
1
  import type { AssertConfig } from '@xylabs/error';
2
2
  import type { Brand } from '@xylabs/typeof';
3
- import * as z from 'zod';
3
+ import * as z from 'zod/mini';
4
4
  import type { HexConfig } from './hex/index.ts';
5
5
  /** Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). */
6
6
  export declare const EthAddressRegEx: RegExp;
7
7
  /** Zod schema that validates a string is a properly formatted Ethereum address. */
8
- export declare const EthAddressToStringZod: z.ZodString;
8
+ export declare const EthAddressToStringZod: z.ZodMiniString<string>;
9
9
  /** @deprecated use EthAddressToStringZod */
10
- export declare const EthAddressToStringSchema: z.ZodString;
10
+ export declare const EthAddressToStringSchema: z.ZodMiniString<string>;
11
11
  /** Zod schema that validates and transforms a string into an EthAddress type. */
12
- export declare const EthAddressFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
12
+ export declare const EthAddressFromStringZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<EthAddress, string>>;
13
13
  /** @deprecated use EthAddressFromStringZod */
14
- export declare const EthAddressFromStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
14
+ export declare const EthAddressFromStringSchema: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<EthAddress, string>>;
15
15
  /** Branded type representing a validated Ethereum address with 0x prefix. */
16
16
  export type EthAddress = Brand<string, {
17
17
  readonly __eth_address: true;
@@ -33,7 +33,7 @@ export declare const toEthAddress: (value: string | number | bigint | ArrayBuffe
33
33
  */
34
34
  export declare const isEthAddress: (value?: unknown, config?: HexConfig) => value is EthAddress;
35
35
  /** Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. */
36
- export declare const EthAddressZod: z.ZodString & z.ZodType<EthAddress, string, z.core.$ZodTypeInternals<EthAddress, string>>;
36
+ export declare const EthAddressZod: z.ZodMiniString<string>;
37
37
  /**
38
38
  * Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.
39
39
  * @param value - The value to coerce (must be a string)
@@ -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,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,QAAQ,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,UAI/E,CAAA;AAED,8GAA8G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A8G;AAC9G,eAAO,MAAM,aAAa,yBAGzB,CAAA;AAED;;;;;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,5 @@
1
1
  import type { Brand } from '@xylabs/typeof';
2
- import * as z from 'zod';
2
+ import * as z from 'zod/mini';
3
3
  import type { Hex } from '../hex/index.ts';
4
4
  /** The byte length of a standard hash (32 bytes / 256 bits). */
5
5
  export declare const HASH_LENGTH: 32;
@@ -22,7 +22,7 @@ export type BrandedHash = Brand<Hex, {
22
22
  readonly __hash: true;
23
23
  }>;
24
24
  /** Zod schema that validates and transforms a string into a branded Hash type. */
25
- export declare const HashZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedHash, string>>;
25
+ export declare const HashZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<BrandedHash, string>>;
26
26
  /** A validated hash string type, inferred from the HashZod schema. */
27
27
  export type Hash = z.infer<typeof HashZod>;
28
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,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,GA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,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAE/D,kFAAkF;AAClF,eAAO,MAAM,OAAO,iFAGnB,CAAA;AAED,sEAAsE;AACtE,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import * as z from 'zod';
1
+ import * as z from 'zod/mini';
2
2
  /** Zod schema that transforms a Hash to a plain string for JSON serialization. */
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>>;
3
+ export declare const HashToJsonZod: z.ZodMiniPipe<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./hash.ts").BrandedHash, string>>, z.ZodMiniTransform<string, import("./hash.ts").BrandedHash>>;
4
4
  /** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */
5
- export declare const JsonToHashZod: z.ZodPipe<z.ZodString, z.ZodTransform<import("./hash.ts").BrandedHash, string>>;
5
+ export declare const JsonToHashZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<import("./hash.ts").BrandedHash, string>>;
6
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,kFAAkF;AAClF,eAAO,MAAM,aAAa,qJAAoC,CAAA;AAC9D,6FAA6F;AAC7F,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,UAAU,CAAA;AAM7B,kFAAkF;AAClF,eAAO,MAAM,aAAa,iLAAuD,CAAA;AACjF,6FAA6F;AAC7F,eAAO,MAAM,aAAa,qGAAwE,CAAA"}
@@ -1,11 +1,11 @@
1
1
  import type { Brand } from '@xylabs/typeof';
2
- import * as z from 'zod';
2
+ import * as z from 'zod/mini';
3
3
  /** Branded type representing a validated lowercase hex string. */
4
4
  export type BrandedHex = Brand<Lowercase<string>, {
5
5
  readonly __hex: true;
6
6
  }>;
7
7
  /** Zod schema that validates and transforms a string into a branded Hex type. */
8
- export declare const HexZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedHex, string>>;
8
+ export declare const HexZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<BrandedHex, string>>;
9
9
  /** Configuration of validation and output format */
10
10
  export interface HexConfig {
11
11
  bitLength?: number;
@@ -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,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"}
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,UAAU,CAAA;AAI7B,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,gFAGlB,CAAA;AAED,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"}
@@ -1,5 +1,5 @@
1
1
  // src/address/address.ts
2
- import * as z from "zod";
2
+ import * as z from "zod/mini";
3
3
 
4
4
  // src/HexRegEx.ts
5
5
  var HexRegExMinMax = (minBytes = 0, maxBytes = Number.MAX_SAFE_INTEGER / 2) => {
@@ -15,13 +15,16 @@ var HexRegExWithPrefix = /^0x[0-9a-f]+$/;
15
15
  var ZERO_ADDRESS = "0000000000000000000000000000000000000000";
16
16
  var ADDRESS_LENGTH = 40;
17
17
  var AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2);
18
- var AddressZod = z.string().regex(AddressRegEx).transform((v) => v);
18
+ var AddressZod = z.pipe(
19
+ z.string().check(z.regex(AddressRegEx)),
20
+ z.transform((v) => v)
21
+ );
19
22
 
20
23
  // src/address/AddressTransformZod.ts
21
- import * as z4 from "zod";
24
+ import * as z4 from "zod/mini";
22
25
 
23
26
  // src/address/AddressValidationZod.ts
24
- import * as z3 from "zod";
27
+ import * as z3 from "zod/mini";
25
28
 
26
29
  // src/hex/as.ts
27
30
  import { assertError } from "@xylabs/error";
@@ -119,8 +122,11 @@ function asHex(value, assert) {
119
122
  }
120
123
 
121
124
  // src/hex/hex.ts
122
- import * as z2 from "zod";
123
- var HexZod = z2.string().regex(HexRegEx, { message: "Invalid hex format" }).transform((val) => val);
125
+ import * as z2 from "zod/mini";
126
+ var HexZod = z2.pipe(
127
+ z2.string().check(z2.regex(HexRegEx, { error: "Invalid hex format" })),
128
+ z2.transform((val) => val)
129
+ );
124
130
 
125
131
  // src/hex/isHexZero.ts
126
132
  import { isString } from "@xylabs/typeof";
@@ -140,25 +146,30 @@ var toHex = (value, config = {}) => {
140
146
  };
141
147
 
142
148
  // src/address/AddressValidationZod.ts
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);
149
+ var AddressValidationZod = z3.pipe(
150
+ z3.string().check(
151
+ z3.refine((x) => HexZod.safeParse(x).success),
152
+ z3.refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) })
153
+ ),
154
+ z3.transform((v) => v)
155
+ );
144
156
 
145
157
  // src/address/AddressTransformZod.ts
146
- var AddressTransformZod = z4.union([z4.string(), z4.bigint(), z4.number()]).transform((value) => {
147
- switch (typeof value) {
148
- case "bigint": {
149
- return value.toString(16).padStart(ADDRESS_LENGTH, "0");
150
- }
151
- case "string": {
152
- if (value.startsWith("0x")) {
153
- return value.slice(2);
158
+ var AddressTransformZod = z4.pipe(
159
+ z4.pipe(
160
+ z4.union([z4.string(), z4.bigint(), z4.number()]),
161
+ z4.transform((value) => {
162
+ if (typeof value === "bigint") {
163
+ return value.toString(16).padStart(ADDRESS_LENGTH, "0");
164
+ }
165
+ if (typeof value === "string") {
166
+ return value.startsWith("0x") ? value.slice(2) : value;
154
167
  }
155
- return value;
156
- }
157
- case "number": {
158
168
  return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, "0");
159
- }
160
- }
161
- }).refine((x) => AddressValidationZod.safeParse(x).data).transform((x) => x);
169
+ })
170
+ ).check(z4.refine((x) => AddressValidationZod.safeParse(x).success)),
171
+ z4.transform((x) => x)
172
+ );
162
173
 
163
174
  // src/address/as.ts
164
175
  import { assertError as assertError2 } from "@xylabs/error";
@@ -211,11 +222,14 @@ function toAddressV2(value, assert = false) {
211
222
 
212
223
  // src/ethAddress.ts
213
224
  import { assertError as assertError3 } from "@xylabs/error";
214
- import * as z5 from "zod";
225
+ import * as z5 from "zod/mini";
215
226
  var EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20);
216
- var EthAddressToStringZod = z5.string().regex(EthAddressRegEx);
227
+ var EthAddressToStringZod = z5.string().check(z5.regex(EthAddressRegEx));
217
228
  var EthAddressToStringSchema = EthAddressToStringZod;
218
- var EthAddressFromStringZod = z5.string().regex(EthAddressRegEx).transform((v) => toEthAddress(v));
229
+ var EthAddressFromStringZod = z5.pipe(
230
+ z5.string().check(z5.regex(EthAddressRegEx)),
231
+ z5.transform((v) => toEthAddress(v))
232
+ );
219
233
  var EthAddressFromStringSchema = EthAddressFromStringZod;
220
234
  var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
221
235
  var toEthAddress = (value, config = {}) => {
@@ -231,8 +245,9 @@ var isEthAddress = (value, config = {}) => {
231
245
  const loweredValue = typeof value === "string" ? value.toLowerCase() : value;
232
246
  return isHex(loweredValue, { bitLength, prefix });
233
247
  };
234
- var EthAddressZod = z5.string().regex(EthAddressRegEx, { message: "Invalid address format" }).refine(
235
- isEthAddress
248
+ var EthAddressZod = z5.string().check(
249
+ z5.regex(EthAddressRegEx, { error: "Invalid address format" }),
250
+ z5.refine(isEthAddress)
236
251
  );
237
252
  function asEthAddress(value, assert) {
238
253
  try {
@@ -280,7 +295,7 @@ function asHash(value, assert) {
280
295
  }
281
296
 
282
297
  // src/hash/hash.ts
283
- import * as z6 from "zod";
298
+ import * as z6 from "zod/mini";
284
299
  var HASH_LENGTH = 32;
285
300
  var HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH);
286
301
  var ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
@@ -288,12 +303,15 @@ var HashBitLength = [32, 64, 128, 256, 512, 1024, 2048, 4096];
288
303
  var isHashBitLength = (value) => {
289
304
  return typeof value === "number" && HashBitLength.includes(value);
290
305
  };
291
- var HashZod = z6.string().regex(HashRegEx, { message: "Invalid hex format" }).transform((val) => val);
306
+ var HashZod = z6.pipe(
307
+ z6.string().check(z6.regex(HashRegEx, { error: "Invalid hex format" })),
308
+ z6.transform((val) => val)
309
+ );
292
310
 
293
311
  // src/hash/zod.ts
294
- import * as z7 from "zod";
295
- var HashToJsonZod = HashZod.transform((v) => v);
296
- var JsonToHashZod = z7.string().transform((v) => asHash(v, true));
312
+ import * as z7 from "zod/mini";
313
+ var HashToJsonZod = z7.pipe(HashZod, z7.transform((v) => v));
314
+ var JsonToHashZod = z7.pipe(z7.string(), z7.transform((v) => asHash(v, true)));
297
315
 
298
316
  // src/hexToBigInt.ts
299
317
  function hexToBigInt(hex) {
@@ -301,9 +319,15 @@ function hexToBigInt(hex) {
301
319
  }
302
320
 
303
321
  // src/zod.ts
304
- import * as z8 from "zod";
305
- var BigIntToJsonZod = z8.bigint().nonnegative().transform((x) => toHex(x));
306
- var JsonToBigIntZod = z8.string().transform((x) => toHex(x)).transform((x) => hexToBigInt(x));
322
+ import * as z8 from "zod/mini";
323
+ var BigIntToJsonZod = z8.pipe(
324
+ z8.bigint().check(z8.nonnegative()),
325
+ z8.transform((x) => toHex(x))
326
+ );
327
+ var JsonToBigIntZod = z8.pipe(
328
+ z8.string(),
329
+ z8.transform((x) => hexToBigInt(toHex(x)))
330
+ );
307
331
  export {
308
332
  ADDRESS_LENGTH,
309
333
  AddressRegEx,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
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"],
4
- "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).success)\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, byteSize: 4 })\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 = 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 = 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"],
5
- "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,mBAAmB;;;ACD5B,SAAS,gBAAgB;;;ACKlB,IAAM,gBAAgB,CAAC,UAA0B;AACtD,QAAM,UAAU,SAAS;AACzB,MAAI,UAAU,WAAW,EAAG,OAAM,IAAI,MAAM,qCAAqC;AACjF,SAAO;AACT;AAOO,IAAM,gBAAgB,CAAC,UAA0B;AACtD,SAAO,SAAS;AAClB;;;ACRO,IAAM,QAAQ,CAAC,OAAgB,WAAqC;AAEzE,MAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,QAAM,kBAAkB,QAAQ,SAAS,MAAM,SAAS,IAAI,MAAM;AAGlE,MAAI,QAAQ,cAAc,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AAO,OAAO,WAAW,IAAI,cAAcA,aAAY,OAAO,QAAQ,wBAAwB,KAAK,GAAG;AACxG;;;AE5BA,YAAYC,QAAO;AAMZ,IAAM,cAAc;AAGpB,IAAM,YAAY,eAAe,aAAa,WAAW;AAGzD,IAAM,YAAY;AAKlB,IAAM,gBAAiC,CAAC,IAAI,IAAI,KAAK,KAAK,KAAK,MAAM,MAAM,IAAI;AAO/E,IAAM,kBAAkB,CAAC,UAA2C;AACzE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,KAAsB;AACnF;AAMO,IAAM,UAAY,UAAO,EAC7B,MAAM,WAAW,EAAE,SAAS,qBAAqB,CAAC,EAAE,UAAU,SAAO,GAAkB;;;AClC1F,YAAYC,QAAO;AAOZ,IAAM,gBAAgB,QAAQ,UAAkB,OAAK,CAAC;AAEtD,IAAM,gBAAkB,UAAO,EAAE,UAAgB,OAAK,OAAO,GAAG,IAAI,CAAC;;;ACFrE,SAAS,YAAY,KAAkB;AAC5C,SAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC;AACvD;;;ACTA,YAAYC,QAAO;AAMZ,IAAM,kBAAoB,UAAO,EAAE,YAAY,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC;AAExE,IAAM,kBAAoB,UAAO,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC,EAAE,UAAU,OAAK,YAAY,CAAC,CAAC;",
4
+ "sourcesContent": ["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod/mini'\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.pipe(\n z.string().check(z.regex(AddressRegEx)),\n z.transform((v: string): BrandedAddress => v as BrandedAddress),\n)\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/mini'\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.pipe(\n z.pipe(\n z.union([z.string(), z.bigint(), z.number()]),\n z.transform((value: string | bigint | number): string => {\n if (typeof value === 'bigint') {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n if (typeof value === 'string') {\n return value.startsWith('0x') ? value.slice(2) : value\n }\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }),\n ).check(z.refine((x: string) => AddressValidationZod.safeParse(x).success)),\n z.transform((x: string): Address => x as Address),\n)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n", "import * as z from 'zod/mini'\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.pipe(\n z.string().check(\n z.refine((x: string) => HexZod.safeParse(x).success),\n z.refine((x: string) => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) }),\n ),\n z.transform((v: string): Address => v as Address),\n)\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/mini'\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.pipe(\n z.string().check(z.regex(HexRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHex),\n)\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, byteSize: 4 })\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 = 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 = 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/mini'\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().check(z.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.pipe(\n z.string().check(z.regex(EthAddressRegEx)),\n z.transform((v: string) => toEthAddress(v)),\n)\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().check(\n z.regex(EthAddressRegEx, { error: 'Invalid address format' }),\n z.refine(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/mini'\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.pipe(\n z.string().check(z.regex(HashRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHash),\n)\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/mini'\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 = z.pipe(HashZod, z.transform((v: Hash): string => v))\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.pipe(z.string(), z.transform((v: string): Hash => 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/mini'\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.pipe(\n z.bigint().check(z.nonnegative()),\n z.transform((x: bigint) => toHex(x)),\n)\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.pipe(\n z.string(),\n z.transform((x: string) => hexToBigInt(toHex(x))),\n)\n"],
5
+ "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,WA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MAAM,IAAI;AAO/E,IAAM,kBAAkB,CAAC,UAA2C;AACzE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,KAAsB;AACnF;AAMO,IAAM,UAAY;AAAA,EACrB,UAAO,EAAE,MAAQ,SAAM,WAAW,EAAE,OAAO,qBAAqB,CAAC,CAAC;AAAA,EAClE,aAAU,CAAC,QAAgB,GAAkB;AACjD;;;ACpCA,YAAYC,QAAO;AAOZ,IAAM,gBAAkB,QAAK,SAAW,aAAU,CAAC,MAAoB,CAAC,CAAC;AAEzE,IAAM,gBAAkB,QAAO,UAAO,GAAK,aAAU,CAAC,MAAoB,OAAO,GAAG,IAAI,CAAC,CAAC;;;ACF1F,SAAS,YAAY,KAAkB;AAC5C,SAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC;AACvD;;;ACTA,YAAYC,QAAO;AAMZ,IAAM,kBAAoB;AAAA,EAC7B,UAAO,EAAE,MAAQ,eAAY,CAAC;AAAA,EAC9B,aAAU,CAAC,MAAc,MAAM,CAAC,CAAC;AACrC;AAEO,IAAM,kBAAoB;AAAA,EAC7B,UAAO;AAAA,EACP,aAAU,CAAC,MAAc,YAAY,MAAM,CAAC,CAAC,CAAC;AAClD;",
6
6
  "names": ["z", "z", "z", "assertError", "assertError", "assertError", "z", "assertError", "assertError", "assertError", "z", "z", "z"]
7
7
  }
@@ -1,6 +1,6 @@
1
- import * as z from 'zod';
1
+ import * as z from 'zod/mini';
2
2
  /** Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. */
3
- export declare const BigIntToJsonZod: z.ZodPipe<z.ZodBigInt, z.ZodTransform<import("./hex/hex.ts").BrandedHex, bigint>>;
3
+ export declare const BigIntToJsonZod: z.ZodMiniPipe<z.ZodMiniBigInt<bigint>, z.ZodMiniTransform<import("./hex/hex.ts").BrandedHex, bigint>>;
4
4
  /** Zod schema that parses a JSON hex string into a BigInt. */
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>>;
5
+ export declare const JsonToBigIntZod: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<bigint, string>>;
6
6
  //# sourceMappingURL=zod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,iGAAiG;AACjG,eAAO,MAAM,eAAe,mFAAoD,CAAA;AAChF,8DAA8D;AAC9D,eAAO,MAAM,eAAe,yJAAqE,CAAA"}
1
+ {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAK7B,iGAAiG;AACjG,eAAO,MAAM,eAAe,uGAG3B,CAAA;AACD,8DAA8D;AAC9D,eAAO,MAAM,eAAe,4EAG3B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/hex",
3
- "version": "5.1.5",
3
+ "version": "6.0.0",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "hex",
@@ -41,8 +41,8 @@
41
41
  "README.md"
42
42
  ],
43
43
  "dependencies": {
44
- "@xylabs/typeof": "~5.1.5",
45
- "@xylabs/error": "~5.1.5"
44
+ "@xylabs/error": "~6.0.0",
45
+ "@xylabs/typeof": "~6.0.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@xylabs/toolchain": "^8.0.8",
@@ -52,7 +52,7 @@
52
52
  "vite": "^8.0.13",
53
53
  "vitest": "^4.1.6",
54
54
  "zod": "^4.4.3",
55
- "@xylabs/vitest-extended": "~5.1.5"
55
+ "@xylabs/vitest-extended": "~6.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "zod": "^4.4"