@feelyourprotocol/util 8141.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.
Files changed (223) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +297 -0
  3. package/dist/cjs/account.d.ts +165 -0
  4. package/dist/cjs/account.d.ts.map +1 -0
  5. package/dist/cjs/account.js +530 -0
  6. package/dist/cjs/account.js.map +1 -0
  7. package/dist/cjs/address.d.ts +67 -0
  8. package/dist/cjs/address.d.ts.map +1 -0
  9. package/dist/cjs/address.js +136 -0
  10. package/dist/cjs/address.js.map +1 -0
  11. package/dist/cjs/authorization.d.ts +41 -0
  12. package/dist/cjs/authorization.d.ts.map +1 -0
  13. package/dist/cjs/authorization.js +135 -0
  14. package/dist/cjs/authorization.js.map +1 -0
  15. package/dist/cjs/bal.d.ts +129 -0
  16. package/dist/cjs/bal.d.ts.map +1 -0
  17. package/dist/cjs/bal.js +529 -0
  18. package/dist/cjs/bal.js.map +1 -0
  19. package/dist/cjs/binaryTree.d.ts +148 -0
  20. package/dist/cjs/binaryTree.d.ts.map +1 -0
  21. package/dist/cjs/binaryTree.js +240 -0
  22. package/dist/cjs/binaryTree.js.map +1 -0
  23. package/dist/cjs/blobs.d.ts +76 -0
  24. package/dist/cjs/blobs.d.ts.map +1 -0
  25. package/dist/cjs/blobs.js +175 -0
  26. package/dist/cjs/blobs.js.map +1 -0
  27. package/dist/cjs/bytes.d.ts +291 -0
  28. package/dist/cjs/bytes.d.ts.map +1 -0
  29. package/dist/cjs/bytes.js +606 -0
  30. package/dist/cjs/bytes.js.map +1 -0
  31. package/dist/cjs/constants.d.ts +91 -0
  32. package/dist/cjs/constants.d.ts.map +1 -0
  33. package/dist/cjs/constants.js +97 -0
  34. package/dist/cjs/constants.js.map +1 -0
  35. package/dist/cjs/db.d.ts +65 -0
  36. package/dist/cjs/db.d.ts.map +1 -0
  37. package/dist/cjs/db.js +14 -0
  38. package/dist/cjs/db.js.map +1 -0
  39. package/dist/cjs/env.d.ts +9 -0
  40. package/dist/cjs/env.d.ts.map +1 -0
  41. package/dist/cjs/env.js +13 -0
  42. package/dist/cjs/env.js.map +1 -0
  43. package/dist/cjs/errors.d.ts +3 -0
  44. package/dist/cjs/errors.d.ts.map +1 -0
  45. package/dist/cjs/errors.js +19 -0
  46. package/dist/cjs/errors.js.map +1 -0
  47. package/dist/cjs/helpers.d.ts +21 -0
  48. package/dist/cjs/helpers.d.ts.map +1 -0
  49. package/dist/cjs/helpers.js +50 -0
  50. package/dist/cjs/helpers.js.map +1 -0
  51. package/dist/cjs/index.d.ts +67 -0
  52. package/dist/cjs/index.d.ts.map +1 -0
  53. package/dist/cjs/index.js +93 -0
  54. package/dist/cjs/index.js.map +1 -0
  55. package/dist/cjs/internal.d.ts +72 -0
  56. package/dist/cjs/internal.d.ts.map +1 -0
  57. package/dist/cjs/internal.js +182 -0
  58. package/dist/cjs/internal.js.map +1 -0
  59. package/dist/cjs/kzg.d.ts +14 -0
  60. package/dist/cjs/kzg.d.ts.map +1 -0
  61. package/dist/cjs/kzg.js +3 -0
  62. package/dist/cjs/kzg.js.map +1 -0
  63. package/dist/cjs/lock.d.ts +15 -0
  64. package/dist/cjs/lock.d.ts.map +1 -0
  65. package/dist/cjs/lock.js +45 -0
  66. package/dist/cjs/lock.js.map +1 -0
  67. package/dist/cjs/mapDB.d.ts +17 -0
  68. package/dist/cjs/mapDB.d.ts.map +1 -0
  69. package/dist/cjs/mapDB.js +46 -0
  70. package/dist/cjs/mapDB.js.map +1 -0
  71. package/dist/cjs/package.json +3 -0
  72. package/dist/cjs/provider.d.ts +46 -0
  73. package/dist/cjs/provider.d.ts.map +1 -0
  74. package/dist/cjs/provider.js +84 -0
  75. package/dist/cjs/provider.js.map +1 -0
  76. package/dist/cjs/request.d.ts +20 -0
  77. package/dist/cjs/request.d.ts.map +1 -0
  78. package/dist/cjs/request.js +35 -0
  79. package/dist/cjs/request.js.map +1 -0
  80. package/dist/cjs/signature.d.ts +47 -0
  81. package/dist/cjs/signature.d.ts.map +1 -0
  82. package/dist/cjs/signature.js +147 -0
  83. package/dist/cjs/signature.js.map +1 -0
  84. package/dist/cjs/tasks.d.ts +32 -0
  85. package/dist/cjs/tasks.d.ts.map +1 -0
  86. package/dist/cjs/tasks.js +51 -0
  87. package/dist/cjs/tasks.js.map +1 -0
  88. package/dist/cjs/types.d.ts +64 -0
  89. package/dist/cjs/types.d.ts.map +1 -0
  90. package/dist/cjs/types.js +78 -0
  91. package/dist/cjs/types.js.map +1 -0
  92. package/dist/cjs/units.d.ts +22 -0
  93. package/dist/cjs/units.d.ts.map +1 -0
  94. package/dist/cjs/units.js +51 -0
  95. package/dist/cjs/units.js.map +1 -0
  96. package/dist/cjs/withdrawal.d.ts +72 -0
  97. package/dist/cjs/withdrawal.d.ts.map +1 -0
  98. package/dist/cjs/withdrawal.js +93 -0
  99. package/dist/cjs/withdrawal.js.map +1 -0
  100. package/dist/esm/account.d.ts +165 -0
  101. package/dist/esm/account.d.ts.map +1 -0
  102. package/dist/esm/account.js +505 -0
  103. package/dist/esm/account.js.map +1 -0
  104. package/dist/esm/address.d.ts +67 -0
  105. package/dist/esm/address.d.ts.map +1 -0
  106. package/dist/esm/address.js +125 -0
  107. package/dist/esm/address.js.map +1 -0
  108. package/dist/esm/authorization.d.ts +41 -0
  109. package/dist/esm/authorization.d.ts.map +1 -0
  110. package/dist/esm/authorization.js +126 -0
  111. package/dist/esm/authorization.js.map +1 -0
  112. package/dist/esm/bal.d.ts +129 -0
  113. package/dist/esm/bal.d.ts.map +1 -0
  114. package/dist/esm/bal.js +522 -0
  115. package/dist/esm/bal.js.map +1 -0
  116. package/dist/esm/binaryTree.d.ts +148 -0
  117. package/dist/esm/binaryTree.d.ts.map +1 -0
  118. package/dist/esm/binaryTree.js +226 -0
  119. package/dist/esm/binaryTree.js.map +1 -0
  120. package/dist/esm/blobs.d.ts +76 -0
  121. package/dist/esm/blobs.d.ts.map +1 -0
  122. package/dist/esm/blobs.js +163 -0
  123. package/dist/esm/blobs.js.map +1 -0
  124. package/dist/esm/bytes.d.ts +291 -0
  125. package/dist/esm/bytes.d.ts.map +1 -0
  126. package/dist/esm/bytes.js +562 -0
  127. package/dist/esm/bytes.js.map +1 -0
  128. package/dist/esm/constants.d.ts +91 -0
  129. package/dist/esm/constants.d.ts.map +1 -0
  130. package/dist/esm/constants.js +94 -0
  131. package/dist/esm/constants.js.map +1 -0
  132. package/dist/esm/db.d.ts +65 -0
  133. package/dist/esm/db.d.ts.map +1 -0
  134. package/dist/esm/db.js +11 -0
  135. package/dist/esm/db.js.map +1 -0
  136. package/dist/esm/env.d.ts +9 -0
  137. package/dist/esm/env.d.ts.map +1 -0
  138. package/dist/esm/env.js +9 -0
  139. package/dist/esm/env.js.map +1 -0
  140. package/dist/esm/errors.d.ts +3 -0
  141. package/dist/esm/errors.d.ts.map +1 -0
  142. package/dist/esm/errors.js +14 -0
  143. package/dist/esm/errors.js.map +1 -0
  144. package/dist/esm/helpers.d.ts +21 -0
  145. package/dist/esm/helpers.d.ts.map +1 -0
  146. package/dist/esm/helpers.js +43 -0
  147. package/dist/esm/helpers.js.map +1 -0
  148. package/dist/esm/index.d.ts +67 -0
  149. package/dist/esm/index.d.ts.map +1 -0
  150. package/dist/esm/index.js +67 -0
  151. package/dist/esm/index.js.map +1 -0
  152. package/dist/esm/internal.d.ts +72 -0
  153. package/dist/esm/internal.d.ts.map +1 -0
  154. package/dist/esm/internal.js +170 -0
  155. package/dist/esm/internal.js.map +1 -0
  156. package/dist/esm/kzg.d.ts +14 -0
  157. package/dist/esm/kzg.d.ts.map +1 -0
  158. package/dist/esm/kzg.js +2 -0
  159. package/dist/esm/kzg.js.map +1 -0
  160. package/dist/esm/lock.d.ts +15 -0
  161. package/dist/esm/lock.d.ts.map +1 -0
  162. package/dist/esm/lock.js +41 -0
  163. package/dist/esm/lock.js.map +1 -0
  164. package/dist/esm/mapDB.d.ts +17 -0
  165. package/dist/esm/mapDB.d.ts.map +1 -0
  166. package/dist/esm/mapDB.js +42 -0
  167. package/dist/esm/mapDB.js.map +1 -0
  168. package/dist/esm/package.json +3 -0
  169. package/dist/esm/provider.d.ts +46 -0
  170. package/dist/esm/provider.d.ts.map +1 -0
  171. package/dist/esm/provider.js +79 -0
  172. package/dist/esm/provider.js.map +1 -0
  173. package/dist/esm/request.d.ts +20 -0
  174. package/dist/esm/request.d.ts.map +1 -0
  175. package/dist/esm/request.js +30 -0
  176. package/dist/esm/request.js.map +1 -0
  177. package/dist/esm/signature.d.ts +47 -0
  178. package/dist/esm/signature.d.ts.map +1 -0
  179. package/dist/esm/signature.js +137 -0
  180. package/dist/esm/signature.js.map +1 -0
  181. package/dist/esm/tasks.d.ts +32 -0
  182. package/dist/esm/tasks.d.ts.map +1 -0
  183. package/dist/esm/tasks.js +47 -0
  184. package/dist/esm/tasks.js.map +1 -0
  185. package/dist/esm/types.d.ts +64 -0
  186. package/dist/esm/types.d.ts.map +1 -0
  187. package/dist/esm/types.js +71 -0
  188. package/dist/esm/types.js.map +1 -0
  189. package/dist/esm/units.d.ts +22 -0
  190. package/dist/esm/units.d.ts.map +1 -0
  191. package/dist/esm/units.js +46 -0
  192. package/dist/esm/units.js.map +1 -0
  193. package/dist/esm/withdrawal.d.ts +72 -0
  194. package/dist/esm/withdrawal.d.ts.map +1 -0
  195. package/dist/esm/withdrawal.js +86 -0
  196. package/dist/esm/withdrawal.js.map +1 -0
  197. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  198. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  199. package/package.json +116 -0
  200. package/src/account.ts +630 -0
  201. package/src/address.ts +158 -0
  202. package/src/authorization.ts +180 -0
  203. package/src/bal.ts +761 -0
  204. package/src/binaryTree.ts +353 -0
  205. package/src/blobs.ts +209 -0
  206. package/src/bytes.ts +659 -0
  207. package/src/constants.ts +125 -0
  208. package/src/db.ts +86 -0
  209. package/src/env.ts +9 -0
  210. package/src/errors.ts +28 -0
  211. package/src/helpers.ts +46 -0
  212. package/src/index.ts +88 -0
  213. package/src/internal.ts +212 -0
  214. package/src/kzg.ts +24 -0
  215. package/src/lock.ts +42 -0
  216. package/src/mapDB.ts +57 -0
  217. package/src/provider.ts +109 -0
  218. package/src/request.ts +48 -0
  219. package/src/signature.ts +202 -0
  220. package/src/tasks.ts +59 -0
  221. package/src/types.ts +177 -0
  222. package/src/units.ts +56 -0
  223. package/src/withdrawal.ts +133 -0
@@ -0,0 +1,291 @@
1
+ import { bytesToHex as bytesToUnprefixedHexNoble } from '@noble/hashes/utils.js';
2
+ import type { PrefixedHexString, TransformableToBytes } from './types.ts';
3
+ /**
4
+ * @deprecated
5
+ */
6
+ export declare const bytesToUnprefixedHex: typeof bytesToUnprefixedHexNoble;
7
+ /**
8
+ * Converts a {@link PrefixedHexString} to a {@link Uint8Array}
9
+ * @param {PrefixedHexString} hex The 0x-prefixed hex string to convert
10
+ * @returns {Uint8Array} The converted bytes
11
+ * @throws If the input is not a valid 0x-prefixed hex string
12
+ */
13
+ export declare const hexToBytes: (hex: PrefixedHexString) => Uint8Array;
14
+ export declare const unprefixedHexToBytes: (hex: string) => Uint8Array;
15
+ /**
16
+ * Converts a {@link Uint8Array} to a {@link PrefixedHexString}
17
+ * @param {Uint8Array} bytes the bytes to convert
18
+ * @returns {PrefixedHexString} the hex string
19
+ * @dev Returns `0x` if provided an empty Uint8Array
20
+ */
21
+ export declare const bytesToHex: (bytes: Uint8Array) => PrefixedHexString;
22
+ /**
23
+ * Converts a {@link Uint8Array} to a {@link bigint}
24
+ * @param {Uint8Array} bytes the bytes to convert
25
+ * @returns {bigint}
26
+ */
27
+ export declare const bytesToBigInt: (bytes: Uint8Array, littleEndian?: boolean) => bigint;
28
+ /**
29
+ * Converts a {@link Uint8Array} to a {@link number}.
30
+ * @param {Uint8Array} bytes the bytes to convert
31
+ * @return {number}
32
+ * @throws If the input number exceeds 53 bits.
33
+ */
34
+ export declare const bytesToInt: (bytes: Uint8Array) => number;
35
+ /******************************************/
36
+ /**
37
+ * Converts a {@link number} into a {@link PrefixedHexString}
38
+ * @param {number} i
39
+ * @return {PrefixedHexString}
40
+ */
41
+ export declare const intToHex: (i: number) => PrefixedHexString;
42
+ /**
43
+ * Converts an {@link number} to a {@link Uint8Array}
44
+ * @param {Number} i
45
+ * @return {Uint8Array}
46
+ */
47
+ export declare const intToBytes: (i: number) => Uint8Array;
48
+ /**
49
+ * Converts a {@link bigint} to a {@link Uint8Array}
50
+ * * @param {bigint} num the bigint to convert
51
+ * @returns {Uint8Array}
52
+ */
53
+ export declare const bigIntToBytes: (num: bigint, littleEndian?: boolean) => Uint8Array;
54
+ export interface SetLengthOpts {
55
+ /** Allow truncation if msg exceeds length. Default: false */
56
+ allowTruncate?: boolean;
57
+ }
58
+ /**
59
+ * Left Pads a `Uint8Array` with leading zeros till it has `length` bytes.
60
+ * Throws if input length exceeds target length, unless allowTruncate option is true.
61
+ * @param {Uint8Array} msg the value to pad
62
+ * @param {number} length the number of bytes the output should be
63
+ * @param {SetLengthOpts} opts options object with allowTruncate flag
64
+ * @return {Uint8Array}
65
+ */
66
+ export declare const setLengthLeft: (msg: Uint8Array, length: number, opts?: SetLengthOpts) => Uint8Array;
67
+ /**
68
+ * Right Pads a `Uint8Array` with trailing zeros till it has `length` bytes.
69
+ * Throws if input length exceeds target length, unless allowTruncate option is true.
70
+ * @param {Uint8Array} msg the value to pad
71
+ * @param {number} length the number of bytes the output should be
72
+ * @param {SetLengthOpts} opts options object with allowTruncate flag
73
+ * @return {Uint8Array}
74
+ */
75
+ export declare const setLengthRight: (msg: Uint8Array, length: number, opts?: SetLengthOpts) => Uint8Array;
76
+ /**
77
+ * Trims leading zeros from a `Uint8Array`.
78
+ * @param {Uint8Array} a
79
+ * @return {Uint8Array}
80
+ */
81
+ export declare const unpadBytes: (a: Uint8Array) => Uint8Array;
82
+ /**
83
+ * Trims leading zeros from an `Array` (of numbers).
84
+ * @param {number[]} a
85
+ * @return {number[]}
86
+ */
87
+ export declare const unpadArray: (a: number[]) => number[];
88
+ /**
89
+ * Trims leading zeros from a `PrefixedHexString`.
90
+ * @param {PrefixedHexString} a
91
+ * @return {PrefixedHexString}
92
+ */
93
+ export declare const unpadHex: (a: PrefixedHexString) => PrefixedHexString;
94
+ export type ToBytesInputTypes = PrefixedHexString | number | bigint | Uint8Array | number[] | TransformableToBytes | null | undefined;
95
+ /**
96
+ * Attempts to turn a value into a `Uint8Array`.
97
+ * Inputs supported: `Buffer`, `Uint8Array`, `String` (hex-prefixed), `Number`, null/undefined, `BigInt` and other objects
98
+ * with a `toArray()` or `toBytes()` method.
99
+ * @param {ToBytesInputTypes} v the value
100
+ * @return {Uint8Array}
101
+ */
102
+ export declare const toBytes: (v: ToBytesInputTypes) => Uint8Array;
103
+ /**
104
+ * Interprets a `Uint8Array` as a signed integer and returns a `BigInt`. Assumes 256-bit numbers.
105
+ * @param {Uint8Array} num Signed integer value
106
+ * @returns {bigint}
107
+ */
108
+ export declare const fromSigned: (num: Uint8Array) => bigint;
109
+ /**
110
+ * Converts a `BigInt` to an unsigned integer and returns it as a `Uint8Array`. Assumes 256-bit numbers.
111
+ * @param {bigint} num
112
+ * @returns {Uint8Array}
113
+ */
114
+ export declare const toUnsigned: (num: bigint) => Uint8Array;
115
+ /**
116
+ * Adds "0x" to a given `string` if it does not already start with "0x".
117
+ * @param {string} str
118
+ * @return {PrefixedHexString}
119
+ */
120
+ export declare const addHexPrefix: (str: string) => PrefixedHexString;
121
+ /**
122
+ * Shortens a string or Uint8Array's hex string representation to maxLength (default 50).
123
+ *
124
+ * Examples:
125
+ *
126
+ * Input: '657468657265756d000000000000000000000000000000000000000000000000'
127
+ * Output: '657468657265756d0000000000000000000000000000000000…'
128
+ * @param {Uint8Array | string} bytes
129
+ * @param {number} maxLength
130
+ * @return {string}
131
+ */
132
+ export declare const short: (bytes: Uint8Array | string, maxLength?: number) => string;
133
+ /**
134
+ * Checks provided Uint8Array for leading zeroes and throws if found.
135
+ *
136
+ * Examples:
137
+ *
138
+ * Valid values: 0x1, 0x, 0x01, 0x1234
139
+ * Invalid values: 0x0, 0x00, 0x001, 0x0001
140
+ *
141
+ * Note: This method is useful for validating that RLP encoded integers comply with the rule that all
142
+ * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes
143
+ * @param values An object containing string keys and Uint8Array values
144
+ * @throws if any provided value is found to have leading zero bytes
145
+ */
146
+ export declare const validateNoLeadingZeroes: (values: {
147
+ [key: string]: Uint8Array | undefined;
148
+ }) => void;
149
+ /**
150
+ * Converts a {@link bigint} to a `0x` prefixed hex string
151
+ * @param {bigint} num the bigint to convert
152
+ * @returns {PrefixedHexString}
153
+ */
154
+ export declare const bigIntToHex: (num: bigint) => PrefixedHexString;
155
+ /**
156
+ * Calculates max bigint from an array of bigints
157
+ * @param args array of bigints
158
+ */
159
+ export declare const bigIntMax: (...args: bigint[]) => bigint;
160
+ /**
161
+ * Calculates min BigInt from an array of BigInts
162
+ * @param args array of bigints
163
+ */
164
+ export declare const bigIntMin: (...args: bigint[]) => bigint;
165
+ /**
166
+ * Convert value from bigint to an unpadded Uint8Array
167
+ * (useful for RLP transport)
168
+ * @param {bigint} value the bigint to convert
169
+ * @returns {Uint8Array}
170
+ */
171
+ export declare const bigIntToUnpaddedBytes: (value: bigint) => Uint8Array;
172
+ export declare const bigIntToAddressBytes: (value: bigint, strict?: boolean) => Uint8Array;
173
+ /**
174
+ * Convert value from number to an unpadded Uint8Array
175
+ * (useful for RLP transport)
176
+ * @param {number} value the bigint to convert
177
+ * @returns {Uint8Array}
178
+ */
179
+ export declare const intToUnpaddedBytes: (value: number) => Uint8Array;
180
+ /**
181
+ * Compares two Uint8Arrays and returns a number indicating their order in a sorted array.
182
+ *
183
+ * @param {Uint8Array} value1 - The first Uint8Array to compare.
184
+ * @param {Uint8Array} value2 - The second Uint8Array to compare.
185
+ * @returns {number} A positive number if value1 is larger than value2,
186
+ * A negative number if value1 is smaller than value2,
187
+ * or 0 if value1 and value2 are equal.
188
+ */
189
+ export declare const compareBytes: (value1: Uint8Array, value2: Uint8Array) => number;
190
+ /**
191
+ * Generates a Uint8Array of random bytes of specified length.
192
+ *
193
+ * @param {number} length - The length of the Uint8Array.
194
+ * @returns {Uint8Array} A Uint8Array of random bytes of specified length.
195
+ */
196
+ export declare const randomBytes: (length: number) => Uint8Array;
197
+ /**
198
+ * This mirrors the functionality of the `ethereum-cryptography` export except
199
+ * it skips the check to validate that every element of `arrays` is indeed a `uint8Array`
200
+ * Can give small performance gains on large arrays
201
+ * @param {Uint8Array[]} arrays an array of Uint8Arrays
202
+ * @returns {Uint8Array} one Uint8Array with all the elements of the original set
203
+ * works like `Buffer.concat`
204
+ */
205
+ export declare const concatBytes: (...arrays: Uint8Array[]) => Uint8Array<ArrayBuffer>;
206
+ /**
207
+ * @notice Convert a Uint8Array to a 32-bit integer
208
+ * @param {Uint8Array} bytes The input Uint8Array from which to read the 32-bit integer.
209
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
210
+ * @return {number} The 32-bit integer read from the input Uint8Array.
211
+ */
212
+ export declare function bytesToInt32(bytes: Uint8Array, littleEndian?: boolean): number;
213
+ /**
214
+ * @notice Convert a Uint8Array to a 64-bit bigint
215
+ * @param {Uint8Array} bytes The input Uint8Array from which to read the 64-bit bigint.
216
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
217
+ * @return {bigint} The 64-bit bigint read from the input Uint8Array.
218
+ */
219
+ export declare function bytesToBigInt64(bytes: Uint8Array, littleEndian?: boolean): bigint;
220
+ /**
221
+ * @notice Convert a 32-bit integer to a Uint8Array.
222
+ * @param {number} value The 32-bit integer to convert.
223
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
224
+ * @return {Uint8Array} A Uint8Array of length 4 containing the integer.
225
+ */
226
+ export declare function int32ToBytes(value: number, littleEndian?: boolean): Uint8Array;
227
+ /**
228
+ * @notice Convert a 64-bit bigint to a Uint8Array.
229
+ * @param {bigint} value The 64-bit bigint to convert.
230
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
231
+ * @return {Uint8Array} A Uint8Array of length 8 containing the bigint.
232
+ */
233
+ export declare function bigInt64ToBytes(value: bigint, littleEndian?: boolean): Uint8Array;
234
+ export { utf8ToBytes } from '@noble/hashes/utils.js';
235
+ /**
236
+ * @notice Converts a Uint8Array to a UTF-8 string.
237
+ * Implementation copied from ethereum-cryptography https://github.com/ethereum/js-ethereum-cryptography/blob/31f980b2847545d33268f2510ba38a3836202a44/src/utils.ts#L22-L27
238
+ * @param {Uint8Array} bytes - The input Uint8Array to convert.
239
+ * @returns {string} The UTF-8 string.
240
+ * @throws {TypeError} If the input is not a Uint8Array.
241
+ *
242
+ */
243
+ export declare function bytesToUtf8(bytes: Uint8Array): string;
244
+ /**
245
+ * @notice Compares two Uint8Arrays and returns true if they are equal.
246
+ * Implementation copied from ethereum-cryptography https://github.com/ethereum/js-ethereum-cryptography/blob/main/src/utils.ts#L35-L45
247
+ * @param {Uint8Array} a - The first Uint8Array to compare.
248
+ * @param {Uint8Array} b - The second Uint8Array to compare.
249
+ * @returns {boolean} True if the Uint8Arrays are equal, false otherwise.
250
+ */
251
+ export declare function equalsBytes(a: Uint8Array, b: Uint8Array): boolean;
252
+ export declare function hexToBigInt(input: PrefixedHexString): bigint;
253
+ /**
254
+ * Converts a Uint8Array of bytes into an array of bits.
255
+ * @param {Uint8Array} bytes - The input byte array.
256
+ * @param {number} bitLength - The number of bits to extract from the input bytes.
257
+ * @returns {number[]} An array of bits (each 0 or 1) corresponding to the input bytes.
258
+ */
259
+ export declare function bytesToBits(bytes: Uint8Array, bitLength?: number): number[];
260
+ /**
261
+ * Converts an array of bits into a Uint8Array.
262
+ * The input bits are grouped into sets of 8, with the first bit in each group being the most significant.
263
+ * @param {number[]} bits - The input array of bits (each should be 0 or 1). Its length should be a multiple of 8.
264
+ * @returns {Uint8Array} A Uint8Array constructed from the input bits.
265
+ */
266
+ export declare function bitsToBytes(bits: number[]): Uint8Array;
267
+ /**
268
+ * Compares two byte arrays and returns the count of consecutively matching items from the start.
269
+ * @param {Uint8Array} bytes1 - The first Uint8Array to compare.
270
+ * @param {Uint8Array} bytes2 - The second Uint8Array to compare.
271
+ * @returns {number} The count of consecutively matching items from the start.
272
+ */
273
+ export declare function matchingBytesLength(bytes1: Uint8Array, bytes2: Uint8Array): number;
274
+ /**
275
+ * Compares two arrays of bits (0 or 1) and returns the count of consecutively matching bits from the start.
276
+ * @param {number[]} bits1 - The first array of bits, in bytes or bits.
277
+ * @param {number[]} bits2 - The second array of bits, in bytes or bits.
278
+ * @returns {number} The count of consecutively matching bits from the start.
279
+ */
280
+ export declare function matchingBitsLength(bits1: number[], bits2: number[]): number;
281
+ /**
282
+ * Checks whether two arrays of bits are equal.
283
+ *
284
+ * Two arrays are considered equal if they have the same length and each corresponding element is identical.
285
+ *
286
+ * @param {number[]} bits1 - The first bits array.
287
+ * @param {number[]} bits2 - The second bits array.
288
+ * @returns {boolean} True if the arrays are equal; otherwise, false.
289
+ */
290
+ export declare function equalsBits(bits1: number[], bits2: number[]): boolean;
291
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,yBAAyB,EAGxC,MAAM,wBAAwB,CAAA;AAM/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAIzE;;GAEG;AACH,eAAO,MAAM,oBAAoB,kCAA4B,CAAA;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,iBAAiB,KAAG,UAGnD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,UAGlD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,UAAU,KAAG,iBAK9C,CAAA;AAQD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAA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