viem 0.1.14 → 0.1.16

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 (55) hide show
  1. package/dist/abi.d.ts +3 -3
  2. package/dist/abi.js +2 -2
  3. package/dist/abi.mjs +1 -1
  4. package/dist/{chain-0ce17567.d.ts → chain-3a97fb0b.d.ts} +1 -1
  5. package/dist/{chain-5b8fb5eb.d.ts → chain-94e42876.d.ts} +1 -1
  6. package/dist/chains.d.ts +3 -3
  7. package/dist/chains.js +63 -63
  8. package/dist/chains.mjs +1 -1
  9. package/dist/{chunk-KH3WJ45D.mjs → chunk-6CRQ2Z6Y.mjs} +2 -2
  10. package/dist/{chunk-TZWWCJQ5.js → chunk-EUMT64YW.js} +19 -19
  11. package/dist/{chunk-S3SV7Y4G.mjs → chunk-S53L3VGF.mjs} +151 -70
  12. package/dist/chunk-S53L3VGF.mjs.map +1 -0
  13. package/dist/{chunk-P5JTF7JS.js → chunk-SA6IPLJF.js} +164 -83
  14. package/dist/chunk-SA6IPLJF.js.map +1 -0
  15. package/dist/contract.d.ts +7 -7
  16. package/dist/contract.js +2 -2
  17. package/dist/contract.mjs +1 -1
  18. package/dist/{createClient-98b1c2e7.d.ts → createClient-ddc3fa22.d.ts} +2 -2
  19. package/dist/{createPublicClient-812a1dae.d.ts → createPublicClient-1e28879c.d.ts} +11 -5
  20. package/dist/{eip1193-44504199.d.ts → eip1193-343f2a94.d.ts} +1 -1
  21. package/dist/{encodeFunctionResult-e491eb56.d.ts → encodeFunctionResult-4d3bafb8.d.ts} +2 -2
  22. package/dist/{encodePacked-d7942f6b.d.ts → encodePacked-a51cd55a.d.ts} +1 -1
  23. package/dist/ens.d.ts +4 -4
  24. package/dist/ens.js +3 -3
  25. package/dist/ens.mjs +2 -2
  26. package/dist/ethers.d.ts +4 -4
  27. package/dist/ethers.js +3 -3
  28. package/dist/ethers.mjs +1 -1
  29. package/dist/{formatAbiItem-29a73545.d.ts → formatAbiItem-e5d7437a.d.ts} +1 -1
  30. package/dist/{getAbiItem-779cb566.d.ts → getAbiItem-de2d6ac0.d.ts} +1 -1
  31. package/dist/index.d.ts +20 -14
  32. package/dist/index.js +96 -90
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +8 -2
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/{parseGwei-75956089.d.ts → parseGwei-da38c1af.d.ts} +21 -10
  37. package/dist/public.d.ts +4 -4
  38. package/dist/public.js +2 -2
  39. package/dist/public.mjs +1 -1
  40. package/dist/{test-d0a36452.d.ts → test-07a99259.d.ts} +3 -3
  41. package/dist/test.d.ts +5 -5
  42. package/dist/test.js +2 -2
  43. package/dist/test.mjs +1 -1
  44. package/dist/utils/index.d.ts +29 -14
  45. package/dist/utils/index.js +10 -2
  46. package/dist/utils/index.mjs +11 -3
  47. package/dist/wallet.d.ts +4 -4
  48. package/dist/wallet.js +2 -2
  49. package/dist/wallet.mjs +1 -1
  50. package/dist/window.d.ts +2 -2
  51. package/package.json +2 -1
  52. package/dist/chunk-P5JTF7JS.js.map +0 -1
  53. package/dist/chunk-S3SV7Y4G.mjs.map +0 -1
  54. /package/dist/{chunk-KH3WJ45D.mjs.map → chunk-6CRQ2Z6Y.mjs.map} +0 -0
  55. /package/dist/{chunk-TZWWCJQ5.js.map → chunk-EUMT64YW.js.map} +0 -0
@@ -17,7 +17,7 @@ import {
17
17
  var package_default = {
18
18
  name: "viem",
19
19
  description: "TypeScript Interface for Ethereum",
20
- version: "0.1.14",
20
+ version: "0.1.16",
21
21
  scripts: {
22
22
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
23
23
  bench: "vitest bench --no-threads",
@@ -41,6 +41,7 @@ var package_default = {
41
41
  test: "vitest dev --no-threads",
42
42
  "test:cov": "vitest dev --coverage --no-threads",
43
43
  "test:ci": "CI=true vitest --coverage --no-threads",
44
+ "test:typecheck": "SKIP_GLOBAL_SETUP=true vitest typecheck",
44
45
  "test:ui": "vitest dev --ui --no-threads",
45
46
  "ts-node": "bun",
46
47
  typecheck: "tsc --noEmit"
@@ -137,6 +138,7 @@ var package_default = {
137
138
  sideEffects: false,
138
139
  dependencies: {
139
140
  "@noble/hashes": "^1.1.2",
141
+ "@noble/secp256k1": "^1.7.1",
140
142
  "@wagmi/chains": "~0.2.11",
141
143
  abitype: "~0.7.1",
142
144
  "idna-uts46-hx": "^4.1.2",
@@ -208,12 +210,12 @@ var getVersion = () => `${package_default.name}@${package_default.version}`;
208
210
  var BaseError = class extends Error {
209
211
  constructor(shortMessage, args = {}) {
210
212
  const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
211
- const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
213
+ const docsPath6 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
212
214
  const message = [
213
215
  shortMessage || "An error occurred.",
214
216
  "",
215
217
  ...args.metaMessages ? [...args.metaMessages, ""] : [],
216
- ...docsPath5 ? [`Docs: https://viem.sh${docsPath5}.html`] : [],
218
+ ...docsPath6 ? [`Docs: https://viem.sh${docsPath6}.html`] : [],
217
219
  ...details ? [`Details: ${details}`] : [],
218
220
  `Version: ${getVersion()}`
219
221
  ].join("\n");
@@ -226,7 +228,7 @@ var BaseError = class extends Error {
226
228
  if (args.cause)
227
229
  this.cause = args.cause;
228
230
  this.details = details;
229
- this.docsPath = docsPath5;
231
+ this.docsPath = docsPath6;
230
232
  this.metaMessages = args.metaMessages;
231
233
  this.shortMessage = shortMessage;
232
234
  }
@@ -234,28 +236,28 @@ var BaseError = class extends Error {
234
236
 
235
237
  // src/errors/abi.ts
236
238
  var AbiConstructorNotFoundError = class extends BaseError {
237
- constructor({ docsPath: docsPath5 }) {
239
+ constructor({ docsPath: docsPath6 }) {
238
240
  super(
239
241
  [
240
242
  "A constructor was not found on the ABI.",
241
243
  "Make sure you are using the correct ABI and that the constructor exists on it."
242
244
  ].join("\n"),
243
245
  {
244
- docsPath: docsPath5
246
+ docsPath: docsPath6
245
247
  }
246
248
  );
247
249
  __publicField(this, "name", "AbiConstructorNotFoundError");
248
250
  }
249
251
  };
250
252
  var AbiConstructorParamsNotFoundError = class extends BaseError {
251
- constructor({ docsPath: docsPath5 }) {
253
+ constructor({ docsPath: docsPath6 }) {
252
254
  super(
253
255
  [
254
256
  "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
255
257
  "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
256
258
  ].join("\n"),
257
259
  {
258
- docsPath: docsPath5
260
+ docsPath: docsPath6
259
261
  }
260
262
  );
261
263
  __publicField(this, "name", "AbiConstructorParamsNotFoundError");
@@ -320,7 +322,7 @@ var AbiEncodingLengthMismatchError = class extends BaseError {
320
322
  }
321
323
  };
322
324
  var AbiErrorInputsNotFoundError = class extends BaseError {
323
- constructor(errorName, { docsPath: docsPath5 }) {
325
+ constructor(errorName, { docsPath: docsPath6 }) {
324
326
  super(
325
327
  [
326
328
  `Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
@@ -328,28 +330,28 @@ var AbiErrorInputsNotFoundError = class extends BaseError {
328
330
  "Make sure you are using the correct ABI and that the inputs exist on it."
329
331
  ].join("\n"),
330
332
  {
331
- docsPath: docsPath5
333
+ docsPath: docsPath6
332
334
  }
333
335
  );
334
336
  __publicField(this, "name", "AbiErrorInputsNotFoundError");
335
337
  }
336
338
  };
337
339
  var AbiErrorNotFoundError = class extends BaseError {
338
- constructor(errorName, { docsPath: docsPath5 }) {
340
+ constructor(errorName, { docsPath: docsPath6 }) {
339
341
  super(
340
342
  [
341
343
  `Error "${errorName}" not found on ABI.`,
342
344
  "Make sure you are using the correct ABI and that the error exists on it."
343
345
  ].join("\n"),
344
346
  {
345
- docsPath: docsPath5
347
+ docsPath: docsPath6
346
348
  }
347
349
  );
348
350
  __publicField(this, "name", "AbiErrorNotFoundError");
349
351
  }
350
352
  };
351
353
  var AbiErrorSignatureNotFoundError = class extends BaseError {
352
- constructor(signature, { docsPath: docsPath5 }) {
354
+ constructor(signature, { docsPath: docsPath6 }) {
353
355
  super(
354
356
  [
355
357
  `Encoded error signature "${signature}" not found on ABI.`,
@@ -357,14 +359,22 @@ var AbiErrorSignatureNotFoundError = class extends BaseError {
357
359
  `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
358
360
  ].join("\n"),
359
361
  {
360
- docsPath: docsPath5
362
+ docsPath: docsPath6
361
363
  }
362
364
  );
363
365
  __publicField(this, "name", "AbiErrorSignatureNotFoundError");
364
366
  }
365
367
  };
368
+ var AbiEventSignatureEmptyTopicsError = class extends BaseError {
369
+ constructor({ docsPath: docsPath6 }) {
370
+ super("Cannot extract event signature from empty topics.", {
371
+ docsPath: docsPath6
372
+ });
373
+ __publicField(this, "name", "AbiEventSignatureEmptyTopicsError");
374
+ }
375
+ };
366
376
  var AbiEventSignatureNotFoundError = class extends BaseError {
367
- constructor(signature, { docsPath: docsPath5 }) {
377
+ constructor(signature, { docsPath: docsPath6 }) {
368
378
  super(
369
379
  [
370
380
  `Encoded event signature "${signature}" not found on ABI.`,
@@ -372,42 +382,42 @@ var AbiEventSignatureNotFoundError = class extends BaseError {
372
382
  `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
373
383
  ].join("\n"),
374
384
  {
375
- docsPath: docsPath5
385
+ docsPath: docsPath6
376
386
  }
377
387
  );
378
388
  __publicField(this, "name", "AbiEventSignatureNotFoundError");
379
389
  }
380
390
  };
381
391
  var AbiEventNotFoundError = class extends BaseError {
382
- constructor(eventName, { docsPath: docsPath5 }) {
392
+ constructor(eventName, { docsPath: docsPath6 }) {
383
393
  super(
384
394
  [
385
395
  `Event "${eventName}" not found on ABI.`,
386
396
  "Make sure you are using the correct ABI and that the event exists on it."
387
397
  ].join("\n"),
388
398
  {
389
- docsPath: docsPath5
399
+ docsPath: docsPath6
390
400
  }
391
401
  );
392
402
  __publicField(this, "name", "AbiEventNotFoundError");
393
403
  }
394
404
  };
395
405
  var AbiFunctionNotFoundError = class extends BaseError {
396
- constructor(functionName, { docsPath: docsPath5 }) {
406
+ constructor(functionName, { docsPath: docsPath6 }) {
397
407
  super(
398
408
  [
399
409
  `Function "${functionName}" not found on ABI.`,
400
410
  "Make sure you are using the correct ABI and that the function exists on it."
401
411
  ].join("\n"),
402
412
  {
403
- docsPath: docsPath5
413
+ docsPath: docsPath6
404
414
  }
405
415
  );
406
416
  __publicField(this, "name", "AbiFunctionNotFoundError");
407
417
  }
408
418
  };
409
419
  var AbiFunctionOutputsNotFoundError = class extends BaseError {
410
- constructor(functionName, { docsPath: docsPath5 }) {
420
+ constructor(functionName, { docsPath: docsPath6 }) {
411
421
  super(
412
422
  [
413
423
  `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
@@ -415,14 +425,14 @@ var AbiFunctionOutputsNotFoundError = class extends BaseError {
415
425
  "Make sure you are using the correct ABI and that the function exists on it."
416
426
  ].join("\n"),
417
427
  {
418
- docsPath: docsPath5
428
+ docsPath: docsPath6
419
429
  }
420
430
  );
421
431
  __publicField(this, "name", "AbiFunctionOutputsNotFoundError");
422
432
  }
423
433
  };
424
434
  var AbiFunctionSignatureNotFoundError = class extends BaseError {
425
- constructor(signature, { docsPath: docsPath5 }) {
435
+ constructor(signature, { docsPath: docsPath6 }) {
426
436
  super(
427
437
  [
428
438
  `Encoded function signature "${signature}" not found on ABI.`,
@@ -430,7 +440,7 @@ var AbiFunctionSignatureNotFoundError = class extends BaseError {
430
440
  `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
431
441
  ].join("\n"),
432
442
  {
433
- docsPath: docsPath5
443
+ docsPath: docsPath6
434
444
  }
435
445
  );
436
446
  __publicField(this, "name", "AbiFunctionSignatureNotFoundError");
@@ -459,25 +469,25 @@ var DecodeLogTopicsMismatch = class extends BaseError {
459
469
  }
460
470
  };
461
471
  var InvalidAbiEncodingTypeError = class extends BaseError {
462
- constructor(type, { docsPath: docsPath5 }) {
472
+ constructor(type, { docsPath: docsPath6 }) {
463
473
  super(
464
474
  [
465
475
  `Type "${type}" is not a valid encoding type.`,
466
476
  "Please provide a valid ABI type."
467
477
  ].join("\n"),
468
- { docsPath: docsPath5 }
478
+ { docsPath: docsPath6 }
469
479
  );
470
480
  __publicField(this, "name", "InvalidAbiEncodingType");
471
481
  }
472
482
  };
473
483
  var InvalidAbiDecodingTypeError = class extends BaseError {
474
- constructor(type, { docsPath: docsPath5 }) {
484
+ constructor(type, { docsPath: docsPath6 }) {
475
485
  super(
476
486
  [
477
487
  `Type "${type}" is not a valid decoding type.`,
478
488
  "Please provide a valid ABI type."
479
489
  ].join("\n"),
480
- { docsPath: docsPath5 }
490
+ { docsPath: docsPath6 }
481
491
  );
482
492
  __publicField(this, "name", "InvalidAbiDecodingType");
483
493
  }
@@ -687,7 +697,7 @@ var FeeConflictError = class extends BaseError {
687
697
  var TransactionExecutionError = class extends BaseError {
688
698
  constructor(cause, {
689
699
  account,
690
- docsPath: docsPath5,
700
+ docsPath: docsPath6,
691
701
  chain,
692
702
  data,
693
703
  gas,
@@ -712,7 +722,7 @@ var TransactionExecutionError = class extends BaseError {
712
722
  });
713
723
  super(cause.shortMessage, {
714
724
  cause,
715
- docsPath: docsPath5,
725
+ docsPath: docsPath6,
716
726
  metaMessages: [
717
727
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
718
728
  "Request Arguments:",
@@ -766,7 +776,7 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
766
776
  var CallExecutionError = class extends BaseError {
767
777
  constructor(cause, {
768
778
  account,
769
- docsPath: docsPath5,
779
+ docsPath: docsPath6,
770
780
  chain,
771
781
  data,
772
782
  gas,
@@ -790,7 +800,7 @@ var CallExecutionError = class extends BaseError {
790
800
  });
791
801
  super(cause.shortMessage, {
792
802
  cause,
793
- docsPath: docsPath5,
803
+ docsPath: docsPath6,
794
804
  metaMessages: [
795
805
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
796
806
  "Raw Call Arguments:",
@@ -807,7 +817,7 @@ var ContractFunctionExecutionError = class extends BaseError {
807
817
  abi,
808
818
  args,
809
819
  contractAddress,
810
- docsPath: docsPath5,
820
+ docsPath: docsPath6,
811
821
  functionName,
812
822
  sender
813
823
  }) {
@@ -829,7 +839,7 @@ var ContractFunctionExecutionError = class extends BaseError {
829
839
  cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`,
830
840
  {
831
841
  cause,
832
- docsPath: docsPath5,
842
+ docsPath: docsPath6,
833
843
  metaMessages: [
834
844
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
835
845
  "Contract Call:",
@@ -1007,7 +1017,7 @@ var OffsetOutOfBoundsError = class extends BaseError {
1007
1017
  var EstimateGasExecutionError = class extends BaseError {
1008
1018
  constructor(cause, {
1009
1019
  account,
1010
- docsPath: docsPath5,
1020
+ docsPath: docsPath6,
1011
1021
  chain,
1012
1022
  data,
1013
1023
  gas,
@@ -1031,7 +1041,7 @@ var EstimateGasExecutionError = class extends BaseError {
1031
1041
  });
1032
1042
  super(cause.shortMessage, {
1033
1043
  cause,
1034
- docsPath: docsPath5,
1044
+ docsPath: docsPath6,
1035
1045
  metaMessages: [
1036
1046
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
1037
1047
  "Estimate Gas Arguments:",
@@ -1220,21 +1230,21 @@ var UnknownNodeError = class extends BaseError {
1220
1230
  // src/errors/request.ts
1221
1231
  var RequestError = class extends BaseError {
1222
1232
  constructor(err, {
1223
- docsPath: docsPath5,
1233
+ docsPath: docsPath6,
1224
1234
  metaMessages,
1225
1235
  shortMessage
1226
1236
  }) {
1227
1237
  super(shortMessage, {
1228
1238
  cause: err,
1229
- docsPath: docsPath5,
1239
+ docsPath: docsPath6,
1230
1240
  metaMessages
1231
1241
  });
1232
1242
  this.name = err.name;
1233
1243
  }
1234
1244
  };
1235
1245
  var RpcRequestError = class extends RequestError {
1236
- constructor(err, { docsPath: docsPath5, shortMessage }) {
1237
- super(err, { docsPath: docsPath5, metaMessages: err.metaMessages, shortMessage });
1246
+ constructor(err, { docsPath: docsPath6, shortMessage }) {
1247
+ super(err, { docsPath: docsPath6, metaMessages: err.metaMessages, shortMessage });
1238
1248
  __publicField(this, "code");
1239
1249
  this.code = err.code;
1240
1250
  this.name = err.name;
@@ -2427,18 +2437,23 @@ function decodeErrorResult({
2427
2437
  }
2428
2438
 
2429
2439
  // src/utils/abi/decodeEventLog.ts
2440
+ var docsPath = "/docs/contract/decodeEventLog";
2430
2441
  function decodeEventLog({
2431
2442
  abi,
2432
2443
  data,
2433
2444
  topics
2434
2445
  }) {
2435
2446
  const [signature, ...argTopics] = topics;
2447
+ if (!signature)
2448
+ throw new AbiEventSignatureEmptyTopicsError({
2449
+ docsPath
2450
+ });
2436
2451
  const abiItem = abi.find(
2437
2452
  (x) => x.type === "event" && signature === getEventSelector(formatAbiItem(x))
2438
2453
  );
2439
2454
  if (!(abiItem && "name" in abiItem))
2440
2455
  throw new AbiEventSignatureNotFoundError(signature, {
2441
- docsPath: "/docs/contract/decodeEventLog"
2456
+ docsPath
2442
2457
  });
2443
2458
  const { name, inputs } = abiItem;
2444
2459
  const isUnnamed = inputs?.some((x) => !("name" in x && x.name));
@@ -2577,7 +2592,7 @@ function isArgOfType(arg, abiParameter) {
2577
2592
  }
2578
2593
 
2579
2594
  // src/utils/abi/decodeFunctionResult.ts
2580
- var docsPath = "/docs/contract/decodeFunctionResult";
2595
+ var docsPath2 = "/docs/contract/decodeFunctionResult";
2581
2596
  function decodeFunctionResult({
2582
2597
  abi,
2583
2598
  args,
@@ -2590,9 +2605,9 @@ function decodeFunctionResult({
2590
2605
  name: functionName
2591
2606
  });
2592
2607
  if (!description)
2593
- throw new AbiFunctionNotFoundError(functionName, { docsPath });
2608
+ throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath2 });
2594
2609
  if (!("outputs" in description))
2595
- throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
2610
+ throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath2 });
2596
2611
  const values = decodeAbiParameters(description.outputs, data);
2597
2612
  if (values && values.length > 1)
2598
2613
  return values;
@@ -2602,7 +2617,7 @@ function decodeFunctionResult({
2602
2617
  }
2603
2618
 
2604
2619
  // src/utils/abi/encodeDeployData.ts
2605
- var docsPath2 = "/docs/contract/encodeDeployData";
2620
+ var docsPath3 = "/docs/contract/encodeDeployData";
2606
2621
  function encodeDeployData({
2607
2622
  abi,
2608
2623
  args,
@@ -2614,11 +2629,11 @@ function encodeDeployData({
2614
2629
  (x) => "type" in x && x.type === "constructor"
2615
2630
  );
2616
2631
  if (!description)
2617
- throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
2632
+ throw new AbiConstructorNotFoundError({ docsPath: docsPath3 });
2618
2633
  if (!("inputs" in description))
2619
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2634
+ throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath3 });
2620
2635
  if (!description.inputs || description.inputs.length === 0)
2621
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2636
+ throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath3 });
2622
2637
  const data = encodeAbiParameters(
2623
2638
  description.inputs,
2624
2639
  args
@@ -2627,7 +2642,7 @@ function encodeDeployData({
2627
2642
  }
2628
2643
 
2629
2644
  // src/utils/abi/encodeErrorResult.ts
2630
- var docsPath3 = "/docs/contract/encodeErrorResult";
2645
+ var docsPath4 = "/docs/contract/encodeErrorResult";
2631
2646
  function encodeErrorResult({ abi, errorName, args }) {
2632
2647
  const description = getAbiItem({
2633
2648
  abi,
@@ -2635,13 +2650,13 @@ function encodeErrorResult({ abi, errorName, args }) {
2635
2650
  name: errorName
2636
2651
  });
2637
2652
  if (!description)
2638
- throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
2653
+ throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath4 });
2639
2654
  const definition = formatAbiItem(description);
2640
2655
  const signature = getFunctionSelector(definition);
2641
2656
  let data = "0x";
2642
2657
  if (args && args.length > 0) {
2643
2658
  if (!("inputs" in description && description.inputs))
2644
- throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
2659
+ throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath4 });
2645
2660
  data = encodeAbiParameters(description.inputs, args);
2646
2661
  }
2647
2662
  return concatHex([signature, data]);
@@ -2707,7 +2722,7 @@ function encodeFunctionData({
2707
2722
  }
2708
2723
 
2709
2724
  // src/utils/abi/encodeFunctionResult.ts
2710
- var docsPath4 = "/docs/contract/encodeFunctionResult";
2725
+ var docsPath5 = "/docs/contract/encodeFunctionResult";
2711
2726
  function encodeFunctionResult({
2712
2727
  abi,
2713
2728
  functionName,
@@ -2717,9 +2732,9 @@ function encodeFunctionResult({
2717
2732
  (x) => "name" in x && x.name === functionName
2718
2733
  );
2719
2734
  if (!description)
2720
- throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
2735
+ throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath5 });
2721
2736
  if (!("outputs" in description))
2722
- throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath4 });
2737
+ throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath5 });
2723
2738
  let values = Array.isArray(result) ? result : [result];
2724
2739
  if (description.outputs.length === 0 && !values[0])
2725
2740
  values = [];
@@ -3237,14 +3252,14 @@ function getNodeError(err, args) {
3237
3252
 
3238
3253
  // src/utils/errors/getCallError.ts
3239
3254
  function getCallError(err, {
3240
- docsPath: docsPath5,
3255
+ docsPath: docsPath6,
3241
3256
  ...args
3242
3257
  }) {
3243
3258
  let cause = err;
3244
3259
  if (containsNodeError(err))
3245
3260
  cause = getNodeError(err, args);
3246
3261
  return new CallExecutionError(cause, {
3247
- docsPath: docsPath5,
3262
+ docsPath: docsPath6,
3248
3263
  ...args
3249
3264
  });
3250
3265
  }
@@ -3255,7 +3270,7 @@ function getContractError(err, {
3255
3270
  abi,
3256
3271
  address,
3257
3272
  args,
3258
- docsPath: docsPath5,
3273
+ docsPath: docsPath6,
3259
3274
  functionName,
3260
3275
  sender
3261
3276
  }) {
@@ -3275,7 +3290,7 @@ function getContractError(err, {
3275
3290
  abi,
3276
3291
  args,
3277
3292
  contractAddress: address,
3278
- docsPath: docsPath5,
3293
+ docsPath: docsPath6,
3279
3294
  functionName,
3280
3295
  sender
3281
3296
  });
@@ -3283,28 +3298,28 @@ function getContractError(err, {
3283
3298
 
3284
3299
  // src/utils/errors/getEstimateGasError.ts
3285
3300
  function getEstimateGasError(err, {
3286
- docsPath: docsPath5,
3301
+ docsPath: docsPath6,
3287
3302
  ...args
3288
3303
  }) {
3289
3304
  let cause = err;
3290
3305
  if (containsNodeError(err))
3291
3306
  cause = getNodeError(err, args);
3292
3307
  return new EstimateGasExecutionError(cause, {
3293
- docsPath: docsPath5,
3308
+ docsPath: docsPath6,
3294
3309
  ...args
3295
3310
  });
3296
3311
  }
3297
3312
 
3298
3313
  // src/utils/errors/getTransactionError.ts
3299
3314
  function getTransactionError(err, {
3300
- docsPath: docsPath5,
3315
+ docsPath: docsPath6,
3301
3316
  ...args
3302
3317
  }) {
3303
3318
  let cause = err;
3304
3319
  if (containsNodeError(err))
3305
3320
  cause = getNodeError(err, args);
3306
3321
  return new TransactionExecutionError(cause, {
3307
- docsPath: docsPath5,
3322
+ docsPath: docsPath6,
3308
3323
  ...args
3309
3324
  });
3310
3325
  }
@@ -3479,6 +3494,56 @@ var rpc = {
3479
3494
  webSocketAsync
3480
3495
  };
3481
3496
 
3497
+ // src/utils/signature/hashMessage.ts
3498
+ function hashMessage(message, to_) {
3499
+ const messageBytes = toBytes(message);
3500
+ const prefixBytes = toBytes(
3501
+ `Ethereum Signed Message:
3502
+ ${messageBytes.length}`
3503
+ );
3504
+ return keccak256(concat([prefixBytes, messageBytes]), to_);
3505
+ }
3506
+
3507
+ // src/utils/signature/recoverAddress.ts
3508
+ import { recoverPublicKey } from "@noble/secp256k1";
3509
+ function recoverAddress({
3510
+ hash: hash2,
3511
+ signature
3512
+ }) {
3513
+ const signatureHex = isHex(signature) ? signature : toHex(signature);
3514
+ const hashHex = isHex(hash2) ? hash2 : toHex(hash2);
3515
+ const v = hexToNumber(`0x${signatureHex.slice(130)}`);
3516
+ const publicKey = toHex(
3517
+ recoverPublicKey(
3518
+ hashHex.substring(2),
3519
+ signatureHex.substring(2, 130),
3520
+ v - 27
3521
+ )
3522
+ );
3523
+ const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
3524
+ return checksumAddress(`0x${address}`);
3525
+ }
3526
+
3527
+ // src/utils/signature/recoverMessageAddress.ts
3528
+ function recoverMessageAddress({
3529
+ message,
3530
+ signature
3531
+ }) {
3532
+ return recoverAddress({ hash: hashMessage(message), signature });
3533
+ }
3534
+
3535
+ // src/utils/signature/verifyMessage.ts
3536
+ function verifyMessage({
3537
+ address,
3538
+ message,
3539
+ signature
3540
+ }) {
3541
+ return isAddressEqual(
3542
+ getAddress(address),
3543
+ recoverMessageAddress({ message, signature })
3544
+ );
3545
+ }
3546
+
3482
3547
  // src/utils/transaction/assertRequest.ts
3483
3548
  function assertRequest(args) {
3484
3549
  const { account, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
@@ -4370,8 +4435,10 @@ function watchBlockNumber(client, {
4370
4435
  }
4371
4436
  }
4372
4437
  }
4373
- prevBlockNumber = blockNumber;
4374
- emit.onBlockNumber(blockNumber, prevBlockNumber);
4438
+ if (!prevBlockNumber || blockNumber > prevBlockNumber) {
4439
+ emit.onBlockNumber(blockNumber, prevBlockNumber);
4440
+ prevBlockNumber = blockNumber;
4441
+ }
4375
4442
  } catch (err) {
4376
4443
  emit.onError?.(err);
4377
4444
  }
@@ -4427,8 +4494,16 @@ function watchBlocks(client, {
4427
4494
  }
4428
4495
  }
4429
4496
  }
4430
- emit.onBlock(block, prevBlock);
4431
- prevBlock = block;
4497
+ if (
4498
+ // If no previous block exists, emit.
4499
+ !prevBlock?.number || // If the block tag is "pending" with no block number, emit.
4500
+ blockTag === "pending" && !block?.number || // If the next block number is greater than the previous block number, emit.
4501
+ // We don't want to emit blocks in the past.
4502
+ block.number && block.number > prevBlock.number
4503
+ ) {
4504
+ emit.onBlock(block, prevBlock);
4505
+ prevBlock = block;
4506
+ }
4432
4507
  } catch (err) {
4433
4508
  emit.onError?.(err);
4434
4509
  }
@@ -5016,12 +5091,13 @@ async function sendTransaction(client, args) {
5016
5091
  }
5017
5092
 
5018
5093
  // src/actions/wallet/signMessage.ts
5019
- async function signMessage(client, { account, data }) {
5094
+ async function signMessage(client, { account, data, message }) {
5095
+ const message_ = message || data;
5020
5096
  if (account.type === "local")
5021
- return account.signMessage(data);
5097
+ return account.signMessage(message_);
5022
5098
  return client.request({
5023
5099
  method: "personal_sign",
5024
- params: [toHex(data), account.address]
5100
+ params: [toHex(message_), account.address]
5025
5101
  });
5026
5102
  }
5027
5103
 
@@ -5260,6 +5336,7 @@ export {
5260
5336
  AbiErrorInputsNotFoundError,
5261
5337
  AbiErrorNotFoundError,
5262
5338
  AbiErrorSignatureNotFoundError,
5339
+ AbiEventSignatureEmptyTopicsError,
5263
5340
  AbiEventSignatureNotFoundError,
5264
5341
  AbiEventNotFoundError,
5265
5342
  AbiFunctionNotFoundError,
@@ -5425,6 +5502,10 @@ export {
5425
5502
  stringify,
5426
5503
  getSocket,
5427
5504
  rpc,
5505
+ hashMessage,
5506
+ recoverAddress,
5507
+ recoverMessageAddress,
5508
+ verifyMessage,
5428
5509
  assertRequest,
5429
5510
  call,
5430
5511
  simulateContract,
@@ -5508,4 +5589,4 @@ export {
5508
5589
  formatGwei,
5509
5590
  parseEther
5510
5591
  };
5511
- //# sourceMappingURL=chunk-S3SV7Y4G.mjs.map
5592
+ //# sourceMappingURL=chunk-S53L3VGF.mjs.map