viem 0.0.1-alpha.3 → 0.0.1-alpha.31

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 (101) hide show
  1. package/chains/package.json +1 -1
  2. package/contract/package.json +4 -0
  3. package/dist/chain-00b37e4e.d.ts +543 -0
  4. package/dist/chain-38182d92.d.ts +5 -0
  5. package/dist/chains.d.ts +1305 -74
  6. package/dist/chains.js +125 -130
  7. package/dist/chains.js.map +1 -0
  8. package/dist/chains.mjs +129 -0
  9. package/dist/chains.mjs.map +1 -0
  10. package/dist/chunk-5STAX3WF.js +265 -0
  11. package/dist/chunk-5STAX3WF.js.map +1 -0
  12. package/dist/chunk-6ZFIUYGC.mjs +3436 -0
  13. package/dist/chunk-6ZFIUYGC.mjs.map +1 -0
  14. package/dist/chunk-APXHGB76.mjs +197 -0
  15. package/dist/chunk-APXHGB76.mjs.map +1 -0
  16. package/dist/chunk-C54QK7K3.mjs +210 -0
  17. package/dist/chunk-C54QK7K3.mjs.map +1 -0
  18. package/dist/{chunk-YZEQFYZ3.js → chunk-IBWRBL2I.mjs} +725 -556
  19. package/dist/chunk-IBWRBL2I.mjs.map +1 -0
  20. package/dist/chunk-J7QHQ26Y.js +3436 -0
  21. package/dist/chunk-J7QHQ26Y.js.map +1 -0
  22. package/dist/chunk-MYFKW55L.js +210 -0
  23. package/dist/chunk-MYFKW55L.js.map +1 -0
  24. package/dist/chunk-NCPBWOQA.js +1216 -0
  25. package/dist/chunk-NCPBWOQA.js.map +1 -0
  26. package/dist/chunk-QBB3DFIB.mjs +265 -0
  27. package/dist/chunk-QBB3DFIB.mjs.map +1 -0
  28. package/dist/chunk-UUULPQHV.js +197 -0
  29. package/dist/chunk-UUULPQHV.js.map +1 -0
  30. package/dist/contract.d.ts +11 -0
  31. package/dist/contract.js +57 -0
  32. package/dist/contract.js.map +1 -0
  33. package/dist/contract.mjs +57 -0
  34. package/dist/contract.mjs.map +1 -0
  35. package/dist/createClient-5258d590.d.ts +70 -0
  36. package/dist/createPublicClient-99be385b.d.ts +650 -0
  37. package/dist/{eip1193-8b4d90ce.d.ts → eip1193-fcdeee04.d.ts} +13 -10
  38. package/dist/ens.d.ts +22 -0
  39. package/dist/ens.js +22 -0
  40. package/dist/ens.js.map +1 -0
  41. package/dist/ens.mjs +22 -0
  42. package/dist/ens.mjs.map +1 -0
  43. package/dist/formatAbiItem-50cb39d8.d.ts +14 -0
  44. package/dist/getAbiItem-6d4f64d2.d.ts +97 -0
  45. package/dist/index.d.ts +251 -67
  46. package/dist/index.js +769 -344
  47. package/dist/index.js.map +1 -0
  48. package/dist/index.mjs +769 -0
  49. package/dist/index.mjs.map +1 -0
  50. package/dist/namehash-88f4639d.d.ts +22 -0
  51. package/dist/parseGwei-8af7a0a6.d.ts +509 -0
  52. package/dist/public.d.ts +29 -0
  53. package/dist/public.js +60 -0
  54. package/dist/public.js.map +1 -0
  55. package/dist/public.mjs +60 -0
  56. package/dist/public.mjs.map +1 -0
  57. package/dist/test-79ec416c.d.ts +213 -0
  58. package/dist/test.d.ts +20 -0
  59. package/dist/test.js +62 -0
  60. package/dist/test.js.map +1 -0
  61. package/dist/test.mjs +62 -0
  62. package/dist/test.mjs.map +1 -0
  63. package/dist/utils/index.d.ts +52 -7
  64. package/dist/utils/index.js +187 -126
  65. package/dist/utils/index.js.map +1 -0
  66. package/dist/utils/index.mjs +187 -0
  67. package/dist/utils/index.mjs.map +1 -0
  68. package/dist/wallet-cf5c8351.d.ts +115 -0
  69. package/dist/wallet.d.ts +7 -0
  70. package/dist/wallet.js +24 -0
  71. package/dist/wallet.js.map +1 -0
  72. package/dist/wallet.mjs +24 -0
  73. package/dist/wallet.mjs.map +1 -0
  74. package/dist/window.d.ts +5 -2
  75. package/dist/window.js +1 -0
  76. package/dist/window.js.map +1 -0
  77. package/dist/window.mjs +1 -0
  78. package/dist/window.mjs.map +1 -0
  79. package/ens/package.json +4 -0
  80. package/package.json +46 -73
  81. package/public/package.json +4 -0
  82. package/test/package.json +4 -0
  83. package/utils/package.json +1 -1
  84. package/wallet/package.json +4 -0
  85. package/window/package.json +1 -1
  86. package/actions/package.json +0 -4
  87. package/clients/package.json +0 -4
  88. package/dist/actions/index.d.ts +0 -7
  89. package/dist/actions/index.js +0 -124
  90. package/dist/chunk-SRDTRROA.js +0 -1214
  91. package/dist/chunk-TLEMV4T3.js +0 -258
  92. package/dist/chunk-WZITKXV3.js +0 -996
  93. package/dist/clients/index.d.ts +0 -7
  94. package/dist/clients/index.js +0 -23
  95. package/dist/createWalletClient-15ad1601.d.ts +0 -130
  96. package/dist/parseGwei-0f85e8ca.d.ts +0 -248
  97. package/dist/rpc-15b85963.d.ts +0 -292
  98. package/dist/rpc-26932bae.d.ts +0 -61
  99. package/dist/transactionRequest-f538ea86.d.ts +0 -44
  100. package/dist/watchAsset-0c9d01e2.d.ts +0 -522
  101. package/dist/webSocket-b55b0951.d.ts +0 -83
@@ -1,1214 +0,0 @@
1
- import {
2
- AbiDecodingDataSizeInvalidError,
3
- AbiEncodingArrayLengthMismatchError,
4
- AbiEncodingLengthMismatchError,
5
- AbiFunctionNotFoundError,
6
- AbiFunctionSignatureNotFoundError,
7
- DataLengthTooLongError,
8
- DataLengthTooShortError,
9
- InvalidAbiDecodingTypeError,
10
- InvalidAbiEncodingTypeError,
11
- InvalidAddressError,
12
- InvalidArrayError,
13
- InvalidBytesBooleanError,
14
- InvalidDefinitionTypeError,
15
- InvalidHexBooleanError,
16
- InvalidHexValueError,
17
- OffsetOutOfBoundsError,
18
- SizeExceedsPaddingSizeError
19
- } from "./chunk-WZITKXV3.js";
20
-
21
- // src/utils/data/concat.ts
22
- function concat(values) {
23
- if (typeof values[0] === "string")
24
- return concatHex(values);
25
- return concatBytes(values);
26
- }
27
- function concatBytes(values) {
28
- let length = 0;
29
- for (const arr of values) {
30
- length += arr.length;
31
- }
32
- const result = new Uint8Array(length);
33
- let offset = 0;
34
- for (const arr of values) {
35
- result.set(arr, offset);
36
- offset += arr.length;
37
- }
38
- return result;
39
- }
40
- function concatHex(values) {
41
- return `0x${values.reduce(
42
- (acc, x) => acc + x.replace("0x", ""),
43
- ""
44
- )}`;
45
- }
46
-
47
- // src/utils/data/isBytes.ts
48
- function isBytes(value) {
49
- if (!value)
50
- return false;
51
- if (typeof value !== "object")
52
- return false;
53
- return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
54
- }
55
-
56
- // src/utils/data/isHex.ts
57
- function isHex(value) {
58
- if (!value)
59
- return false;
60
- if (typeof value !== "string")
61
- return false;
62
- return /^0x[0-9a-fA-F]*$/.test(value);
63
- }
64
-
65
- // src/utils/data/pad.ts
66
- function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
67
- if (typeof hexOrBytes === "string")
68
- return padHex(hexOrBytes, { dir, size: size2 });
69
- return padBytes(hexOrBytes, { dir, size: size2 });
70
- }
71
- function padHex(hex_, { dir, size: size2 = 32 } = {}) {
72
- let hex = hex_.replace("0x", "");
73
- if (hex.length > size2 * 2)
74
- throw new SizeExceedsPaddingSizeError({
75
- size: Math.ceil(hex.length / 2),
76
- targetSize: size2,
77
- type: "hex"
78
- });
79
- return `0x${hex[dir === "right" ? "padEnd" : "padStart"](
80
- size2 * 2,
81
- "0"
82
- )}`;
83
- }
84
- function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
85
- if (bytes.length > size2)
86
- throw new SizeExceedsPaddingSizeError({
87
- size: bytes.length,
88
- targetSize: size2,
89
- type: "bytes"
90
- });
91
- const paddedBytes = new Uint8Array(size2);
92
- for (let i = 0; i < size2; i++) {
93
- const padEnd = dir === "right";
94
- paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
95
- }
96
- return paddedBytes;
97
- }
98
-
99
- // src/utils/data/trim.ts
100
- function trim(hexOrBytes, { dir = "left" } = {}) {
101
- let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
102
- let sliceLength = 0;
103
- for (let i = 0; i < data.length - 1; i++) {
104
- if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
105
- sliceLength++;
106
- else
107
- break;
108
- }
109
- data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
110
- if (typeof hexOrBytes === "string") {
111
- if (data.length === 1 && dir === "right")
112
- data = `${data}0`;
113
- return `0x${data}`;
114
- }
115
- return data;
116
- }
117
-
118
- // src/utils/data/size.ts
119
- function size(value) {
120
- if (isHex(value))
121
- return Math.ceil((value.length - 2) / 2);
122
- return value.length;
123
- }
124
-
125
- // src/utils/data/slice.ts
126
- function slice(value, start, end) {
127
- if (isHex(value))
128
- return sliceHex(value, start, end);
129
- return sliceBytes(value, start, end);
130
- }
131
- function assertStartOffset(value, start) {
132
- if (typeof start === "number" && start > 0 && start > size(value) - 1)
133
- throw new Error(
134
- `Slice starting at offset "${start}" is out-of-bounds (size: ${size(
135
- value
136
- )}).`
137
- );
138
- }
139
- function sliceBytes(value, start, end) {
140
- assertStartOffset(value, start);
141
- return value.slice(start, end);
142
- }
143
- function sliceHex(value_, start, end) {
144
- assertStartOffset(value_, start);
145
- const value = value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2);
146
- return `0x${value}`;
147
- }
148
-
149
- // src/utils/encoding/encodeHex.ts
150
- var hexes = Array.from(
151
- { length: 256 },
152
- (v, i) => i.toString(16).padStart(2, "0")
153
- );
154
- function boolToHex(value) {
155
- return `0x${Number(value)}`;
156
- }
157
- function bytesToHex(value) {
158
- let hex = "";
159
- for (let i = 0; i < value.length; i++) {
160
- hex += hexes[value[i]];
161
- }
162
- return `0x${hex}`;
163
- }
164
- function encodeHex(value) {
165
- if (typeof value === "number" || typeof value === "bigint")
166
- return numberToHex(value);
167
- if (typeof value === "string") {
168
- return stringToHex(value);
169
- }
170
- if (typeof value === "boolean")
171
- return boolToHex(value);
172
- return bytesToHex(value);
173
- }
174
- function numberToHex(value_, opts = {}) {
175
- const { signed, size: size2 } = opts;
176
- let value = BigInt(value_);
177
- let maxValue;
178
- if (size2) {
179
- if (signed)
180
- maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n;
181
- else
182
- maxValue = 2n ** (BigInt(size2) * 8n) - 1n;
183
- } else if (typeof value_ === "number") {
184
- maxValue = BigInt(Number.MAX_SAFE_INTEGER);
185
- }
186
- const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
187
- if (maxValue && value > maxValue || value < minValue) {
188
- const suffix = typeof value_ === "bigint" ? "n" : "";
189
- throw new Error(
190
- `Number "${value_}${suffix}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${maxValue ? `(${minValue}${suffix} to ${maxValue}${suffix})` : `(above ${minValue})`}`
191
- );
192
- }
193
- const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
194
- if (size2)
195
- return pad(hex, { size: size2 });
196
- return hex;
197
- }
198
- function stringToHex(value) {
199
- let hex = "";
200
- for (let i = 0; i < value.length; i++) {
201
- hex += value.charCodeAt(i).toString(16);
202
- }
203
- return `0x${hex}`;
204
- }
205
-
206
- // src/utils/encoding/encodeBytes.ts
207
- var encoder = new TextEncoder();
208
- function boolToBytes(value) {
209
- const bytes = new Uint8Array(1);
210
- bytes[0] = Number(value);
211
- return bytes;
212
- }
213
- function encodeBytes(value) {
214
- if (typeof value === "number" || typeof value === "bigint")
215
- return numberToBytes(value);
216
- if (typeof value === "boolean")
217
- return boolToBytes(value);
218
- if (value.startsWith("0x"))
219
- return hexToBytes(value);
220
- return stringToBytes(value);
221
- }
222
- function hexToBytes(hex_) {
223
- let hex = hex_.slice(2);
224
- if (hex.length % 2)
225
- hex = `0${hex}`;
226
- const bytes = new Uint8Array(hex.length / 2);
227
- for (let index = 0; index < bytes.length; index++) {
228
- const start = index * 2;
229
- const hexByte = hex.slice(start, start + 2);
230
- const byte = Number.parseInt(hexByte, 16);
231
- if (Number.isNaN(byte) || byte < 0)
232
- throw new Error("Invalid byte sequence");
233
- bytes[index] = byte;
234
- }
235
- return bytes;
236
- }
237
- function numberToBytes(value, opts) {
238
- const hex = numberToHex(value, opts);
239
- return hexToBytes(hex);
240
- }
241
- function stringToBytes(value) {
242
- return encoder.encode(value);
243
- }
244
-
245
- // src/utils/encoding/encodeRlp.ts
246
- function encodeRlp(hexOrBytes, to_) {
247
- const to = to_ || "hex";
248
- return format(bytesToRlp(parse(hexOrBytes)), to);
249
- }
250
- function parse(hexOrBytes) {
251
- if (Array.isArray(hexOrBytes))
252
- return hexOrBytes.map(parse);
253
- return typeof hexOrBytes === "string" ? encodeBytes(hexOrBytes) : hexOrBytes;
254
- }
255
- function format(bytes, type = "bytes") {
256
- return type === "hex" ? bytesToHex(bytes) : bytes;
257
- }
258
- function bytesToRlp(bytes) {
259
- if (Array.isArray(bytes)) {
260
- const encoded = concat(bytes.map(bytesToRlp));
261
- return new Uint8Array([...encodeLength(encoded.length, 192), ...encoded]);
262
- }
263
- if (bytes.length === 1 && bytes[0] < 128)
264
- return bytes;
265
- return new Uint8Array([...encodeLength(bytes.length, 128), ...bytes]);
266
- }
267
- function encodeLength(length, offset) {
268
- if (length < 56)
269
- return [offset + length];
270
- return [encodeBytes(length).length + offset + 55, ...encodeBytes(length)];
271
- }
272
-
273
- // src/utils/encoding/decodeHex.ts
274
- function decodeHex(hex, to) {
275
- if (to === "number")
276
- return hexToNumber(hex);
277
- if (to === "bigint")
278
- return hexToBigInt(hex);
279
- if (to === "string")
280
- return hexToString(hex);
281
- if (to === "boolean")
282
- return hexToBool(hex);
283
- return hexToBytes(hex);
284
- }
285
- function hexToBigInt(hex, opts = {}) {
286
- const { signed } = opts;
287
- const value = BigInt(hex);
288
- if (!signed)
289
- return value;
290
- const size2 = (hex.length - 2) / 2;
291
- const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
292
- if (value <= max)
293
- return value;
294
- return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
295
- }
296
- function hexToBool(hex) {
297
- if (trim(hex) === "0x0")
298
- return false;
299
- if (trim(hex) === "0x1")
300
- return true;
301
- throw new InvalidHexBooleanError(hex);
302
- }
303
- function hexToNumber(hex, opts = {}) {
304
- return Number(hexToBigInt(hex, opts));
305
- }
306
- function hexToString(hex) {
307
- const bytes = hexToBytes(hex);
308
- return new TextDecoder().decode(bytes);
309
- }
310
-
311
- // src/utils/encoding/decodeBytes.ts
312
- function decodeBytes(bytes, to) {
313
- if (to === "number")
314
- return bytesToNumber(bytes);
315
- if (to === "bigint")
316
- return bytesToBigint(bytes);
317
- if (to === "boolean")
318
- return bytesToBool(bytes);
319
- if (to === "string")
320
- return bytesToString(bytes);
321
- return bytesToHex(bytes);
322
- }
323
- function bytesToBigint(bytes) {
324
- const hex = bytesToHex(bytes);
325
- return hexToBigInt(hex);
326
- }
327
- function bytesToBool(bytes) {
328
- if (bytes.length > 1 || bytes[0] > 1)
329
- throw new InvalidBytesBooleanError(bytes);
330
- return Boolean(bytes[0]);
331
- }
332
- function bytesToNumber(bytes) {
333
- const hex = bytesToHex(bytes);
334
- return hexToNumber(hex);
335
- }
336
- function bytesToString(bytes) {
337
- return new TextDecoder().decode(bytes);
338
- }
339
-
340
- // src/utils/encoding/decodeRlp.ts
341
- function decodeRlp(value, to) {
342
- const bytes = parse2(value);
343
- const [data, consumed] = rlpToBytes(bytes);
344
- if (consumed < bytes.length)
345
- throw new DataLengthTooLongError({
346
- consumed,
347
- length: bytes.length
348
- });
349
- return format2(data, to);
350
- }
351
- function parse2(value) {
352
- if (typeof value === "string") {
353
- if (value.length > 3 && value.length % 2 !== 0)
354
- throw new InvalidHexValueError(value);
355
- return hexToBytes(value);
356
- }
357
- return value;
358
- }
359
- function format2(bytes, to) {
360
- if (Array.isArray(bytes))
361
- return bytes.map((b) => format2(b, to));
362
- return to === "hex" ? trim(bytesToHex(bytes)) : bytes;
363
- }
364
- function rlpToBytes(bytes, offset = 0) {
365
- if (bytes.length === 0)
366
- return [new Uint8Array([]), 0];
367
- const prefix = bytes[offset];
368
- if (prefix <= 127)
369
- return [new Uint8Array([bytes[offset]]), 1];
370
- if (prefix <= 183) {
371
- const length2 = prefix - 128;
372
- const offset_ = offset + 1;
373
- if (offset_ + length2 > bytes.length)
374
- throw new DataLengthTooShortError({
375
- length: offset_ + length2,
376
- dataLength: bytes.length
377
- });
378
- return [bytes.slice(offset_, offset_ + length2), 1 + length2];
379
- }
380
- if (prefix <= 191) {
381
- const lengthOfLength2 = prefix - 183;
382
- const offset_ = offset + 1;
383
- const length2 = bytesToNumber(bytes.slice(offset_, offset_ + lengthOfLength2));
384
- if (offset_ + lengthOfLength2 + length2 > bytes.length)
385
- throw new DataLengthTooShortError({
386
- length: lengthOfLength2 + length2,
387
- dataLength: bytes.length - lengthOfLength2
388
- });
389
- return [
390
- bytes.slice(offset_ + lengthOfLength2, offset_ + lengthOfLength2 + length2),
391
- 1 + lengthOfLength2 + length2
392
- ];
393
- }
394
- let lengthOfLength = 0;
395
- let length = prefix - 192;
396
- if (prefix > 247) {
397
- lengthOfLength = prefix - 247;
398
- length = bytesToNumber(bytes.slice(offset + 1, offset + 1 + lengthOfLength));
399
- }
400
- let nextOffset = offset + 1 + lengthOfLength;
401
- if (nextOffset > bytes.length)
402
- throw new DataLengthTooShortError({
403
- length: nextOffset,
404
- dataLength: bytes.length
405
- });
406
- let consumed = 1 + lengthOfLength + length;
407
- let result = [];
408
- while (nextOffset < offset + consumed) {
409
- const decoded = rlpToBytes(bytes, nextOffset);
410
- result.push(decoded[0]);
411
- nextOffset += decoded[1];
412
- if (nextOffset > offset + consumed)
413
- throw new OffsetOutOfBoundsError({
414
- nextOffset,
415
- offset: offset + consumed
416
- });
417
- }
418
- return [result, consumed];
419
- }
420
-
421
- // src/utils/solidity.ts
422
- var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
423
- function extractFunctionParts(def) {
424
- const parts = def.match(paramsRegex);
425
- const type = parts?.[2] || void 0;
426
- const name = parts?.[3];
427
- const params = parts?.[5] || void 0;
428
- return { type, name, params };
429
- }
430
- function extractFunctionName(def) {
431
- return extractFunctionParts(def).name;
432
- }
433
- function extractFunctionParams(def) {
434
- const params = extractFunctionParts(def).params;
435
- const splitParams = params?.split(",").map((x) => x.trim().split(" "));
436
- return splitParams?.map((param) => ({
437
- type: param[0],
438
- name: param[1] === "indexed" ? param[2] : param[1],
439
- ...param[1] === "indexed" ? { indexed: true } : {}
440
- }));
441
- }
442
- function extractFunctionType(def) {
443
- return extractFunctionParts(def).type;
444
- }
445
-
446
- // src/utils/hash/keccak256.ts
447
- import { keccak_256 } from "@noble/hashes/sha3";
448
- function keccak256(value, to_) {
449
- const to = to_ || "hex";
450
- const bytes = keccak_256(value);
451
- if (to === "bytes")
452
- return bytes;
453
- return encodeHex(bytes);
454
- }
455
-
456
- // src/utils/hash/hashFunction.ts
457
- var hash = (value) => keccak256(encodeBytes(value));
458
- function hashFunction(def) {
459
- const name = extractFunctionName(def);
460
- const params = extractFunctionParams(def);
461
- if (!params || params.length === 0)
462
- return hash(def.replace(/ /g, ""));
463
- return hash(`${name}(${params.map(({ type }) => type).join(",")})`);
464
- }
465
-
466
- // src/utils/hash/getEventSignature.ts
467
- var getEventSignature = (event) => hashFunction(event);
468
-
469
- // src/utils/hash/getFunctionSignature.ts
470
- var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
471
-
472
- // src/utils/address/getAddress.ts
473
- var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
474
- function checksumAddress(address_) {
475
- const hexAddress = address_.substring(2).toLowerCase();
476
- const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
477
- let address = hexAddress.split("");
478
- for (let i = 0; i < 40; i += 2) {
479
- if (hash2?.[i >> 1] >> 4 >= 8) {
480
- address[i] = address[i].toUpperCase();
481
- }
482
- if ((hash2[i >> 1] & 15) >= 8) {
483
- address[i + 1] = address[i + 1].toUpperCase();
484
- }
485
- }
486
- return `0x${address.join("")}`;
487
- }
488
- function getAddress(address) {
489
- if (!addressRegex.test(address))
490
- throw new InvalidAddressError({ address });
491
- return checksumAddress(address);
492
- }
493
-
494
- // src/utils/address/getContractAddress.ts
495
- function getContractAddress(opts) {
496
- if (opts.opcode === "CREATE2")
497
- return getCreate2Address(opts);
498
- return getCreateAddress(opts);
499
- }
500
- function getCreateAddress(opts) {
501
- const from = encodeBytes(getAddress(opts.from));
502
- let nonce = encodeBytes(opts.nonce);
503
- if (nonce[0] === 0)
504
- nonce = new Uint8Array([]);
505
- return getAddress(
506
- `0x${keccak256(encodeRlp([from, nonce], "bytes")).slice(26)}`
507
- );
508
- }
509
- function getCreate2Address(opts) {
510
- const from = encodeBytes(getAddress(opts.from));
511
- const salt = pad(
512
- isBytes(opts.salt) ? opts.salt : encodeBytes(opts.salt),
513
- { size: 32 }
514
- );
515
- const bytecodeHash = encodeBytes(
516
- keccak256(
517
- isBytes(opts.bytecode) ? opts.bytecode : encodeBytes(opts.bytecode)
518
- )
519
- );
520
- return getAddress(
521
- slice(
522
- keccak256(concat([encodeBytes("0xff"), from, salt, bytecodeHash])),
523
- 12
524
- )
525
- );
526
- }
527
-
528
- // src/utils/address/isAddress.ts
529
- function isAddress(address) {
530
- try {
531
- return Boolean(getAddress(address));
532
- } catch {
533
- return false;
534
- }
535
- }
536
-
537
- // src/utils/address/isAddressEqual.ts
538
- function isAddressEqual(a, b) {
539
- return getAddress(a) === getAddress(b);
540
- }
541
-
542
- // src/utils/abi/encodeAbi.ts
543
- function encodeAbi({
544
- params,
545
- values
546
- }) {
547
- if (params.length !== values.length)
548
- throw new AbiEncodingLengthMismatchError({
549
- expectedLength: params.length,
550
- givenLength: values.length
551
- });
552
- const preparedParams = prepareParams({ params, values });
553
- const data = encodeParams(preparedParams);
554
- if (data.length === 0)
555
- return void 0;
556
- return data;
557
- }
558
- function prepareParams({
559
- params,
560
- values
561
- }) {
562
- let preparedParams = [];
563
- for (let i = 0; i < params.length; i++) {
564
- preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
565
- }
566
- return preparedParams;
567
- }
568
- function prepareParam({
569
- param,
570
- value
571
- }) {
572
- const arrayComponents = getArrayComponents(param.type);
573
- if (arrayComponents) {
574
- const [length, type] = arrayComponents;
575
- return encodeArray(value, { length, param: { ...param, type } });
576
- }
577
- if (param.type === "tuple") {
578
- return encodeTuple(value, {
579
- param
580
- });
581
- }
582
- if (param.type === "address") {
583
- return encodeAddress(value);
584
- }
585
- if (param.type === "bool") {
586
- return encodeBool(value);
587
- }
588
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
589
- const signed = param.type.startsWith("int");
590
- return encodeNumber(value, { signed });
591
- }
592
- if (param.type.startsWith("bytes")) {
593
- return encodeBytes2(value, { param });
594
- }
595
- if (param.type === "string") {
596
- return encodeString(value);
597
- }
598
- throw new InvalidAbiEncodingTypeError(param.type);
599
- }
600
- function encodeParams(preparedParams) {
601
- let staticSize = 0;
602
- for (let i = 0; i < preparedParams.length; i++) {
603
- const { dynamic, encoded } = preparedParams[i];
604
- if (dynamic)
605
- staticSize += 32;
606
- else
607
- staticSize += size(encoded);
608
- }
609
- let staticParams = [];
610
- let dynamicParams = [];
611
- let dynamicSize = 0;
612
- for (let i = 0; i < preparedParams.length; i++) {
613
- const { dynamic, encoded } = preparedParams[i];
614
- if (dynamic) {
615
- staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
616
- dynamicParams.push(encoded);
617
- dynamicSize += size(encoded);
618
- } else {
619
- staticParams.push(encoded);
620
- }
621
- }
622
- return concat([...staticParams, ...dynamicParams]);
623
- }
624
- function encodeAddress(value) {
625
- return { dynamic: false, encoded: padHex(value.toLowerCase()) };
626
- }
627
- function encodeArray(value, {
628
- length,
629
- param
630
- }) {
631
- let dynamic = length === null;
632
- if (!Array.isArray(value))
633
- throw new InvalidArrayError(value);
634
- if (!dynamic && value.length !== length)
635
- throw new AbiEncodingArrayLengthMismatchError({
636
- expectedLength: length,
637
- givenLength: value.length,
638
- type: `${param.type}[${length}]`
639
- });
640
- let dynamicChild = false;
641
- let preparedParams = [];
642
- for (let i = 0; i < value.length; i++) {
643
- const preparedParam = prepareParam({ param, value: value[i] });
644
- if (preparedParam.dynamic)
645
- dynamicChild = true;
646
- preparedParams.push(preparedParam);
647
- }
648
- if (dynamic || dynamicChild) {
649
- const data = encodeParams(preparedParams);
650
- if (dynamic) {
651
- const length2 = numberToHex(preparedParams.length, { size: 32 });
652
- return {
653
- dynamic: true,
654
- encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
655
- };
656
- }
657
- if (dynamicChild)
658
- return { dynamic: true, encoded: data };
659
- }
660
- return {
661
- dynamic: false,
662
- encoded: concat(preparedParams.map(({ encoded }) => encoded))
663
- };
664
- }
665
- function encodeBytes2(value, { param }) {
666
- const [_, size_] = param.type.split("bytes");
667
- if (!size_)
668
- return {
669
- dynamic: true,
670
- encoded: concat([
671
- padHex(numberToHex(size(value), { size: 32 })),
672
- padHex(value, { dir: "right" })
673
- ])
674
- };
675
- return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
676
- }
677
- function encodeBool(value) {
678
- return { dynamic: false, encoded: padHex(boolToHex(value)) };
679
- }
680
- function encodeNumber(value, { signed }) {
681
- return {
682
- dynamic: false,
683
- encoded: numberToHex(value, {
684
- size: 32,
685
- signed
686
- })
687
- };
688
- }
689
- function encodeString(value) {
690
- return {
691
- dynamic: true,
692
- encoded: concat([
693
- padHex(numberToHex(value.length, { size: 32 })),
694
- padHex(stringToHex(value), { dir: "right" })
695
- ])
696
- };
697
- }
698
- function encodeTuple(value, { param }) {
699
- let dynamic = false;
700
- let preparedParams = [];
701
- for (let i = 0; i < param.components.length; i++) {
702
- const param_ = param.components[i];
703
- const index = Array.isArray(value) ? i : param_.name;
704
- const preparedParam = prepareParam({
705
- param: param_,
706
- value: value[index]
707
- });
708
- preparedParams.push(preparedParam);
709
- dynamic = preparedParam.dynamic;
710
- }
711
- return {
712
- dynamic,
713
- encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
714
- };
715
- }
716
- function getArrayComponents(type) {
717
- const matches = type.match(/^(.*)\[(\d+)?\]$/);
718
- return matches ? [matches[2] ? Number(matches[2]) : null, matches[1]] : void 0;
719
- }
720
-
721
- // src/utils/abi/decodeAbi.ts
722
- function decodeAbi({
723
- data,
724
- params
725
- }) {
726
- if (size(data) % 32 !== 0)
727
- throw new AbiDecodingDataSizeInvalidError(size(data));
728
- return decodeParams({
729
- data,
730
- params
731
- });
732
- }
733
- function decodeParams({
734
- data,
735
- params
736
- }) {
737
- let decodedValues = [];
738
- let position = 0;
739
- for (let i = 0; i < params.length; i++) {
740
- const param = params[i];
741
- const { consumed, value } = decodeParam({ data, param, position });
742
- decodedValues.push(value);
743
- position += consumed;
744
- }
745
- return decodedValues;
746
- }
747
- function decodeParam({
748
- data,
749
- param,
750
- position
751
- }) {
752
- const arrayComponents = getArrayComponents(param.type);
753
- if (arrayComponents) {
754
- const [length, type] = arrayComponents;
755
- return decodeArray(data, {
756
- length,
757
- param: { ...param, type },
758
- position
759
- });
760
- }
761
- if (param.type === "tuple") {
762
- return decodeTuple(data, { param, position });
763
- }
764
- if (param.type === "string") {
765
- return decodeString(data, { position });
766
- }
767
- if (param.type.startsWith("bytes")) {
768
- return decodeBytes2(data, { param, position });
769
- }
770
- let value = slice(data, position, position + 32);
771
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
772
- return decodeNumber(value, { param });
773
- }
774
- if (param.type === "address") {
775
- return decodeAddress(value);
776
- }
777
- if (param.type === "bool") {
778
- return decodeBool(value);
779
- }
780
- throw new InvalidAbiDecodingTypeError(param.type);
781
- }
782
- function decodeAddress(value) {
783
- return { consumed: 32, value: checksumAddress(trim(value)) };
784
- }
785
- function decodeArray(data, {
786
- param,
787
- length,
788
- position
789
- }) {
790
- if (!length) {
791
- const offset = hexToNumber(slice(data, position, position + 32));
792
- const length2 = hexToNumber(slice(data, offset, offset + 32));
793
- let consumed2 = 0;
794
- let value2 = [];
795
- for (let i = 0; i < length2; ++i) {
796
- const decodedChild = decodeParam({
797
- data: slice(data, offset + 32),
798
- param,
799
- position: consumed2
800
- });
801
- consumed2 += decodedChild.consumed;
802
- value2.push(decodedChild.value);
803
- }
804
- return { value: value2, consumed: 32 };
805
- }
806
- if (hasDynamicChild(param)) {
807
- const arrayComponents = getArrayComponents(param.type);
808
- const dynamicChild = !arrayComponents?.[0];
809
- let consumed2 = 0;
810
- let value2 = [];
811
- for (let i = 0; i < length; ++i) {
812
- const offset = hexToNumber(slice(data, position, position + 32));
813
- const decodedChild = decodeParam({
814
- data: slice(data, offset),
815
- param,
816
- position: dynamicChild ? consumed2 : i * 32
817
- });
818
- consumed2 += decodedChild.consumed;
819
- value2.push(decodedChild.value);
820
- }
821
- return { value: value2, consumed: consumed2 };
822
- }
823
- let consumed = 0;
824
- let value = [];
825
- for (let i = 0; i < length; ++i) {
826
- const decodedChild = decodeParam({
827
- data,
828
- param,
829
- position: position + consumed
830
- });
831
- consumed += decodedChild.consumed;
832
- value.push(decodedChild.value);
833
- }
834
- return { value, consumed };
835
- }
836
- function decodeBool(value) {
837
- return { consumed: 32, value: hexToBool(value) };
838
- }
839
- function decodeBytes2(data, { param, position }) {
840
- const [_, size2] = param.type.split("bytes");
841
- if (!size2) {
842
- const offset = hexToNumber(slice(data, position, position + 32));
843
- const length = hexToNumber(slice(data, offset, offset + 32));
844
- const value2 = slice(data, offset + 32, offset + 32 + length);
845
- return { consumed: 32, value: value2 };
846
- }
847
- const value = slice(data, position, position + parseInt(size2));
848
- return { consumed: 32, value };
849
- }
850
- function decodeNumber(value, { param }) {
851
- const signed = param.type.startsWith("int");
852
- const size2 = parseInt(param.type.split("int")[1] || "256");
853
- return {
854
- consumed: 32,
855
- value: size2 > 48 ? hexToBigInt(value, { signed }) : hexToNumber(value, { signed })
856
- };
857
- }
858
- function decodeString(data, { position }) {
859
- const offset = hexToNumber(slice(data, position, position + 32));
860
- const length = hexToNumber(slice(data, offset, offset + 32));
861
- const value = hexToString(
862
- trim(slice(data, offset + 32, offset + 32 + length))
863
- );
864
- return { consumed: 32, value };
865
- }
866
- function decodeTuple(data, { param, position }) {
867
- const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
868
- let value = hasUnnamedChild ? [] : {};
869
- let consumed = 0;
870
- if (hasDynamicChild(param)) {
871
- const offset = hexToNumber(slice(data, position, position + 32));
872
- for (let i = 0; i < param.components.length; ++i) {
873
- const component = param.components[i];
874
- const decodedChild = decodeParam({
875
- data: slice(data, offset),
876
- param: component,
877
- position: consumed
878
- });
879
- consumed += decodedChild.consumed;
880
- value[hasUnnamedChild ? i : component?.name] = decodedChild.value;
881
- }
882
- return { consumed: 32, value };
883
- }
884
- for (let i = 0; i < param.components.length; ++i) {
885
- const component = param.components[i];
886
- const decodedChild = decodeParam({
887
- data,
888
- param: component,
889
- position: position + consumed
890
- });
891
- consumed += decodedChild.consumed;
892
- value[hasUnnamedChild ? i : component?.name] = decodedChild.value;
893
- }
894
- return { consumed, value };
895
- }
896
- function hasDynamicChild(param) {
897
- const { type } = param;
898
- if (type === "string")
899
- return true;
900
- if (type === "bytes")
901
- return true;
902
- if (type.endsWith("[]"))
903
- return true;
904
- if (type === "tuple")
905
- return param.components?.some(hasDynamicChild);
906
- const arrayComponents = getArrayComponents(param.type);
907
- if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
908
- return true;
909
- return false;
910
- }
911
-
912
- // src/utils/abi/getDefinition.ts
913
- function getDefinition(description) {
914
- if (description.type !== "function" && description.type !== "event" && description.type !== "error")
915
- throw new InvalidDefinitionTypeError(description.type);
916
- return `${description.name}(${getParams(description.inputs)})`;
917
- }
918
- function getParams(params) {
919
- if (!params)
920
- return "";
921
- return params.map(getParam).join(",");
922
- }
923
- function getParam(param) {
924
- if (param.type.startsWith("tuple")) {
925
- return `(${getParams(
926
- param.components
927
- )})${param.type.slice("tuple".length)}`;
928
- }
929
- return param.type;
930
- }
931
-
932
- // src/utils/abi/decodeFunctionData.ts
933
- function decodeFunctionData({ abi, data }) {
934
- const signature = slice(data, 0, 4);
935
- const description = abi.find(
936
- (x) => signature === getFunctionSignature(getDefinition(x))
937
- );
938
- if (!description)
939
- throw new AbiFunctionSignatureNotFoundError(signature);
940
- return {
941
- functionName: description.name,
942
- args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
943
- };
944
- }
945
-
946
- // src/utils/abi/encodeFunctionData.ts
947
- function encodeFunctionData({
948
- abi,
949
- args,
950
- functionName
951
- }) {
952
- const description = abi.find((x) => "name" in x && x.name === functionName);
953
- if (!description)
954
- throw new AbiFunctionNotFoundError(functionName);
955
- const definition = getDefinition(description);
956
- const signature = getFunctionSignature(definition);
957
- const data = "inputs" in description && description.inputs ? encodeAbi({
958
- params: description.inputs,
959
- values: args ?? []
960
- }) : void 0;
961
- return concatHex([signature, data ?? "0x"]);
962
- }
963
-
964
- // src/constants.ts
965
- var etherUnits = {
966
- gwei: 9,
967
- wei: 18
968
- };
969
- var gweiUnits = {
970
- ether: -9,
971
- wei: 9
972
- };
973
- var weiUnits = {
974
- ether: -18,
975
- gwei: -9
976
- };
977
- var transactionType = {
978
- "0x0": "legacy",
979
- "0x1": "eip2930",
980
- "0x2": "eip1559"
981
- };
982
-
983
- // src/utils/formatters/transaction.ts
984
- function formatTransaction(transaction) {
985
- const transaction_ = {
986
- ...transaction,
987
- blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
988
- gas: transaction.gas ? BigInt(transaction.gas) : void 0,
989
- gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
990
- maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
991
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? BigInt(transaction.maxPriorityFeePerGas) : void 0,
992
- nonce: transaction.nonce ? hexToNumber(transaction.nonce) : void 0,
993
- transactionIndex: transaction.transactionIndex ? Number(transaction.transactionIndex) : null,
994
- type: transaction.type ? transactionType[transaction.type] : void 0,
995
- value: transaction.value ? BigInt(transaction.value) : void 0,
996
- v: transaction.v ? BigInt(transaction.v) : void 0
997
- };
998
- if (transaction_.type === "legacy") {
999
- delete transaction_["accessList"];
1000
- delete transaction_["maxFeePerGas"];
1001
- delete transaction_["maxPriorityFeePerGas"];
1002
- }
1003
- if (transaction_.type === "eip2930") {
1004
- delete transaction_["maxFeePerGas"];
1005
- delete transaction_["maxPriorityFeePerGas"];
1006
- }
1007
- return transaction_;
1008
- }
1009
-
1010
- // src/utils/formatters/block.ts
1011
- function formatBlock(block) {
1012
- const transactions = block.transactions?.map((transaction) => {
1013
- if (typeof transaction === "string")
1014
- return transaction;
1015
- return formatTransaction(transaction);
1016
- });
1017
- return {
1018
- ...block,
1019
- baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
1020
- difficulty: block.difficulty ? BigInt(block.difficulty) : void 0,
1021
- gasLimit: block.gasLimit ? BigInt(block.gasLimit) : void 0,
1022
- gasUsed: block.gasUsed ? BigInt(block.gasUsed) : void 0,
1023
- number: block.number ? BigInt(block.number) : null,
1024
- size: block.size ? BigInt(block.size) : void 0,
1025
- timestamp: block.timestamp ? BigInt(block.timestamp) : void 0,
1026
- transactions,
1027
- totalDifficulty: block.totalDifficulty ? BigInt(block.totalDifficulty) : null
1028
- };
1029
- }
1030
-
1031
- // src/utils/formatters/feeHistory.ts
1032
- function formatFeeHistory(feeHistory) {
1033
- return {
1034
- baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
1035
- gasUsedRatio: feeHistory.gasUsedRatio,
1036
- oldestBlock: BigInt(feeHistory.oldestBlock),
1037
- reward: feeHistory.reward?.map(
1038
- (reward) => reward.map((value) => BigInt(value))
1039
- )
1040
- };
1041
- }
1042
-
1043
- // src/utils/formatters/format.ts
1044
- function format3(data, { formatter }) {
1045
- return formatter(data);
1046
- }
1047
-
1048
- // src/utils/formatters/log.ts
1049
- function formatLog(log) {
1050
- return {
1051
- ...log,
1052
- blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
1053
- logIndex: log.logIndex ? BigInt(log.logIndex) : null,
1054
- transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null
1055
- };
1056
- }
1057
-
1058
- // src/utils/formatters/transactionReceipt.ts
1059
- var statuses = {
1060
- "0x0": "reverted",
1061
- "0x1": "success"
1062
- };
1063
- function formatTransactionReceipt(transactionReceipt) {
1064
- return {
1065
- ...transactionReceipt,
1066
- blockNumber: transactionReceipt.blockNumber ? BigInt(transactionReceipt.blockNumber) : null,
1067
- cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
1068
- effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
1069
- gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
1070
- logs: transactionReceipt.logs ? transactionReceipt.logs.map(formatLog) : null,
1071
- transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
1072
- status: transactionReceipt.status ? statuses[transactionReceipt.status] : null,
1073
- type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
1074
- };
1075
- }
1076
-
1077
- // src/utils/formatters/transactionRequest.ts
1078
- function formatTransactionRequest(transactionRequest) {
1079
- return {
1080
- ...transactionRequest,
1081
- gas: typeof transactionRequest.gas !== "undefined" ? numberToHex(transactionRequest.gas) : void 0,
1082
- gasPrice: typeof transactionRequest.gasPrice !== "undefined" ? numberToHex(transactionRequest.gasPrice) : void 0,
1083
- maxFeePerGas: typeof transactionRequest.maxFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxFeePerGas) : void 0,
1084
- maxPriorityFeePerGas: typeof transactionRequest.maxPriorityFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxPriorityFeePerGas) : void 0,
1085
- nonce: typeof transactionRequest.nonce !== "undefined" ? numberToHex(transactionRequest.nonce) : void 0,
1086
- value: typeof transactionRequest.value !== "undefined" ? numberToHex(transactionRequest.value) : void 0
1087
- };
1088
- }
1089
-
1090
- // src/utils/unit/formatUnit.ts
1091
- function formatUnit(value, decimals) {
1092
- let display = value.toString();
1093
- const negative = display.startsWith("-");
1094
- if (negative)
1095
- display = display.slice(1);
1096
- let [integer, fraction] = [
1097
- display.slice(0, display.length - decimals),
1098
- display.slice(display.length - decimals)
1099
- ];
1100
- fraction = fraction.padStart(decimals, "0");
1101
- fraction = fraction.replace(/(0+)$/, "");
1102
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
1103
- }
1104
-
1105
- // src/utils/unit/formatEther.ts
1106
- function formatEther(wei, unit = "wei") {
1107
- return formatUnit(wei, etherUnits[unit]);
1108
- }
1109
-
1110
- // src/utils/unit/formatGwei.ts
1111
- function formatGwei(wei, unit = "wei") {
1112
- return formatUnit(wei, gweiUnits[unit]);
1113
- }
1114
-
1115
- // src/utils/unit/parseUnit.ts
1116
- function parseUnit(value, decimals) {
1117
- let [integer, fraction = "0"] = value.split(".");
1118
- const negative = integer.startsWith("-");
1119
- if (negative)
1120
- integer = integer.slice(1);
1121
- fraction = fraction.replace(/(0+)$/, "");
1122
- if (decimals === 0) {
1123
- integer = `${Math.round(Number(`${integer}.${fraction}`))}`;
1124
- fraction = "";
1125
- } else if (fraction.length > decimals) {
1126
- const [before, after] = [
1127
- fraction.slice(0, decimals),
1128
- fraction.slice(decimals)
1129
- ];
1130
- fraction = `${/^0+$/.test(before) ? before.slice(0, before.length - 1) : ""}${Math.round(Number(`${before}.${after}`))}`;
1131
- } else {
1132
- fraction = fraction.padEnd(decimals, "0");
1133
- }
1134
- return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
1135
- }
1136
-
1137
- // src/utils/unit/parseEther.ts
1138
- function parseEther(ether, unit = "wei") {
1139
- return parseUnit(ether, etherUnits[unit]);
1140
- }
1141
-
1142
- // src/utils/unit/parseGwei.ts
1143
- function parseGwei(ether, unit = "wei") {
1144
- return parseUnit(ether, gweiUnits[unit]);
1145
- }
1146
-
1147
- export {
1148
- isBytes,
1149
- isHex,
1150
- pad,
1151
- padHex,
1152
- padBytes,
1153
- trim,
1154
- size,
1155
- slice,
1156
- sliceBytes,
1157
- sliceHex,
1158
- boolToHex,
1159
- bytesToHex,
1160
- encodeHex,
1161
- numberToHex,
1162
- stringToHex,
1163
- boolToBytes,
1164
- encodeBytes,
1165
- hexToBytes,
1166
- numberToBytes,
1167
- stringToBytes,
1168
- encodeRlp,
1169
- decodeHex,
1170
- hexToBigInt,
1171
- hexToBool,
1172
- hexToNumber,
1173
- hexToString,
1174
- decodeBytes,
1175
- bytesToBigint,
1176
- bytesToBool,
1177
- bytesToNumber,
1178
- bytesToString,
1179
- decodeRlp,
1180
- extractFunctionName,
1181
- extractFunctionParams,
1182
- extractFunctionType,
1183
- keccak256,
1184
- getEventSignature,
1185
- getFunctionSignature,
1186
- checksumAddress,
1187
- getAddress,
1188
- getContractAddress,
1189
- getCreateAddress,
1190
- getCreate2Address,
1191
- isAddress,
1192
- isAddressEqual,
1193
- encodeAbi,
1194
- decodeAbi,
1195
- decodeFunctionData,
1196
- encodeFunctionData,
1197
- etherUnits,
1198
- gweiUnits,
1199
- weiUnits,
1200
- transactionType,
1201
- formatTransaction,
1202
- formatBlock,
1203
- formatFeeHistory,
1204
- format3 as format,
1205
- formatLog,
1206
- formatTransactionReceipt,
1207
- formatTransactionRequest,
1208
- formatUnit,
1209
- formatEther,
1210
- formatGwei,
1211
- parseUnit,
1212
- parseEther,
1213
- parseGwei
1214
- };