viem 0.1.8 → 0.1.10

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 (53) 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-d64be356.d.ts → chain-94f99620.d.ts} +7 -31
  5. package/dist/chain-f8edc5d7.d.ts +10 -0
  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-TFO2ZNO6.js → chunk-5FH7E6C5.js} +28 -50
  10. package/dist/chunk-5FH7E6C5.js.map +1 -0
  11. package/dist/{chunk-2NPEMQUQ.mjs → chunk-6YZF7223.mjs} +13 -35
  12. package/dist/chunk-6YZF7223.mjs.map +1 -0
  13. package/dist/{chunk-SWM5USHJ.js → chunk-L5P7BYGT.js} +81 -46
  14. package/dist/chunk-L5P7BYGT.js.map +1 -0
  15. package/dist/{chunk-EYQS4UG5.mjs → chunk-UI4RZ2SR.mjs} +39 -4
  16. package/dist/chunk-UI4RZ2SR.mjs.map +1 -0
  17. package/dist/contract.d.ts +8 -8
  18. package/dist/contract.js +2 -2
  19. package/dist/contract.mjs +1 -1
  20. package/dist/{createClient-8575dcd6.d.ts → createClient-ff222f1b.d.ts} +2 -2
  21. package/dist/{createPublicClient-b12dc2b7.d.ts → createPublicClient-110e0ff7.d.ts} +4 -4
  22. package/dist/{eip1193-029d52f0.d.ts → eip1193-e31a0368.d.ts} +1 -1
  23. package/dist/{encodeFunctionResult-12963e93.d.ts → encodeFunctionResult-5455530b.d.ts} +1 -1
  24. package/dist/{encodePacked-98b20b4d.d.ts → encodePacked-de79982f.d.ts} +1 -1
  25. package/dist/ens.d.ts +4 -4
  26. package/dist/ens.js +3 -3
  27. package/dist/ens.mjs +2 -2
  28. package/dist/{formatAbiItem-8ee3a7fa.d.ts → formatAbiItem-62cbb896.d.ts} +1 -1
  29. package/dist/{getAbiItem-de103f9b.d.ts → getAbiItem-46aa68bf.d.ts} +1 -1
  30. package/dist/index.d.ts +13 -13
  31. package/dist/index.js +89 -89
  32. package/dist/index.mjs +2 -2
  33. package/dist/{parseGwei-ac04b47a.d.ts → parseGwei-d221a29d.d.ts} +3 -3
  34. package/dist/public.d.ts +4 -4
  35. package/dist/public.js +2 -2
  36. package/dist/public.mjs +1 -1
  37. package/dist/{test-f964519b.d.ts → test-796738d1.d.ts} +3 -3
  38. package/dist/test.d.ts +6 -6
  39. package/dist/test.js +2 -2
  40. package/dist/test.mjs +1 -1
  41. package/dist/utils/index.d.ts +13 -13
  42. package/dist/utils/index.js +4 -2
  43. package/dist/utils/index.mjs +3 -1
  44. package/dist/wallet.d.ts +4 -4
  45. package/dist/wallet.js +2 -2
  46. package/dist/wallet.mjs +1 -1
  47. package/dist/window.d.ts +2 -2
  48. package/package.json +2 -2
  49. package/dist/chain-688e1663.d.ts +0 -5
  50. package/dist/chunk-2NPEMQUQ.mjs.map +0 -1
  51. package/dist/chunk-EYQS4UG5.mjs.map +0 -1
  52. package/dist/chunk-SWM5USHJ.js.map +0 -1
  53. package/dist/chunk-TFO2ZNO6.js.map +0 -1
@@ -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.8",
20
+ version: "0.1.10",
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",
@@ -131,7 +131,7 @@ var package_default = {
131
131
  dependencies: {
132
132
  "@noble/hashes": "^1.1.2",
133
133
  "@wagmi/chains": "~0.2.11",
134
- abitype: "~0.6.7",
134
+ abitype: "~0.7.1",
135
135
  "idna-uts46-hx": "^4.1.2",
136
136
  "isomorphic-ws": "^5.0.0",
137
137
  ws: "^8.12.0"
@@ -2964,6 +2964,28 @@ function buildRequest(request, {
2964
2964
  function defineChain(chain) {
2965
2965
  return chain;
2966
2966
  }
2967
+ function getChainContractAddress({
2968
+ blockNumber,
2969
+ chain,
2970
+ contract: name
2971
+ }) {
2972
+ const contract = chain?.contracts?.[name];
2973
+ if (!contract)
2974
+ throw new ChainDoesNotSupportContract({
2975
+ chain,
2976
+ contract: { name }
2977
+ });
2978
+ if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
2979
+ throw new ChainDoesNotSupportContract({
2980
+ blockNumber,
2981
+ chain,
2982
+ contract: {
2983
+ name,
2984
+ blockCreated: contract.blockCreated
2985
+ }
2986
+ });
2987
+ return contract.address;
2988
+ }
2967
2989
 
2968
2990
  // src/utils/formatters/format.ts
2969
2991
  function format3(data, { formatter }) {
@@ -4032,8 +4054,20 @@ async function multicall(client, args) {
4032
4054
  blockNumber,
4033
4055
  blockTag,
4034
4056
  contracts,
4035
- multicallAddress
4057
+ multicallAddress: multicallAddress_
4036
4058
  } = args;
4059
+ let multicallAddress = multicallAddress_;
4060
+ if (!multicallAddress) {
4061
+ if (!client.chain)
4062
+ throw new Error(
4063
+ "client chain not configured. multicallAddress is required."
4064
+ );
4065
+ multicallAddress = getChainContractAddress({
4066
+ blockNumber,
4067
+ chain: client.chain,
4068
+ contract: "multicall3"
4069
+ });
4070
+ }
4037
4071
  const calls = contracts.map(({ abi, address, args: args2, functionName }) => {
4038
4072
  try {
4039
4073
  const callData = encodeFunctionData({
@@ -5244,6 +5278,7 @@ export {
5244
5278
  isDeterministicError,
5245
5279
  buildRequest,
5246
5280
  defineChain,
5281
+ getChainContractAddress,
5247
5282
  format3 as format,
5248
5283
  defineFormatter,
5249
5284
  transactionType,
@@ -5346,4 +5381,4 @@ export {
5346
5381
  formatGwei,
5347
5382
  parseEther
5348
5383
  };
5349
- //# sourceMappingURL=chunk-EYQS4UG5.mjs.map
5384
+ //# sourceMappingURL=chunk-UI4RZ2SR.mjs.map