viem 0.1.20 → 0.2.0-0-2-0.20230320T235312

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 (60) 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/account-07d04222.d.ts +74 -0
  5. package/dist/{chain-1b53ef88.d.ts → chain-b2e88e30.d.ts} +113 -108
  6. package/dist/{chain-ec8c485d.d.ts → chain-c4f924cf.d.ts} +1 -1
  7. package/dist/chains.d.ts +3 -3
  8. package/dist/chains.js +63 -63
  9. package/dist/chains.mjs +1 -1
  10. package/dist/{chunk-YFSMUTVA.mjs → chunk-4DIN6KDM.mjs} +2 -2
  11. package/dist/chunk-4DIN6KDM.mjs.map +1 -0
  12. package/dist/{chunk-KGXWL2EP.js → chunk-BLB7NERO.js} +19 -19
  13. package/dist/chunk-BLB7NERO.js.map +1 -0
  14. package/dist/{chunk-T5H6ROQX.mjs → chunk-KOAJUBTN.mjs} +334 -33
  15. package/dist/chunk-KOAJUBTN.mjs.map +1 -0
  16. package/dist/{chunk-FXDLMUBO.js → chunk-T4AH4Y6Y.js} +403 -102
  17. package/dist/chunk-T4AH4Y6Y.js.map +1 -0
  18. package/dist/contract.d.ts +8 -7
  19. package/dist/contract.js +2 -2
  20. package/dist/contract.mjs +1 -1
  21. package/dist/{createClient-a28317a9.d.ts → createClient-d4f1dea1.d.ts} +6 -6
  22. package/dist/{createPublicClient-0021fc35.d.ts → createPublicClient-3a714a8d.d.ts} +154 -207
  23. package/dist/{eip1193-4f4e240c.d.ts → eip1193-cd3e872a.d.ts} +1 -1
  24. package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-750c9055.d.ts} +1 -1
  25. package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-de74201f.d.ts} +1 -1
  26. package/dist/ens.d.ts +5 -4
  27. package/dist/ens.js +3 -3
  28. package/dist/ens.mjs +2 -2
  29. package/dist/ethers.d.ts +3 -5
  30. package/dist/ethers.js +3 -3
  31. package/dist/ethers.js.map +1 -1
  32. package/dist/ethers.mjs +1 -1
  33. package/dist/ethers.mjs.map +1 -1
  34. package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-fdbdda39.d.ts} +1 -1
  35. package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-9d709e3b.d.ts} +1 -1
  36. package/dist/index.d.ts +14 -13
  37. package/dist/index.js +101 -91
  38. package/dist/index.js.map +1 -1
  39. package/dist/index.mjs +13 -3
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/{parseGwei-c2fb9fa2.d.ts → parseGwei-f930d155.d.ts} +46 -9
  42. package/dist/public.d.ts +5 -4
  43. package/dist/public.js +2 -2
  44. package/dist/public.mjs +1 -1
  45. package/dist/{test-a203fdee.d.ts → test-c70126a6.d.ts} +33 -32
  46. package/dist/test.d.ts +10 -10
  47. package/dist/test.js +2 -2
  48. package/dist/test.mjs +1 -1
  49. package/dist/utils/index.d.ts +28 -18
  50. package/dist/utils/index.js +10 -2
  51. package/dist/utils/index.mjs +11 -3
  52. package/dist/wallet.d.ts +5 -4
  53. package/dist/wallet.js +2 -2
  54. package/dist/wallet.mjs +1 -1
  55. package/dist/window.d.ts +2 -2
  56. package/package.json +2 -2
  57. package/dist/chunk-FXDLMUBO.js.map +0 -1
  58. package/dist/chunk-KGXWL2EP.js.map +0 -1
  59. package/dist/chunk-T5H6ROQX.mjs.map +0 -1
  60. package/dist/chunk-YFSMUTVA.mjs.map +0 -1
@@ -13,11 +13,14 @@ import {
13
13
  parseAbiParameters
14
14
  } from "abitype";
15
15
 
16
+ // src/errors/utils.ts
17
+ import "abitype";
18
+
16
19
  // package.json
17
20
  var package_default = {
18
21
  name: "viem",
19
22
  description: "TypeScript Interface for Ethereum",
20
- version: "0.1.20",
23
+ version: "0.1.21",
21
24
  scripts: {
22
25
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
23
26
  bench: "vitest bench --no-threads",
@@ -215,7 +218,9 @@ var BaseError = class extends Error {
215
218
  shortMessage || "An error occurred.",
216
219
  "",
217
220
  ...args.metaMessages ? [...args.metaMessages, ""] : [],
218
- ...docsPath6 ? [`Docs: https://viem.sh${docsPath6}.html`] : [],
221
+ ...docsPath6 ? [
222
+ `Docs: https://viem.sh${docsPath6}.html${args.docsSlug ? `#${args.docsSlug}` : ""}`
223
+ ] : [],
219
224
  ...details ? [`Details: ${details}`] : [],
220
225
  `Version: ${getVersion()}`
221
226
  ].join("\n");
@@ -516,6 +521,23 @@ var UnsupportedPackedAbiType = class extends BaseError {
516
521
  }
517
522
  };
518
523
 
524
+ // src/errors/account.ts
525
+ var AccountNotFoundError = class extends BaseError {
526
+ constructor({ docsPath: docsPath6 } = {}) {
527
+ super(
528
+ [
529
+ "Could not find an Account to execute with this Action.",
530
+ "Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the WalletClient."
531
+ ].join("\n"),
532
+ {
533
+ docsPath: docsPath6,
534
+ docsSlug: "account"
535
+ }
536
+ );
537
+ __publicField(this, "name", "AccountNotFoundError");
538
+ }
539
+ };
540
+
519
541
  // src/errors/address.ts
520
542
  var InvalidAddressError = class extends BaseError {
521
543
  constructor({ address }) {
@@ -569,7 +591,7 @@ var ChainMismatchError = class extends BaseError {
569
591
  currentChainId
570
592
  }) {
571
593
  super(
572
- `The current chain (id: ${currentChainId}) does not match the chain passed to the request (id: ${chain.id} \u2013 ${chain.name}).`,
594
+ `The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} \u2013 ${chain.name}).`,
573
595
  {
574
596
  metaMessages: [
575
597
  `Current Chain ID: ${currentChainId}`,
@@ -580,6 +602,17 @@ var ChainMismatchError = class extends BaseError {
580
602
  __publicField(this, "name", "ChainMismatchError");
581
603
  }
582
604
  };
605
+ var ChainNotFoundError = class extends BaseError {
606
+ constructor() {
607
+ super(
608
+ [
609
+ "No chain was provided to the request.",
610
+ "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
611
+ ].join("\n")
612
+ );
613
+ __publicField(this, "name", "ChainNotFoundError");
614
+ }
615
+ };
583
616
 
584
617
  // src/constants/abis.ts
585
618
  var multicall3Abi = [
@@ -710,7 +743,7 @@ var TransactionExecutionError = class extends BaseError {
710
743
  }) {
711
744
  const prettyArgs = prettyPrint({
712
745
  chain: chain && `${chain?.name} (id: ${chain?.id})`,
713
- from: account.address,
746
+ from: account?.address,
714
747
  to,
715
748
  value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
716
749
  data,
@@ -775,7 +808,7 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
775
808
  // src/errors/contract.ts
776
809
  var CallExecutionError = class extends BaseError {
777
810
  constructor(cause, {
778
- account,
811
+ account: account_,
779
812
  docsPath: docsPath6,
780
813
  chain,
781
814
  data,
@@ -787,6 +820,7 @@ var CallExecutionError = class extends BaseError {
787
820
  to,
788
821
  value
789
822
  }) {
823
+ const account = account_ ? parseAccount(account_) : void 0;
790
824
  const prettyArgs = prettyPrint({
791
825
  from: account?.address,
792
826
  to,
@@ -1029,7 +1063,7 @@ var EstimateGasExecutionError = class extends BaseError {
1029
1063
  value
1030
1064
  }) {
1031
1065
  const prettyArgs = prettyPrint({
1032
- from: account.address,
1066
+ from: account?.address,
1033
1067
  to,
1034
1068
  value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
1035
1069
  data,
@@ -2826,19 +2860,30 @@ function formatAbiItemWithArgs({
2826
2860
  }
2827
2861
 
2828
2862
  // src/utils/account.ts
2829
- function getAccount(account) {
2830
- if (typeof account === "string") {
2831
- if (!isAddress(account))
2832
- throw new InvalidAddressError({ address: account });
2833
- return { address: account, type: "json-rpc" };
2863
+ function getAccount(source) {
2864
+ if (typeof source === "string") {
2865
+ if (!isAddress(source))
2866
+ throw new InvalidAddressError({ address: source });
2867
+ return {
2868
+ address: source,
2869
+ type: "json-rpc"
2870
+ };
2834
2871
  }
2835
- if (!isAddress(account.address))
2836
- throw new InvalidAddressError({ address: account.address });
2872
+ if (!isAddress(source.address))
2873
+ throw new InvalidAddressError({ address: source.address });
2837
2874
  return {
2838
- ...account,
2875
+ address: source.address,
2876
+ signMessage: source.signMessage,
2877
+ signTransaction: source.signTransaction,
2878
+ signTypedData: source.signTypedData,
2839
2879
  type: "local"
2840
2880
  };
2841
2881
  }
2882
+ function parseAccount(account) {
2883
+ if (typeof account === "string")
2884
+ return { address: account, type: "json-rpc" };
2885
+ return account;
2886
+ }
2842
2887
 
2843
2888
  // src/utils/promise/withCache.ts
2844
2889
  var promiseCache = /* @__PURE__ */ new Map();
@@ -3504,6 +3549,163 @@ ${messageBytes.length}`
3504
3549
  return keccak256(concat([prefixBytes, messageBytes]), to_);
3505
3550
  }
3506
3551
 
3552
+ // src/utils/signature/hashTypedData.ts
3553
+ function hashTypedData({
3554
+ domain,
3555
+ message,
3556
+ primaryType,
3557
+ types: types_
3558
+ }) {
3559
+ const types = {
3560
+ EIP712Domain: [
3561
+ domain?.name && { name: "name", type: "string" },
3562
+ domain?.version && { name: "version", type: "string" },
3563
+ domain?.chainId && { name: "chainId", type: "uint256" },
3564
+ domain?.verifyingContract && {
3565
+ name: "verifyingContract",
3566
+ type: "address"
3567
+ },
3568
+ domain?.salt && { name: "salt", type: "bytes32" }
3569
+ ].filter(Boolean),
3570
+ ...types_
3571
+ };
3572
+ let parts = ["0x1901"];
3573
+ if (domain)
3574
+ parts.push(
3575
+ hashDomain({
3576
+ domain,
3577
+ types
3578
+ })
3579
+ );
3580
+ if (primaryType !== "EIP712Domain") {
3581
+ parts.push(
3582
+ hashStruct({
3583
+ data: message,
3584
+ primaryType,
3585
+ types
3586
+ })
3587
+ );
3588
+ }
3589
+ return keccak256(concat(parts));
3590
+ }
3591
+ function hashDomain({
3592
+ domain,
3593
+ types
3594
+ }) {
3595
+ return hashStruct({
3596
+ data: domain,
3597
+ primaryType: "EIP712Domain",
3598
+ types
3599
+ });
3600
+ }
3601
+ function hashStruct({
3602
+ data,
3603
+ primaryType,
3604
+ types
3605
+ }) {
3606
+ const encoded = encodeData({
3607
+ data,
3608
+ primaryType,
3609
+ types
3610
+ });
3611
+ return keccak256(encoded);
3612
+ }
3613
+ function encodeData({
3614
+ data,
3615
+ primaryType,
3616
+ types
3617
+ }) {
3618
+ let encodedTypes = [{ type: "bytes32" }];
3619
+ const encodedValues = [hashType({ primaryType, types })];
3620
+ for (const field of types[primaryType]) {
3621
+ const [type, value] = encodeField({
3622
+ types,
3623
+ name: field.name,
3624
+ type: field.type,
3625
+ value: data[field.name]
3626
+ });
3627
+ encodedTypes.push(type);
3628
+ encodedValues.push(value);
3629
+ }
3630
+ return encodeAbiParameters(encodedTypes, encodedValues);
3631
+ }
3632
+ function hashType({
3633
+ primaryType,
3634
+ types
3635
+ }) {
3636
+ const encodedHashType = toHex(encodeType({ primaryType, types }));
3637
+ return keccak256(encodedHashType);
3638
+ }
3639
+ function encodeType({
3640
+ primaryType,
3641
+ types
3642
+ }) {
3643
+ let result = "";
3644
+ const unsortedDeps = findTypeDependencies({ primaryType, types });
3645
+ unsortedDeps.delete(primaryType);
3646
+ const deps = [primaryType, ...Array.from(unsortedDeps).sort()];
3647
+ for (const type of deps) {
3648
+ result += `${type}(${types[type].map(({ name, type: t }) => `${t} ${name}`).join(",")})`;
3649
+ }
3650
+ return result;
3651
+ }
3652
+ function findTypeDependencies({
3653
+ primaryType: primaryType_,
3654
+ types
3655
+ }, results = /* @__PURE__ */ new Set()) {
3656
+ const match = primaryType_.match(/^\w*/u);
3657
+ const primaryType = match?.[0];
3658
+ if (results.has(primaryType) || types[primaryType] === void 0) {
3659
+ return results;
3660
+ }
3661
+ results.add(primaryType);
3662
+ for (const field of types[primaryType]) {
3663
+ findTypeDependencies({ primaryType: field.type, types }, results);
3664
+ }
3665
+ return results;
3666
+ }
3667
+ function encodeField({
3668
+ types,
3669
+ name,
3670
+ type,
3671
+ value
3672
+ }) {
3673
+ if (types[type] !== void 0) {
3674
+ return [
3675
+ { type: "bytes32" },
3676
+ keccak256(encodeData({ data: value, primaryType: type, types }))
3677
+ ];
3678
+ }
3679
+ if (type === "bytes") {
3680
+ const prepend = value.length % 2 ? "0" : "";
3681
+ value = `0x${prepend + value.slice(2)}`;
3682
+ return [{ type: "bytes32" }, keccak256(value)];
3683
+ }
3684
+ if (type === "string")
3685
+ return [{ type: "bytes32" }, keccak256(toHex(value))];
3686
+ if (type.lastIndexOf("]") === type.length - 1) {
3687
+ const parsedType = type.slice(0, type.lastIndexOf("["));
3688
+ const typeValuePairs = value.map(
3689
+ (item) => encodeField({
3690
+ name,
3691
+ type: parsedType,
3692
+ types,
3693
+ value: item
3694
+ })
3695
+ );
3696
+ return [
3697
+ { type: "bytes32" },
3698
+ keccak256(
3699
+ encodeAbiParameters(
3700
+ typeValuePairs.map(([t]) => t),
3701
+ typeValuePairs.map(([, v]) => v)
3702
+ )
3703
+ )
3704
+ ];
3705
+ }
3706
+ return [{ type }, value];
3707
+ }
3708
+
3507
3709
  // src/utils/signature/recoverAddress.ts
3508
3710
  import { recoverPublicKey } from "@noble/secp256k1";
3509
3711
  function recoverAddress({
@@ -3532,6 +3734,25 @@ function recoverMessageAddress({
3532
3734
  return recoverAddress({ hash: hashMessage(message), signature });
3533
3735
  }
3534
3736
 
3737
+ // src/utils/signature/recoverTypedDataAddress.ts
3738
+ function recoverTypedDataAddress({
3739
+ domain,
3740
+ message,
3741
+ primaryType,
3742
+ signature,
3743
+ types
3744
+ }) {
3745
+ return recoverAddress({
3746
+ hash: hashTypedData({
3747
+ domain,
3748
+ message,
3749
+ primaryType,
3750
+ types
3751
+ }),
3752
+ signature
3753
+ });
3754
+ }
3755
+
3535
3756
  // src/utils/signature/verifyMessage.ts
3536
3757
  function verifyMessage({
3537
3758
  address,
@@ -3544,9 +3765,37 @@ function verifyMessage({
3544
3765
  );
3545
3766
  }
3546
3767
 
3768
+ // src/utils/signature/verifyTypedData.ts
3769
+ function verifyTypedData({
3770
+ address,
3771
+ domain,
3772
+ message,
3773
+ primaryType,
3774
+ signature,
3775
+ types
3776
+ }) {
3777
+ return isAddressEqual(
3778
+ getAddress(address),
3779
+ recoverTypedDataAddress({
3780
+ domain,
3781
+ message,
3782
+ primaryType,
3783
+ signature,
3784
+ types
3785
+ })
3786
+ );
3787
+ }
3788
+
3547
3789
  // src/utils/transaction/assertRequest.ts
3548
3790
  function assertRequest(args) {
3549
- const { account, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
3791
+ const {
3792
+ account: account_,
3793
+ gasPrice,
3794
+ maxFeePerGas,
3795
+ maxPriorityFeePerGas,
3796
+ to
3797
+ } = args;
3798
+ const account = account_ ? parseAccount(account_) : void 0;
3550
3799
  if (account && !isAddress(account.address))
3551
3800
  throw new InvalidAddressError({ address: account.address });
3552
3801
  if (to && !isAddress(to))
@@ -3562,7 +3811,7 @@ function assertRequest(args) {
3562
3811
  // src/actions/public/call.ts
3563
3812
  async function call(client, args) {
3564
3813
  const {
3565
- account,
3814
+ account: account_,
3566
3815
  blockNumber,
3567
3816
  blockTag = "latest",
3568
3817
  accessList,
@@ -3576,6 +3825,7 @@ async function call(client, args) {
3576
3825
  value,
3577
3826
  ...rest
3578
3827
  } = args;
3828
+ const account = account_ ? parseAccount(account_) : void 0;
3579
3829
  try {
3580
3830
  assertRequest(args);
3581
3831
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
@@ -3609,6 +3859,7 @@ async function call(client, args) {
3609
3859
  } catch (err) {
3610
3860
  throw getCallError(err, {
3611
3861
  ...args,
3862
+ account,
3612
3863
  chain: client.chain
3613
3864
  });
3614
3865
  }
@@ -3622,6 +3873,7 @@ async function simulateContract(client, {
3622
3873
  functionName,
3623
3874
  ...callRequest
3624
3875
  }) {
3876
+ const account = callRequest.account ? parseAccount(callRequest.account) : void 0;
3625
3877
  const calldata = encodeFunctionData({
3626
3878
  abi,
3627
3879
  args,
@@ -3656,7 +3908,7 @@ async function simulateContract(client, {
3656
3908
  args,
3657
3909
  docsPath: "/docs/contract/simulateContract",
3658
3910
  functionName,
3659
- sender: callRequest.account?.address
3911
+ sender: account?.address
3660
3912
  });
3661
3913
  }
3662
3914
  }
@@ -3748,9 +4000,13 @@ async function createContractEventFilter(client, {
3748
4000
 
3749
4001
  // src/actions/public/estimateGas.ts
3750
4002
  async function estimateGas(client, args) {
4003
+ if (!args.account)
4004
+ throw new AccountNotFoundError({
4005
+ docsPath: "/docs/actions/public/estimateGas"
4006
+ });
4007
+ const account = parseAccount(args.account);
3751
4008
  try {
3752
4009
  const {
3753
- account,
3754
4010
  accessList,
3755
4011
  blockNumber,
3756
4012
  blockTag = "latest",
@@ -3763,7 +4019,7 @@ async function estimateGas(client, args) {
3763
4019
  to,
3764
4020
  value,
3765
4021
  ...rest
3766
- } = args.account.type === "local" ? await prepareRequest(client, args) : args;
4022
+ } = account.type === "local" ? await prepareRequest(client, args) : args;
3767
4023
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
3768
4024
  assertRequest(args);
3769
4025
  const formatter = client.chain?.formatters?.transactionRequest;
@@ -3794,6 +4050,7 @@ async function estimateGas(client, args) {
3794
4050
  } catch (err) {
3795
4051
  throw getEstimateGasError(err, {
3796
4052
  ...args,
4053
+ account,
3797
4054
  chain: client.chain
3798
4055
  });
3799
4056
  }
@@ -3807,6 +4064,7 @@ async function estimateContractGas(client, {
3807
4064
  functionName,
3808
4065
  ...request
3809
4066
  }) {
4067
+ const account = parseAccount(request.account);
3810
4068
  const data = encodeFunctionData({
3811
4069
  abi,
3812
4070
  args,
@@ -3826,7 +4084,7 @@ async function estimateContractGas(client, {
3826
4084
  args,
3827
4085
  docsPath: "/docs/contract/simulateContract",
3828
4086
  functionName,
3829
- sender: request.account?.address
4087
+ sender: account?.address
3830
4088
  });
3831
4089
  }
3832
4090
  }
@@ -4977,7 +5235,12 @@ async function addChain(client, { chain }) {
4977
5235
  }
4978
5236
 
4979
5237
  // src/actions/wallet/deployContract.ts
4980
- function deployContract(walletClient, { abi, args, bytecode, ...request }) {
5238
+ function deployContract(walletClient, {
5239
+ abi,
5240
+ args,
5241
+ bytecode,
5242
+ ...request
5243
+ }) {
4981
5244
  const calldata = encodeDeployData({
4982
5245
  abi,
4983
5246
  args,
@@ -5018,10 +5281,9 @@ async function requestPermissions(client, permissions) {
5018
5281
  // src/actions/wallet/sendTransaction.ts
5019
5282
  async function sendTransaction(client, args) {
5020
5283
  const {
5021
- account,
5022
- chain,
5284
+ account: account_ = client.account,
5285
+ chain = client.chain,
5023
5286
  accessList,
5024
- assertChain = true,
5025
5287
  data,
5026
5288
  gas,
5027
5289
  gasPrice,
@@ -5032,13 +5294,20 @@ async function sendTransaction(client, args) {
5032
5294
  value,
5033
5295
  ...rest
5034
5296
  } = args;
5297
+ if (!account_)
5298
+ throw new AccountNotFoundError({
5299
+ docsPath: "/docs/actions/wallet/sendTransaction"
5300
+ });
5301
+ const account = parseAccount(account_);
5035
5302
  try {
5036
5303
  assertRequest(args);
5037
- const currentChainId = await getChainId(client);
5038
- if (assertChain && chain && currentChainId !== chain?.id)
5039
- throw new ChainMismatchError({ chain, currentChainId });
5304
+ const chainId = await getChainId(client);
5305
+ if (chain !== null && chainId !== chain?.id) {
5306
+ if (!chain)
5307
+ throw new ChainNotFoundError();
5308
+ throw new ChainMismatchError({ chain, currentChainId: chainId });
5309
+ }
5040
5310
  if (account.type === "local") {
5041
- const chainId = chain?.id ?? currentChainId;
5042
5311
  const request2 = await prepareRequest(client, {
5043
5312
  account,
5044
5313
  accessList,
@@ -5087,12 +5356,25 @@ async function sendTransaction(client, args) {
5087
5356
  params: [request]
5088
5357
  });
5089
5358
  } catch (err) {
5090
- throw getTransactionError(err, args);
5359
+ throw getTransactionError(err, {
5360
+ ...args,
5361
+ account,
5362
+ chain: args.chain || void 0
5363
+ });
5091
5364
  }
5092
5365
  }
5093
5366
 
5094
5367
  // src/actions/wallet/signMessage.ts
5095
- async function signMessage(client, { account, data, message }) {
5368
+ async function signMessage(client, {
5369
+ account: account_ = client.account,
5370
+ data,
5371
+ message
5372
+ }) {
5373
+ if (!account_)
5374
+ throw new AccountNotFoundError({
5375
+ docsPath: "/docs/actions/wallet/signMessage"
5376
+ });
5377
+ const account = parseAccount(account_);
5096
5378
  const message_ = message || data;
5097
5379
  if (account.type === "local")
5098
5380
  return account.signMessage(message_);
@@ -5104,12 +5386,17 @@ async function signMessage(client, { account, data, message }) {
5104
5386
 
5105
5387
  // src/actions/wallet/signTypedData.ts
5106
5388
  async function signTypedData(client, {
5107
- account,
5389
+ account: account_ = client.account,
5108
5390
  domain,
5109
5391
  message,
5110
5392
  primaryType,
5111
5393
  types: types_
5112
5394
  }) {
5395
+ if (!account_)
5396
+ throw new AccountNotFoundError({
5397
+ docsPath: "/docs/actions/wallet/signTypedData"
5398
+ });
5399
+ const account = parseAccount(account_);
5113
5400
  const types = {
5114
5401
  EIP712Domain: [
5115
5402
  domain?.name && { name: "name", type: "string" },
@@ -5259,7 +5546,17 @@ function parseGwei(ether, unit = "wei") {
5259
5546
  // src/utils/transaction/prepareRequest.ts
5260
5547
  var defaultTip = parseGwei("1.5");
5261
5548
  async function prepareRequest(client, args) {
5262
- const { account, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce } = args;
5549
+ const {
5550
+ account: account_,
5551
+ gas,
5552
+ gasPrice,
5553
+ maxFeePerGas,
5554
+ maxPriorityFeePerGas,
5555
+ nonce
5556
+ } = args;
5557
+ if (!account_)
5558
+ throw new AccountNotFoundError();
5559
+ const account = parseAccount(account_);
5263
5560
  const block = await getBlock(client, { blockTag: "latest" });
5264
5561
  const request = { ...args, from: account.address };
5265
5562
  if (typeof nonce === "undefined")
@@ -5479,6 +5776,7 @@ export {
5479
5776
  parseAbiParameter,
5480
5777
  parseAbiParameters,
5481
5778
  getAccount,
5779
+ parseAccount,
5482
5780
  isDeterministicError,
5483
5781
  buildRequest,
5484
5782
  defineChain,
@@ -5504,9 +5802,12 @@ export {
5504
5802
  getSocket,
5505
5803
  rpc,
5506
5804
  hashMessage,
5805
+ hashTypedData,
5507
5806
  recoverAddress,
5508
5807
  recoverMessageAddress,
5808
+ recoverTypedDataAddress,
5509
5809
  verifyMessage,
5810
+ verifyTypedData,
5510
5811
  assertRequest,
5511
5812
  call,
5512
5813
  simulateContract,
@@ -5590,4 +5891,4 @@ export {
5590
5891
  formatGwei,
5591
5892
  parseEther
5592
5893
  };
5593
- //# sourceMappingURL=chunk-T5H6ROQX.mjs.map
5894
+ //# sourceMappingURL=chunk-KOAJUBTN.mjs.map