@xylabs/hex 5.0.5 → 5.0.6
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/dist/neutral/address/AddressTransformZod.d.ts +8 -0
- package/dist/neutral/address/AddressTransformZod.d.ts.map +1 -0
- package/dist/neutral/address/AddressValidationZod.d.ts +8 -0
- package/dist/neutral/address/AddressValidationZod.d.ts.map +1 -0
- package/dist/neutral/address/address.d.ts +7 -22
- package/dist/neutral/address/address.d.ts.map +1 -1
- package/dist/neutral/address/addressDeprecated.d.ts +18 -0
- package/dist/neutral/address/addressDeprecated.d.ts.map +1 -0
- package/dist/neutral/address/as.d.ts +7 -0
- package/dist/neutral/address/as.d.ts.map +1 -0
- package/dist/neutral/address/index.d.ts +6 -2
- package/dist/neutral/address/index.d.ts.map +1 -1
- package/dist/neutral/address/is.d.ts +6 -0
- package/dist/neutral/address/is.d.ts.map +1 -0
- package/dist/neutral/address/to.d.ts +6 -0
- package/dist/neutral/address/to.d.ts.map +1 -0
- package/dist/neutral/ethAddress.d.ts +4 -0
- package/dist/neutral/ethAddress.d.ts.map +1 -1
- package/dist/neutral/hash/as.d.ts +5 -0
- package/dist/neutral/hash/as.d.ts.map +1 -0
- package/dist/neutral/hash/hash.d.ts +14 -0
- package/dist/neutral/hash/hash.d.ts.map +1 -0
- package/dist/neutral/hash/index.d.ts +4 -0
- package/dist/neutral/hash/index.d.ts.map +1 -0
- package/dist/neutral/hash/is.d.ts +3 -0
- package/dist/neutral/hash/is.d.ts.map +1 -0
- package/dist/neutral/hex/as.d.ts +1 -1
- package/dist/neutral/hex/as.d.ts.map +1 -1
- package/dist/neutral/hex/from/from.d.ts +1 -1
- package/dist/neutral/hex/from/from.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromArrayBuffer.d.ts +1 -1
- package/dist/neutral/hex/from/fromArrayBuffer.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromBigInt.d.ts +1 -1
- package/dist/neutral/hex/from/fromBigInt.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromHexString.d.ts +1 -1
- package/dist/neutral/hex/from/fromHexString.d.ts.map +1 -1
- package/dist/neutral/hex/from/fromNumber.d.ts +1 -1
- package/dist/neutral/hex/from/fromNumber.d.ts.map +1 -1
- package/dist/neutral/hex/{model.d.ts → hex.d.ts} +1 -1
- package/dist/neutral/hex/hex.d.ts.map +1 -0
- package/dist/neutral/hex/index.d.ts +1 -1
- package/dist/neutral/hex/index.d.ts.map +1 -1
- package/dist/neutral/hex/is.d.ts +1 -1
- package/dist/neutral/hex/is.d.ts.map +1 -1
- package/dist/neutral/hex/to.d.ts +1 -1
- package/dist/neutral/hex/to.d.ts.map +1 -1
- package/dist/neutral/index-internal.d.ts +1 -1
- package/dist/neutral/index-internal.d.ts.map +1 -1
- package/dist/neutral/index-internal.mjs +94 -62
- package/dist/neutral/index-internal.mjs.map +1 -1
- package/dist/neutral/index.mjs +94 -62
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/address/AddressTransformZod.ts +26 -0
- package/src/address/{AddressZodValidation.ts → AddressValidationZod.ts} +2 -2
- package/src/address/address.ts +6 -76
- package/src/address/addressDeprecated.ts +18 -0
- package/src/address/as.ts +37 -0
- package/src/address/index.ts +6 -2
- package/src/address/is.ts +14 -0
- package/src/address/to.ts +18 -0
- package/src/ethAddress.ts +9 -2
- package/src/hash/as.ts +24 -0
- package/src/hash/hash.ts +23 -0
- package/src/hash/index.ts +3 -0
- package/src/hash/is.ts +6 -0
- package/src/hex/as.ts +1 -1
- package/src/hex/from/from.ts +1 -1
- package/src/hex/from/fromArrayBuffer.ts +1 -1
- package/src/hex/from/fromBigInt.ts +1 -1
- package/src/hex/from/fromHexString.ts +1 -1
- package/src/hex/from/fromNumber.ts +1 -1
- package/src/hex/index.ts +1 -1
- package/src/hex/is.ts +1 -1
- package/src/hex/to.ts +1 -1
- package/src/index-internal.ts +1 -1
- package/src/spec/hash.spec.ts +1 -1
- package/dist/neutral/address/AddressZodTransform.d.ts +0 -5
- package/dist/neutral/address/AddressZodTransform.d.ts.map +0 -1
- package/dist/neutral/address/AddressZodValidation.d.ts +0 -5
- package/dist/neutral/address/AddressZodValidation.d.ts.map +0 -1
- package/dist/neutral/hash.d.ts +0 -17
- package/dist/neutral/hash.d.ts.map +0 -1
- package/dist/neutral/hex/model.d.ts.map +0 -1
- package/src/address/AddressZodTransform.ts +0 -19
- package/src/hash.ts +0 -51
- /package/src/hex/{model.ts → hex.ts} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
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<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
3
|
+
readonly __hex: true;
|
|
4
|
+
}>, {
|
|
5
|
+
readonly __address: true;
|
|
6
|
+
}>, string>>;
|
|
7
|
+
export type AddressTransformZodType = z.infer<typeof AddressTransformZod>;
|
|
8
|
+
//# sourceMappingURL=AddressTransformZod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressTransformZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressTransformZod.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,eAAO,MAAM,mBAAmB;;;;YAkBD,CAAA;AAE/B,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const AddressValidationZod: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
3
|
+
readonly __hex: true;
|
|
4
|
+
}>, {
|
|
5
|
+
readonly __address: true;
|
|
6
|
+
}>, string>>;
|
|
7
|
+
export type AddressValidationZodType = z.infer<typeof AddressValidationZod>;
|
|
8
|
+
//# sourceMappingURL=AddressValidationZod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressValidationZod.d.ts","sourceRoot":"","sources":["../../../src/address/AddressValidationZod.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAMnB,eAAO,MAAM,oBAAoB;;;;YAGF,CAAA;AAE/B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
+
import type { Brand } from '@xylabs/typeof';
|
|
1
2
|
import z from 'zod';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Hex, HexConfig } from '../hex/index.ts';
|
|
4
|
-
export type Address = Hex & {
|
|
5
|
-
readonly __address: true;
|
|
6
|
-
};
|
|
7
|
-
export declare const AddressRegEx: RegExp;
|
|
8
|
-
export declare const AddressToStringZod: z.ZodString;
|
|
9
|
-
/** @deprecated use AddressToStringZod */
|
|
10
|
-
export declare const AddressToStringSchema: z.ZodString;
|
|
11
|
-
export declare const AddressFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<Address, string>>;
|
|
12
|
-
/** @deprecated use AddressFromStringZod */
|
|
13
|
-
export declare const AddressFromStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<Address, string>>;
|
|
3
|
+
import type { Hex } from '../hex/index.ts';
|
|
14
4
|
export declare const ZERO_ADDRESS: Address;
|
|
15
5
|
export declare const ADDRESS_LENGTH: 40;
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare function isAddressV2(value: unknown): value is Address;
|
|
22
|
-
/** @alpha */
|
|
23
|
-
export declare function asAddressV2(value: unknown, assert?: boolean): Address | undefined;
|
|
24
|
-
/** @alpha */
|
|
25
|
-
export declare function toAddressV2(value: unknown, assert?: boolean): Address | undefined;
|
|
6
|
+
export declare const AddressRegEx: RegExp;
|
|
7
|
+
export declare const AddressZod: z.ZodType<Brand<Hex, {
|
|
8
|
+
readonly __address: true;
|
|
9
|
+
}>>;
|
|
10
|
+
export type Address = z.infer<typeof AddressZod>;
|
|
26
11
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/address/address.ts"],"names":[],"mappings":"
|
|
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,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,KAAK,EAAE,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,eAAO,MAAM,UAAU,EACiD,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,CAAA;AAE3H,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/** @deprecated use AddressZod */
|
|
3
|
+
export declare const AddressToStringZod: z.ZodString;
|
|
4
|
+
/** @deprecated use AddressZod */
|
|
5
|
+
export declare const AddressToStringSchema: z.ZodString;
|
|
6
|
+
/** @deprecated use AddressZod */
|
|
7
|
+
export declare const AddressFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
8
|
+
readonly __hex: true;
|
|
9
|
+
}>, {
|
|
10
|
+
readonly __address: true;
|
|
11
|
+
}>, string>>;
|
|
12
|
+
/** @deprecated use AddressZod */
|
|
13
|
+
export declare const AddressFromStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
14
|
+
readonly __hex: true;
|
|
15
|
+
}>, {
|
|
16
|
+
readonly __address: true;
|
|
17
|
+
}>, string>>;
|
|
18
|
+
//# sourceMappingURL=addressDeprecated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressDeprecated.d.ts","sourceRoot":"","sources":["../../../src/address/addressDeprecated.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,aAAiC,CAAA;AAEhE,iCAAiC;AAEjC,eAAO,MAAM,qBAAqB,aAAqB,CAAA;AAEvD,iCAAiC;AACjC,eAAO,MAAM,oBAAoB;;;;YAA4E,CAAA;AAE7G,iCAAiC;AAEjC,eAAO,MAAM,uBAAuB;;;;YAAuB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AssertConfig } from '../assert.ts';
|
|
2
|
+
import type { Address } from './address.ts';
|
|
3
|
+
export declare function asAddress(value: unknown): Address | undefined;
|
|
4
|
+
export declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export declare function asAddressV2(value: unknown, assert?: boolean): Address | undefined;
|
|
7
|
+
//# sourceMappingURL=as.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/address/as.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,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,4 +1,8 @@
|
|
|
1
1
|
export * from './address.ts';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './addressDeprecated.ts';
|
|
3
|
+
export * from './AddressTransformZod.ts';
|
|
4
|
+
export * from './AddressValidationZod.ts';
|
|
5
|
+
export * from './as.ts';
|
|
6
|
+
export * from './is.ts';
|
|
7
|
+
export * from './to.ts';
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HexConfig } from '../hex/index.ts';
|
|
2
|
+
import type { Address } from './address.ts';
|
|
3
|
+
export declare const isAddress: (value: unknown, config?: HexConfig) => value is Address;
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export declare function isAddressV2(value: unknown): value is Address;
|
|
6
|
+
//# sourceMappingURL=is.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HexConfig } from '../hex/index.ts';
|
|
2
|
+
import type { Address } from './address.ts';
|
|
3
|
+
export declare const toAddress: (value: string | number | bigint | ArrayBufferLike, config?: HexConfig) => Address;
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export declare function toAddressV2(value: unknown, assert?: boolean): Address | undefined;
|
|
6
|
+
//# sourceMappingURL=to.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -3,7 +3,11 @@ import z from 'zod';
|
|
|
3
3
|
import type { AssertConfig } from './assert.ts';
|
|
4
4
|
import type { HexConfig } from './hex/index.ts';
|
|
5
5
|
export declare const EthAddressRegEx: RegExp;
|
|
6
|
+
export declare const EthAddressToStringZod: z.ZodString;
|
|
7
|
+
/** @deprecated use EthAddressToStringZod */
|
|
6
8
|
export declare const EthAddressToStringSchema: z.ZodString;
|
|
9
|
+
export declare const EthAddressFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
10
|
+
/** @deprecated use EthAddressFromStringZod */
|
|
7
11
|
export declare const EthAddressFromStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<EthAddress, string>>;
|
|
8
12
|
export type EthAddress = Brand<string, {
|
|
9
13
|
readonly __eth_address: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethAddress.d.ts","sourceRoot":"","sources":["../../src/ethAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAM/C,eAAO,MAAM,eAAe,QAA4C,CAAA;AAExE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"ethAddress.d.ts","sourceRoot":"","sources":["../../src/ethAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,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;AAGjE,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAExE,eAAO,MAAM,gBAAgB,EAAmD,UAAU,CAAA;AAE1F,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,SAAQ,SAAc,KAAG,UAKxG,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,UAG9E,CAAA;AAED,eAAO,MAAM,aAAa,aAIvB,CAAA;AAEH,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hash/as.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Brand } from '@xylabs/typeof';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
import type { Hex } from '../hex/index.ts';
|
|
4
|
+
export declare const HASH_LENGTH: 32;
|
|
5
|
+
export declare const HashRegEx: RegExp;
|
|
6
|
+
export declare const ZERO_HASH: Hash;
|
|
7
|
+
export type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
|
8
|
+
export declare const HashBitLength: HashBitLength[];
|
|
9
|
+
export declare const isHashBitLength: (value: unknown) => value is HashBitLength;
|
|
10
|
+
export declare const HashZod: z.ZodType<Brand<Hex, {
|
|
11
|
+
readonly __hash: true;
|
|
12
|
+
}>>;
|
|
13
|
+
export type Hash = z.infer<typeof HashZod>;
|
|
14
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +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,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAG1C,eAAO,MAAM,WAAW,EAAG,EAAW,CAAA;AAEtC,eAAO,MAAM,SAAS,QAA2C,CAAA;AAEjE,eAAO,MAAM,SAAS,EAAyE,IAAI,CAAA;AAEnG,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,aAEzD,CAAA;AAED,eAAO,MAAM,OAAO,EACiD,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,CAAA;AAErH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hash/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +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"}
|
package/dist/neutral/hex/as.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssertConfig } from '../assert.ts';
|
|
2
|
-
import type { Hex } from './
|
|
2
|
+
import type { Hex } from './hex.ts';
|
|
3
3
|
export declare function asHex(value: unknown): Hex | undefined;
|
|
4
4
|
export declare function asHex(value: unknown, assert: AssertConfig): Hex;
|
|
5
5
|
//# 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,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,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,4 +1,4 @@
|
|
|
1
|
-
import type { Hex, HexConfig } from '../
|
|
1
|
+
import type { Hex, HexConfig } from '../hex.ts';
|
|
2
2
|
/** Takes unknown value and tries our best to convert it to a hex string */
|
|
3
3
|
export declare const hexFrom: (
|
|
4
4
|
/** Supported types are string, number, bigint, and ArrayBuffer */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAM/C,2EAA2E;AAC3E,eAAO,MAAM,OAAO;AAClB,kEAAkE;AAClE,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe;AACjD,oDAAoD;AACpD,SAAS,SAAS,KACjB,GAkBF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromArrayBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fromArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromArrayBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG/C,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB;AAC7B,iCAAiC;AACjC,QAAQ,eAAe;AACvB,oDAAoD;AACpD,SAAS,SAAS,KACjB,GAGF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromBigInt.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromBigInt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fromBigInt.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromBigInt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG/C,uCAAuC;AACvC,eAAO,MAAM,aAAa;AACxB,iCAAiC;AACjC,OAAO,MAAM;AACb,oDAAoD;AACpD,SAAQ,SAAc,KACrB,GAGF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromHexString.d.ts","sourceRoot":"","sources":["../../../../src/hex/from/fromHexString.ts"],"names":[],"mappings":"
|
|
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 +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,
|
|
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"}
|
|
@@ -0,0 +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,CAAC,MAAM,KAAK,CAAA;AAInB,eAAO,MAAM,MAAM,EACiD,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,CAAA;AAEjI,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA;AAExC,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './as.ts';
|
|
2
2
|
export * from './from/index.ts';
|
|
3
|
+
export * from './hex.ts';
|
|
3
4
|
export * from './is.ts';
|
|
4
5
|
export * from './isHexZero.ts';
|
|
5
6
|
export * from './legacy.ts';
|
|
6
|
-
export * from './model.ts';
|
|
7
7
|
export * from './nibble.ts';
|
|
8
8
|
export * from './to.ts';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hex/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hex/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
|
package/dist/neutral/hex/is.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/neutral/hex/to.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to.d.ts","sourceRoot":"","sources":["../../../src/hex/to.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"to.d.ts","sourceRoot":"","sources":["../../../src/hex/to.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,uEAAuE;AACvE,eAAO,MAAM,KAAK;AAChB,kEAAkE;AAClE,OAAO,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe;AACjD,oDAAoD;AACpD,SAAQ,SAAc;;EAIvB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './address/index.ts';
|
|
2
2
|
export * from './assert.ts';
|
|
3
3
|
export * from './ethAddress.ts';
|
|
4
|
-
export * from './hash.ts';
|
|
4
|
+
export * from './hash/index.ts';
|
|
5
5
|
export * from './hex/index.ts';
|
|
6
6
|
export * from './HexRegEx.ts';
|
|
7
7
|
export * from './hexToBigInt.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-internal.d.ts","sourceRoot":"","sources":["../../src/index-internal.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index-internal.d.ts","sourceRoot":"","sources":["../../src/index-internal.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
// src/address/address.ts
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
// src/HexRegEx.ts
|
|
5
|
+
var HexRegExMinMax = (minBytes = 0, maxBytes = Number.MAX_SAFE_INTEGER / 2) => {
|
|
6
|
+
return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`);
|
|
7
|
+
};
|
|
8
|
+
var HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes = Number.MAX_SAFE_INTEGER / 2) => {
|
|
9
|
+
return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`);
|
|
10
|
+
};
|
|
11
|
+
var HexRegEx = /^[0-9a-f]+$/;
|
|
12
|
+
var HexRegExWithPrefix = /^0x[0-9a-f]+$/;
|
|
13
|
+
|
|
14
|
+
// src/address/address.ts
|
|
15
|
+
var ZERO_ADDRESS = "0000000000000000000000000000000000000000";
|
|
16
|
+
var ADDRESS_LENGTH = 40;
|
|
17
|
+
var AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2);
|
|
18
|
+
var AddressZod = z.string().regex(AddressRegEx, { message: "Invalid hex format" });
|
|
19
|
+
|
|
20
|
+
// src/address/addressDeprecated.ts
|
|
21
|
+
import z5 from "zod";
|
|
4
22
|
|
|
5
23
|
// src/assert.ts
|
|
6
24
|
import { isString, isUndefined } from "@xylabs/typeof";
|
|
@@ -17,16 +35,6 @@ var assertError = (value, assert, defaultMessage) => {
|
|
|
17
35
|
// src/hex/from/fromHexString.ts
|
|
18
36
|
import { isNumber } from "@xylabs/typeof";
|
|
19
37
|
|
|
20
|
-
// src/HexRegEx.ts
|
|
21
|
-
var HexRegExMinMax = (minBytes = 0, maxBytes = Number.MAX_SAFE_INTEGER / 2) => {
|
|
22
|
-
return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`);
|
|
23
|
-
};
|
|
24
|
-
var HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes = Number.MAX_SAFE_INTEGER / 2) => {
|
|
25
|
-
return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`);
|
|
26
|
-
};
|
|
27
|
-
var HexRegEx = /^[0-9a-f]+$/;
|
|
28
|
-
var HexRegExWithPrefix = /^0x[0-9a-f]+$/;
|
|
29
|
-
|
|
30
38
|
// src/hex/nibble.ts
|
|
31
39
|
var bitsToNibbles = (value) => {
|
|
32
40
|
const nibbles = value >> 2;
|
|
@@ -116,6 +124,10 @@ function asHex(value, assert) {
|
|
|
116
124
|
return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`);
|
|
117
125
|
}
|
|
118
126
|
|
|
127
|
+
// src/hex/hex.ts
|
|
128
|
+
import z2 from "zod";
|
|
129
|
+
var HexZod = z2.string().regex(HexRegEx, { message: "Invalid hex format" });
|
|
130
|
+
|
|
119
131
|
// src/hex/isHexZero.ts
|
|
120
132
|
import { isString as isString2 } from "@xylabs/typeof";
|
|
121
133
|
var isHexZero = (value) => {
|
|
@@ -127,42 +139,38 @@ var toHexLegacy = (buffer) => {
|
|
|
127
139
|
return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
128
140
|
};
|
|
129
141
|
|
|
130
|
-
// src/hex/model.ts
|
|
131
|
-
import z from "zod";
|
|
132
|
-
var HexZod = z.string().regex(HexRegEx, { message: "Invalid hex format" });
|
|
133
|
-
|
|
134
142
|
// src/hex/to.ts
|
|
135
143
|
var toHex = (value, config = {}) => {
|
|
136
144
|
const { prefix = false } = config;
|
|
137
145
|
return hexFrom(value, { prefix, ...config });
|
|
138
146
|
};
|
|
139
147
|
|
|
140
|
-
// src/address/
|
|
141
|
-
import
|
|
148
|
+
// src/address/AddressTransformZod.ts
|
|
149
|
+
import z4 from "zod";
|
|
142
150
|
|
|
143
|
-
// src/address/
|
|
144
|
-
import
|
|
145
|
-
var
|
|
151
|
+
// src/address/AddressValidationZod.ts
|
|
152
|
+
import z3 from "zod";
|
|
153
|
+
var AddressValidationZod = z3.string().refine((x) => HexZod.safeParse(x)).refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) }).transform((v) => v);
|
|
146
154
|
|
|
147
|
-
// src/address/
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
// src/address/AddressTransformZod.ts
|
|
156
|
+
var AddressTransformZod = z4.union([z4.string(), z4.bigint(), z4.number()]).transform((value) => {
|
|
157
|
+
switch (typeof value) {
|
|
158
|
+
case "bigint": {
|
|
159
|
+
return value.toString(16).padStart(ADDRESS_LENGTH, "0");
|
|
160
|
+
}
|
|
161
|
+
case "string": {
|
|
162
|
+
if (value.startsWith("0x")) {
|
|
163
|
+
return value.slice(2);
|
|
164
|
+
}
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
case "number": {
|
|
168
|
+
return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, "0");
|
|
169
|
+
}
|
|
154
170
|
}
|
|
155
|
-
|
|
156
|
-
}).refine((x) => AddressZodValidation.safeParse(x).data).transform((x) => x);
|
|
171
|
+
}).refine((x) => AddressValidationZod.safeParse(x).data).transform((x) => x);
|
|
157
172
|
|
|
158
|
-
// src/address/
|
|
159
|
-
var AddressRegEx = HexRegExMinMax(20, 20);
|
|
160
|
-
var AddressToStringZod = z4.string().regex(AddressRegEx);
|
|
161
|
-
var AddressToStringSchema = AddressToStringZod;
|
|
162
|
-
var AddressFromStringZod = z4.string().toLowerCase().regex(AddressRegEx).transform((v) => toAddress(v));
|
|
163
|
-
var AddressFromStringSchema = AddressFromStringZod;
|
|
164
|
-
var ZERO_ADDRESS = "0000000000000000000000000000000000000000";
|
|
165
|
-
var ADDRESS_LENGTH = 40;
|
|
173
|
+
// src/address/to.ts
|
|
166
174
|
var toAddress = (value, config = {}) => {
|
|
167
175
|
const { bitLength = 160, prefix = false } = config;
|
|
168
176
|
return hexFrom(value, {
|
|
@@ -171,10 +179,29 @@ var toAddress = (value, config = {}) => {
|
|
|
171
179
|
...config
|
|
172
180
|
});
|
|
173
181
|
};
|
|
182
|
+
function toAddressV2(value, assert = false) {
|
|
183
|
+
return assert ? AddressTransformZod.parse(value) : AddressTransformZod.safeParse(value).data;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/address/addressDeprecated.ts
|
|
187
|
+
var AddressToStringZod = z5.string().regex(AddressRegEx);
|
|
188
|
+
var AddressToStringSchema = AddressToStringZod;
|
|
189
|
+
var AddressFromStringZod = z5.string().toLowerCase().regex(AddressRegEx).transform((v) => toAddress(v));
|
|
190
|
+
var AddressFromStringSchema = AddressFromStringZod;
|
|
191
|
+
|
|
192
|
+
// src/address/as.ts
|
|
193
|
+
import { isObject } from "@xylabs/typeof";
|
|
194
|
+
|
|
195
|
+
// src/address/is.ts
|
|
174
196
|
var isAddress = (value, config = {}) => {
|
|
175
197
|
const { bitLength = 160, prefix = false } = config;
|
|
176
198
|
return isHex(value, { bitLength, prefix });
|
|
177
199
|
};
|
|
200
|
+
function isAddressV2(value) {
|
|
201
|
+
return AddressValidationZod.safeParse(value).success;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/address/as.ts
|
|
178
205
|
function asAddress(value, assert) {
|
|
179
206
|
try {
|
|
180
207
|
let stringValue = void 0;
|
|
@@ -193,21 +220,17 @@ function asAddress(value, assert) {
|
|
|
193
220
|
return assertError(void 0, assert, error.message);
|
|
194
221
|
}
|
|
195
222
|
}
|
|
196
|
-
function isAddressV2(value) {
|
|
197
|
-
return AddressZodValidation.safeParse(value).success;
|
|
198
|
-
}
|
|
199
223
|
function asAddressV2(value, assert = false) {
|
|
200
|
-
return assert ?
|
|
201
|
-
}
|
|
202
|
-
function toAddressV2(value, assert = false) {
|
|
203
|
-
return assert ? AddressZodTransform.parse(value) : AddressZodTransform.safeParse(value).data;
|
|
224
|
+
return assert ? AddressValidationZod.parse(value) : AddressValidationZod.safeParse(value).data;
|
|
204
225
|
}
|
|
205
226
|
|
|
206
227
|
// src/ethAddress.ts
|
|
207
|
-
import
|
|
228
|
+
import z6 from "zod";
|
|
208
229
|
var EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20);
|
|
209
|
-
var
|
|
210
|
-
var
|
|
230
|
+
var EthAddressToStringZod = z6.string().regex(EthAddressRegEx);
|
|
231
|
+
var EthAddressToStringSchema = EthAddressToStringZod;
|
|
232
|
+
var EthAddressFromStringZod = z6.string().regex(EthAddressRegEx).transform((v) => toEthAddress(v));
|
|
233
|
+
var EthAddressFromStringSchema = EthAddressFromStringZod;
|
|
211
234
|
var ETH_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
212
235
|
var toEthAddress = (value, config = {}) => {
|
|
213
236
|
const { bitLength = 160, prefix = false } = config;
|
|
@@ -221,7 +244,7 @@ var isEthAddress = (value, config = {}) => {
|
|
|
221
244
|
const { bitLength = 160, prefix = true } = config;
|
|
222
245
|
return isHex(value, { bitLength, prefix });
|
|
223
246
|
};
|
|
224
|
-
var EthAddressZod =
|
|
247
|
+
var EthAddressZod = z6.string().regex(EthAddressRegEx, { message: "Invalid address format" }).refine(
|
|
225
248
|
isEthAddress
|
|
226
249
|
);
|
|
227
250
|
function asEthAddress(value, assert) {
|
|
@@ -245,21 +268,15 @@ function asEthAddress(value, assert) {
|
|
|
245
268
|
}
|
|
246
269
|
}
|
|
247
270
|
|
|
248
|
-
// src/hash.ts
|
|
271
|
+
// src/hash/as.ts
|
|
249
272
|
import { isUndefined as isUndefined2 } from "@xylabs/typeof";
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
var ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
253
|
-
var HashBitLength = [32, 64, 128, 256, 512, 1024, 2048, 4096];
|
|
254
|
-
var isHashBitLength = (value) => {
|
|
255
|
-
return typeof value === "number" && HashBitLength.includes(value);
|
|
256
|
-
};
|
|
273
|
+
|
|
274
|
+
// src/hash/is.ts
|
|
257
275
|
var isHash = (value, bitLength = 256) => {
|
|
258
276
|
return isHex(value, { bitLength });
|
|
259
277
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
);
|
|
278
|
+
|
|
279
|
+
// src/hash/as.ts
|
|
263
280
|
function asHash(value, assert) {
|
|
264
281
|
let stringValue = void 0;
|
|
265
282
|
switch (typeof value) {
|
|
@@ -274,6 +291,17 @@ function asHash(value, assert) {
|
|
|
274
291
|
return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`);
|
|
275
292
|
}
|
|
276
293
|
|
|
294
|
+
// src/hash/hash.ts
|
|
295
|
+
import z7 from "zod";
|
|
296
|
+
var HASH_LENGTH = 32;
|
|
297
|
+
var HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH);
|
|
298
|
+
var ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
299
|
+
var HashBitLength = [32, 64, 128, 256, 512, 1024, 2048, 4096];
|
|
300
|
+
var isHashBitLength = (value) => {
|
|
301
|
+
return typeof value === "number" && HashBitLength.includes(value);
|
|
302
|
+
};
|
|
303
|
+
var HashZod = z7.string().regex(HashRegEx, { message: "Invalid hex format" });
|
|
304
|
+
|
|
277
305
|
// src/hexToBigInt.ts
|
|
278
306
|
function hexToBigInt(hex) {
|
|
279
307
|
return BigInt(hexFromHexString(hex, { prefix: true }));
|
|
@@ -285,13 +313,17 @@ export {
|
|
|
285
313
|
AddressRegEx,
|
|
286
314
|
AddressToStringSchema,
|
|
287
315
|
AddressToStringZod,
|
|
288
|
-
|
|
289
|
-
|
|
316
|
+
AddressTransformZod,
|
|
317
|
+
AddressValidationZod,
|
|
318
|
+
AddressZod,
|
|
290
319
|
ETH_ZERO_ADDRESS,
|
|
291
320
|
EthAddressFromStringSchema,
|
|
321
|
+
EthAddressFromStringZod,
|
|
292
322
|
EthAddressRegEx,
|
|
293
323
|
EthAddressToStringSchema,
|
|
324
|
+
EthAddressToStringZod,
|
|
294
325
|
EthAddressZod,
|
|
326
|
+
HASH_LENGTH,
|
|
295
327
|
HashBitLength,
|
|
296
328
|
HashRegEx,
|
|
297
329
|
HashZod,
|