viem 0.2.1 → 0.2.3

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 (39) hide show
  1. package/dist/abi.js +2 -2
  2. package/dist/abi.mjs +1 -1
  3. package/dist/accounts/index.d.ts +19 -10
  4. package/dist/accounts/index.js +55 -30
  5. package/dist/accounts/index.js.map +1 -1
  6. package/dist/accounts/index.mjs +48 -23
  7. package/dist/accounts/index.mjs.map +1 -1
  8. package/dist/chains.d.ts +2 -0
  9. package/dist/chains.js +89 -89
  10. package/dist/chains.mjs +1 -1
  11. package/dist/{chunk-2DDJFGFE.js → chunk-E6JLGC6W.js} +25 -26
  12. package/dist/chunk-E6JLGC6W.js.map +1 -0
  13. package/dist/{chunk-YCI363JZ.mjs → chunk-FYMFYRJQ.mjs} +2 -2
  14. package/dist/{chunk-4EJIKB23.js → chunk-TXGT3ARS.js} +6 -6
  15. package/dist/{chunk-LEU2ZGMI.mjs → chunk-ZM26BDGF.mjs} +25 -26
  16. package/dist/chunk-ZM26BDGF.mjs.map +1 -0
  17. package/dist/contract.js +2 -2
  18. package/dist/contract.mjs +1 -1
  19. package/dist/ens.js +5 -5
  20. package/dist/ens.js.map +1 -1
  21. package/dist/ens.mjs +3 -3
  22. package/dist/ens.mjs.map +1 -1
  23. package/dist/ethers.js +4 -4
  24. package/dist/ethers.mjs +2 -2
  25. package/dist/index.js +94 -94
  26. package/dist/index.mjs +1 -1
  27. package/dist/public.js +2 -2
  28. package/dist/public.mjs +1 -1
  29. package/dist/test.js +2 -2
  30. package/dist/test.mjs +1 -1
  31. package/dist/utils/index.js +2 -2
  32. package/dist/utils/index.mjs +1 -1
  33. package/dist/wallet.js +2 -2
  34. package/dist/wallet.mjs +1 -1
  35. package/package.json +10 -11
  36. package/dist/chunk-2DDJFGFE.js.map +0 -1
  37. package/dist/chunk-LEU2ZGMI.mjs.map +0 -1
  38. /package/dist/{chunk-YCI363JZ.mjs.map → chunk-FYMFYRJQ.mjs.map} +0 -0
  39. /package/dist/{chunk-4EJIKB23.js.map → chunk-TXGT3ARS.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  InvalidAddressError,
3
3
  isAddress
4
- } from "./chunk-LEU2ZGMI.mjs";
4
+ } from "./chunk-ZM26BDGF.mjs";
5
5
 
6
6
  // src/accounts/toAccount.ts
7
7
  function toAccount(source) {
@@ -28,4 +28,4 @@ function toAccount(source) {
28
28
  export {
29
29
  toAccount
30
30
  };
31
- //# sourceMappingURL=chunk-YCI363JZ.mjs.map
31
+ //# sourceMappingURL=chunk-FYMFYRJQ.mjs.map
@@ -1,20 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk2DDJFGFEjs = require('./chunk-2DDJFGFE.js');
4
+ var _chunkE6JLGC6Wjs = require('./chunk-E6JLGC6W.js');
5
5
 
6
6
  // src/accounts/toAccount.ts
7
7
  function toAccount(source) {
8
8
  if (typeof source === "string") {
9
- if (!_chunk2DDJFGFEjs.isAddress.call(void 0, source))
10
- throw new (0, _chunk2DDJFGFEjs.InvalidAddressError)({ address: source });
9
+ if (!_chunkE6JLGC6Wjs.isAddress.call(void 0, source))
10
+ throw new (0, _chunkE6JLGC6Wjs.InvalidAddressError)({ address: source });
11
11
  return {
12
12
  address: source,
13
13
  type: "json-rpc"
14
14
  };
15
15
  }
16
- if (!_chunk2DDJFGFEjs.isAddress.call(void 0, source.address))
17
- throw new (0, _chunk2DDJFGFEjs.InvalidAddressError)({ address: source.address });
16
+ if (!_chunkE6JLGC6Wjs.isAddress.call(void 0, source.address))
17
+ throw new (0, _chunkE6JLGC6Wjs.InvalidAddressError)({ address: source.address });
18
18
  return {
19
19
  address: source.address,
20
20
  signMessage: source.signMessage,
@@ -28,4 +28,4 @@ function toAccount(source) {
28
28
 
29
29
 
30
30
  exports.toAccount = toAccount;
31
- //# sourceMappingURL=chunk-4EJIKB23.js.map
31
+ //# sourceMappingURL=chunk-TXGT3ARS.js.map
@@ -20,7 +20,7 @@ import "abitype";
20
20
  var package_default = {
21
21
  name: "viem",
22
22
  description: "TypeScript Interface for Ethereum",
23
- version: "0.2.1",
23
+ version: "0.2.3",
24
24
  scripts: {
25
25
  anvil: "dotenv -- sh -c 'anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME'",
26
26
  bench: "vitest bench --no-threads",
@@ -147,16 +147,15 @@ var package_default = {
147
147
  types: "dist/index.d.ts",
148
148
  sideEffects: false,
149
149
  dependencies: {
150
- "@ensdomains/address-encoder": "^0.2.21",
151
- "@noble/curves": "^0.9.0",
152
- "@noble/hashes": "^1.1.2",
153
- "@scure/bip32": "^1.2.0",
154
- "@scure/bip39": "^1.1.1",
155
- "@wagmi/chains": "~0.2.15",
156
- abitype: "~0.7.1",
157
- "idna-uts46-hx": "^4.1.2",
158
- "isomorphic-ws": "^5.0.0",
159
- ws: "^8.12.0"
150
+ "@noble/curves": "0.9.0",
151
+ "@noble/hashes": "1.3.0",
152
+ "@scure/bip32": "1.2.0",
153
+ "@scure/bip39": "1.2.0",
154
+ "@wagmi/chains": "0.2.16",
155
+ abitype: "0.7.1",
156
+ "idna-uts46-hx": "4.1.2",
157
+ "isomorphic-ws": "5.0.0",
158
+ ws: "8.12.0"
160
159
  },
161
160
  devDependencies: {
162
161
  "@actions/core": "^1.10.0",
@@ -1658,6 +1657,15 @@ var UrlRequiredError = class extends BaseError {
1658
1657
  }
1659
1658
  };
1660
1659
 
1660
+ // src/utils/data/isHex.ts
1661
+ function isHex(value) {
1662
+ if (!value)
1663
+ return false;
1664
+ if (typeof value !== "string")
1665
+ return false;
1666
+ return /^0x[0-9a-fA-F]*$/.test(value);
1667
+ }
1668
+
1661
1669
  // src/utils/data/concat.ts
1662
1670
  function concat(values) {
1663
1671
  if (typeof values[0] === "string")
@@ -1695,15 +1703,6 @@ function isBytes(value) {
1695
1703
  return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
1696
1704
  }
1697
1705
 
1698
- // src/utils/data/isHex.ts
1699
- function isHex(value) {
1700
- if (!value)
1701
- return false;
1702
- if (typeof value !== "string")
1703
- return false;
1704
- return /^0x[0-9a-fA-F]*$/.test(value);
1705
- }
1706
-
1707
1706
  // src/utils/data/pad.ts
1708
1707
  function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
1709
1708
  if (typeof hexOrBytes === "string")
@@ -1858,7 +1857,7 @@ function toBytes(value) {
1858
1857
  return numberToBytes(value);
1859
1858
  if (typeof value === "boolean")
1860
1859
  return boolToBytes(value);
1861
- if (value.startsWith("0x"))
1860
+ if (isHex(value))
1862
1861
  return hexToBytes(value);
1863
1862
  return stringToBytes(value);
1864
1863
  }
@@ -2119,7 +2118,7 @@ var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
2119
2118
 
2120
2119
  // src/utils/hash/isHash.ts
2121
2120
  function isHash(hash2) {
2122
- return hash2.startsWith("0x") && size(hash2) === 32;
2121
+ return isHex(hash2) && size(hash2) === 32;
2123
2122
  }
2124
2123
 
2125
2124
  // src/utils/address/isAddress.ts
@@ -4287,7 +4286,7 @@ function packetToBytes(packet) {
4287
4286
  function length(value2) {
4288
4287
  if (value2 === "." || value2 === "..")
4289
4288
  return 1;
4290
- return toBytes(value2.replace(/^\.|\.$/gm, "")).length + 2;
4289
+ return stringToBytes(value2.replace(/^\.|\.$/gm, "")).length + 2;
4291
4290
  }
4292
4291
  const bytes = new Uint8Array(length(packet));
4293
4292
  const value = packet.replace(/^\.|\.$/gm, "");
@@ -4296,7 +4295,7 @@ function packetToBytes(packet) {
4296
4295
  let offset = 0;
4297
4296
  const list = value.split(".");
4298
4297
  for (let i = 0; i < list.length; i++) {
4299
- const encoded = toBytes(list[i]);
4298
+ const encoded = stringToBytes(list[i]);
4300
4299
  bytes[offset] = encoded.length;
4301
4300
  bytes.set(encoded, offset + 1);
4302
4301
  offset += encoded.length + 1;
@@ -7016,11 +7015,11 @@ export {
7016
7015
  RpcError,
7017
7016
  TimeoutError,
7018
7017
  UrlRequiredError,
7018
+ isHex,
7019
7019
  concat,
7020
7020
  concatBytes,
7021
7021
  concatHex,
7022
7022
  isBytes,
7023
- isHex,
7024
7023
  pad,
7025
7024
  padHex,
7026
7025
  padBytes,
@@ -7220,4 +7219,4 @@ export {
7220
7219
  writeContract,
7221
7220
  getContract
7222
7221
  };
7223
- //# sourceMappingURL=chunk-LEU2ZGMI.mjs.map
7222
+ //# sourceMappingURL=chunk-ZM26BDGF.mjs.map