viem 0.0.1-alpha.26 → 0.0.1-alpha.28

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 (82) hide show
  1. package/dist/chain-4d46a747.d.ts +543 -0
  2. package/dist/{chain-b0cfb141.d.ts → chain-c7c44165.d.ts} +1 -1
  3. package/dist/chains.d.ts +5 -3
  4. package/dist/chains.js +46 -46
  5. package/dist/chains.mjs +1 -1
  6. package/dist/chunk-67DKKHAV.js +210 -0
  7. package/dist/chunk-67DKKHAV.js.map +1 -0
  8. package/dist/{chunk-LINNE4N4.js → chunk-7GQB4KE5.js} +219 -157
  9. package/dist/chunk-7GQB4KE5.js.map +1 -0
  10. package/dist/chunk-FPEKYEVU.js +265 -0
  11. package/dist/chunk-FPEKYEVU.js.map +1 -0
  12. package/dist/chunk-GRILGOX5.mjs +210 -0
  13. package/dist/chunk-GRILGOX5.mjs.map +1 -0
  14. package/dist/{chunk-YTG4YXMB.js → chunk-JJ4FDDDW.js} +16 -16
  15. package/dist/chunk-JJ4FDDDW.js.map +1 -0
  16. package/dist/chunk-NKO23GXR.mjs +265 -0
  17. package/dist/chunk-NKO23GXR.mjs.map +1 -0
  18. package/dist/{chunk-DSQO3E4F.js → chunk-NYWN5V47.js} +219 -59
  19. package/dist/chunk-NYWN5V47.js.map +1 -0
  20. package/dist/{chunk-BSAB6UH4.mjs → chunk-PVBEFQET.mjs} +7 -7
  21. package/dist/chunk-PVBEFQET.mjs.map +1 -0
  22. package/dist/{chunk-QSIX64VZ.mjs → chunk-RCJJFKTU.mjs} +164 -102
  23. package/dist/chunk-RCJJFKTU.mjs.map +1 -0
  24. package/dist/{chunk-PRG3BBPZ.mjs → chunk-TDOKFOQ5.mjs} +223 -63
  25. package/dist/chunk-TDOKFOQ5.mjs.map +1 -0
  26. package/dist/contract.d.ts +12 -128
  27. package/dist/contract.js +6 -4
  28. package/dist/contract.mjs +5 -3
  29. package/dist/{createClient-6689596e.d.ts → createClient-5d5c14d6.d.ts} +5 -3
  30. package/dist/createPublicClient-2b4afeac.d.ts +629 -0
  31. package/dist/{eip1193-617a05ae.d.ts → eip1193-f09a55af.d.ts} +2 -2
  32. package/dist/ens.d.ts +10 -68
  33. package/dist/ens.js +5 -199
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +7 -201
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/formatAbiItem-d231fef2.d.ts +14 -0
  38. package/dist/{getAbiItem-d2e8bd76.d.ts → getAbiItem-0e085959.d.ts} +15 -15
  39. package/dist/index.d.ts +21 -12
  40. package/dist/index.js +368 -26
  41. package/dist/index.js.map +1 -1
  42. package/dist/index.mjs +358 -16
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/namehash-88f4639d.d.ts +22 -0
  45. package/dist/parseGwei-07adffee.d.ts +344 -0
  46. package/dist/public.d.ts +11 -334
  47. package/dist/public.js +5 -3
  48. package/dist/public.mjs +4 -2
  49. package/dist/test-b9208949.d.ts +213 -0
  50. package/dist/test.d.ts +8 -149
  51. package/dist/test.js +20 -222
  52. package/dist/test.js.map +1 -1
  53. package/dist/test.mjs +30 -232
  54. package/dist/test.mjs.map +1 -1
  55. package/dist/{transactionReceipt-44dbf122.d.ts → transactionReceipt-84fc92e1.d.ts} +1 -1
  56. package/dist/{transactionRequest-f437b4ba.d.ts → transactionRequest-44c539b4.d.ts} +1 -1
  57. package/dist/utils/index.d.ts +12 -238
  58. package/dist/utils/index.js +2 -2
  59. package/dist/utils/index.mjs +13 -13
  60. package/dist/wallet-9b1c6905.d.ts +104 -0
  61. package/dist/wallet.d.ts +7 -41
  62. package/dist/wallet.js +3 -3
  63. package/dist/wallet.mjs +2 -2
  64. package/dist/window.d.ts +4 -2
  65. package/package.json +1 -2
  66. package/dist/call-3476b8ee.d.ts +0 -22
  67. package/dist/chain-42de87e5.d.ts +0 -359
  68. package/dist/chunk-BSAB6UH4.mjs.map +0 -1
  69. package/dist/chunk-DSQO3E4F.js.map +0 -1
  70. package/dist/chunk-LINNE4N4.js.map +0 -1
  71. package/dist/chunk-PRG3BBPZ.mjs.map +0 -1
  72. package/dist/chunk-QSIX64VZ.mjs.map +0 -1
  73. package/dist/chunk-YTG4YXMB.js.map +0 -1
  74. package/dist/contract-9dd2f98b.d.ts +0 -166
  75. package/dist/createPublicClient-fd558574.d.ts +0 -19
  76. package/dist/createTestClient-bc1d9028.d.ts +0 -34
  77. package/dist/createWalletClient-4df88244.d.ts +0 -30
  78. package/dist/decodeErrorResult-ac835649.d.ts +0 -16
  79. package/dist/readContract-c460f23a.d.ts +0 -10
  80. package/dist/rpc-8c10fc98.d.ts +0 -119
  81. package/dist/sendTransaction-7ce442c0.d.ts +0 -12
  82. package/dist/watchEvent-569c9976.d.ts +0 -41
@@ -6,13 +6,177 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
 
8
8
  // package.json
9
- var name = "viem";
10
- var version = "0.0.1-alpha.26";
9
+ var package_default = {
10
+ name: "viem",
11
+ description: "TypeScript Interface for Ethereum",
12
+ version: "0.0.1-alpha.28",
13
+ scripts: {
14
+ anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
15
+ bench: "vitest bench --no-threads",
16
+ "bench:ci": "CI=true vitest bench --no-threads",
17
+ build: "tsup",
18
+ changeset: "changeset",
19
+ "changeset:release": "pnpm build && changeset publish",
20
+ "changeset:version": "changeset version && pnpm install --lockfile-only",
21
+ clean: "rimraf dist chains contract ens public test utils wallet window",
22
+ "contracts:build": "wagmi generate",
23
+ dev: "DEV=true tsup",
24
+ "dev:docs": "pnpm -r --filter site dev",
25
+ format: "rome format src/ --write",
26
+ lint: "rome check .",
27
+ "lint:fix": "pnpm lint --apply-suggested",
28
+ playground: "pnpm --filter playground-browser dev",
29
+ postinstall: "pnpm dev && pnpm contracts:build",
30
+ preinstall: "npx only-allow pnpm",
31
+ prepublishOnly: "pnpm bun scripts/prepublishOnly.ts",
32
+ prepare: "npx simple-git-hooks",
33
+ test: "vitest dev --no-threads",
34
+ "test:cov": "vitest dev --coverage --no-threads",
35
+ "test:ci": "CI=true vitest --coverage --no-threads",
36
+ "test:ui": "vitest dev --ui --no-threads",
37
+ "ts-node": "bun",
38
+ typecheck: "tsc --noEmit"
39
+ },
40
+ tsup: {
41
+ entry: [
42
+ "src/index.ts",
43
+ "src/chains.ts",
44
+ "src/contract.ts",
45
+ "src/ens.ts",
46
+ "src/public.ts",
47
+ "src/test.ts",
48
+ "src/utils/index.ts",
49
+ "src/wallet.ts",
50
+ "src/window.ts"
51
+ ]
52
+ },
53
+ files: [
54
+ "/dist",
55
+ "/chains",
56
+ "/contract",
57
+ "/ens",
58
+ "/public",
59
+ "/test",
60
+ "/utils",
61
+ "/wallet",
62
+ "/window"
63
+ ],
64
+ exports: {
65
+ ".": {
66
+ types: "./dist/index.d.ts",
67
+ module: "./dist/index.mts",
68
+ default: "./dist/index.js"
69
+ },
70
+ "./chains": {
71
+ types: "./dist/chains.d.ts",
72
+ module: "./dist/chains.mts",
73
+ default: "./dist/chains.js"
74
+ },
75
+ "./contract": {
76
+ types: "./dist/contract.d.ts",
77
+ module: "./dist/contract.mts",
78
+ default: "./dist/contract.js"
79
+ },
80
+ "./ens": {
81
+ types: "./dist/ens.d.ts",
82
+ module: "./dist/ens.mts",
83
+ default: "./dist/ens.js"
84
+ },
85
+ "./public": {
86
+ types: "./dist/public.d.ts",
87
+ module: "./dist/public.mts",
88
+ default: "./dist/public.js"
89
+ },
90
+ "./test": {
91
+ types: "./dist/test.d.ts",
92
+ module: "./dist/test.mts",
93
+ default: "./dist/test.js"
94
+ },
95
+ "./utils": {
96
+ types: "./dist/utils/index.d.ts",
97
+ module: "./dist/utils/index.mts",
98
+ default: "./dist/utils/index.js"
99
+ },
100
+ "./wallet": {
101
+ types: "./dist/wallet.d.ts",
102
+ module: "./dist/wallet.mts",
103
+ default: "./dist/wallet.js"
104
+ },
105
+ "./window": {
106
+ types: "./dist/window.d.ts",
107
+ module: "./dist/window.mts",
108
+ default: "./dist/window.js"
109
+ },
110
+ "./package.json": "./package.json"
111
+ },
112
+ main: "dist/index.js",
113
+ module: "dist/index.mjs",
114
+ types: "dist/index.d.ts",
115
+ sideEffects: false,
116
+ dependencies: {
117
+ "@noble/hashes": "^1.1.2",
118
+ "@wagmi/chains": "~0.2.8",
119
+ abitype: "~0.3.0",
120
+ "idna-uts46-hx": "^4.1.2",
121
+ "isomorphic-ws": "^5.0.0",
122
+ ws: "^8.12.0"
123
+ },
124
+ devDependencies: {
125
+ "@actions/core": "^1.10.0",
126
+ "@actions/github": "^5.1.1",
127
+ "@adraffy/ens-normalize": "^1.8.9",
128
+ "@changesets/changelog-github": "^0.4.5",
129
+ "@changesets/cli": "^2.23.2",
130
+ "@types/dedent": "^0.7.0",
131
+ "@types/fs-extra": "^9.0.13",
132
+ "@types/node": "^17.0.45",
133
+ "@types/ws": "^8.5.4",
134
+ "@vitest/coverage-c8": "^0.24.3",
135
+ "@vitest/ui": "^0.19.1",
136
+ "@wagmi/cli": "^0.1.6",
137
+ bun: "^0.5.5",
138
+ bundlewatch: "^0.3.3",
139
+ dedent: "^0.7.0",
140
+ ethers: "^5.7.2",
141
+ "ethers@6": "npm:ethers@^6.0.2",
142
+ execa: "^6.1.0",
143
+ "fs-extra": "^10.1.0",
144
+ rimraf: "^4.1.2",
145
+ rome: "^11.0.0",
146
+ "simple-git-hooks": "^2.8.1",
147
+ tsup: "^6.6.0",
148
+ typescript: "^4.9.4",
149
+ vite: "^3.2.5",
150
+ vitest: "~0.25.8",
151
+ web3: "^1.8.1"
152
+ },
153
+ license: "MIT",
154
+ repository: "wagmi-dev/viem",
155
+ authors: [
156
+ "awkweb.eth",
157
+ "jxom.eth"
158
+ ],
159
+ keywords: [
160
+ "eth",
161
+ "ethereum",
162
+ "dapps",
163
+ "wallet",
164
+ "web3"
165
+ ],
166
+ "simple-git-hooks": {
167
+ "pre-commit": "pnpm format && pnpm lint:fix"
168
+ },
169
+ pnpm: {
170
+ patchedDependencies: {
171
+ "vitepress@1.0.0-alpha.34": "patches/vitepress@1.0.0-alpha.34.patch"
172
+ }
173
+ }
174
+ };
11
175
 
12
176
  // src/errors/utils.ts
13
177
  var getContractAddress = (address) => address;
14
178
  var getUrl = (url) => url;
15
- var getVersion = () => `${name}@${version}`;
179
+ var getVersion = () => `${package_default.name}@${package_default.version}`;
16
180
 
17
181
  // src/errors/base.ts
18
182
  var BaseError = class extends Error {
@@ -983,7 +1147,7 @@ function sliceHex(value_, start, end) {
983
1147
  return `0x${value}`;
984
1148
  }
985
1149
 
986
- // src/utils/encoding/encodeHex.ts
1150
+ // src/utils/encoding/toHex.ts
987
1151
  var hexes = Array.from(
988
1152
  { length: 256 },
989
1153
  (v, i) => i.toString(16).padStart(2, "0")
@@ -998,7 +1162,7 @@ function bytesToHex(value) {
998
1162
  }
999
1163
  return `0x${hex}`;
1000
1164
  }
1001
- function encodeHex(value) {
1165
+ function toHex(value) {
1002
1166
  if (typeof value === "number" || typeof value === "bigint")
1003
1167
  return numberToHex(value);
1004
1168
  if (typeof value === "string") {
@@ -1040,14 +1204,14 @@ function stringToHex(value) {
1040
1204
  return `0x${hex}`;
1041
1205
  }
1042
1206
 
1043
- // src/utils/encoding/encodeBytes.ts
1207
+ // src/utils/encoding/toBytes.ts
1044
1208
  var encoder = new TextEncoder();
1045
1209
  function boolToBytes(value) {
1046
1210
  const bytes = new Uint8Array(1);
1047
1211
  bytes[0] = Number(value);
1048
1212
  return bytes;
1049
1213
  }
1050
- function encodeBytes(value) {
1214
+ function toBytes(value) {
1051
1215
  if (typeof value === "number" || typeof value === "bigint")
1052
1216
  return numberToBytes(value);
1053
1217
  if (typeof value === "boolean")
@@ -1079,15 +1243,15 @@ function stringToBytes(value) {
1079
1243
  return encoder.encode(value);
1080
1244
  }
1081
1245
 
1082
- // src/utils/encoding/encodeRlp.ts
1083
- function encodeRlp(hexOrBytes, to_) {
1246
+ // src/utils/encoding/toRlp.ts
1247
+ function toRlp(hexOrBytes, to_) {
1084
1248
  const to = to_ || "hex";
1085
1249
  return format(bytesToRlp(parse(hexOrBytes)), to);
1086
1250
  }
1087
1251
  function parse(hexOrBytes) {
1088
1252
  if (Array.isArray(hexOrBytes))
1089
1253
  return hexOrBytes.map(parse);
1090
- return typeof hexOrBytes === "string" ? encodeBytes(hexOrBytes) : hexOrBytes;
1254
+ return typeof hexOrBytes === "string" ? toBytes(hexOrBytes) : hexOrBytes;
1091
1255
  }
1092
1256
  function format(bytes, type = "bytes") {
1093
1257
  return type === "hex" ? bytesToHex(bytes) : bytes;
@@ -1104,11 +1268,11 @@ function bytesToRlp(bytes) {
1104
1268
  function encodeLength(length, offset) {
1105
1269
  if (length < 56)
1106
1270
  return [offset + length];
1107
- return [encodeBytes(length).length + offset + 55, ...encodeBytes(length)];
1271
+ return [toBytes(length).length + offset + 55, ...toBytes(length)];
1108
1272
  }
1109
1273
 
1110
- // src/utils/encoding/decodeHex.ts
1111
- function decodeHex(hex, to) {
1274
+ // src/utils/encoding/fromHex.ts
1275
+ function fromHex(hex, to) {
1112
1276
  if (to === "number")
1113
1277
  return hexToNumber(hex);
1114
1278
  if (to === "bigint")
@@ -1145,8 +1309,8 @@ function hexToString(hex) {
1145
1309
  return new TextDecoder().decode(bytes);
1146
1310
  }
1147
1311
 
1148
- // src/utils/encoding/decodeBytes.ts
1149
- function decodeBytes(bytes, to) {
1312
+ // src/utils/encoding/fromBytes.ts
1313
+ function fromBytes(bytes, to) {
1150
1314
  if (to === "number")
1151
1315
  return bytesToNumber(bytes);
1152
1316
  if (to === "bigint")
@@ -1174,8 +1338,8 @@ function bytesToString(bytes) {
1174
1338
  return new TextDecoder().decode(bytes);
1175
1339
  }
1176
1340
 
1177
- // src/utils/encoding/decodeRlp.ts
1178
- function decodeRlp(value, to) {
1341
+ // src/utils/encoding/fromRlp.ts
1342
+ function fromRlp(value, to) {
1179
1343
  const bytes = parse2(value);
1180
1344
  const [data, consumed] = rlpToBytes(bytes);
1181
1345
  if (consumed < bytes.length)
@@ -1260,9 +1424,9 @@ var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
1260
1424
  function extractFunctionParts(def) {
1261
1425
  const parts = def.match(paramsRegex);
1262
1426
  const type = parts?.[2] || void 0;
1263
- const name2 = parts?.[3];
1427
+ const name = parts?.[3];
1264
1428
  const params = parts?.[5] || void 0;
1265
- return { type, name: name2, params };
1429
+ return { type, name, params };
1266
1430
  }
1267
1431
  function extractFunctionName(def) {
1268
1432
  return extractFunctionParts(def).name;
@@ -1319,17 +1483,17 @@ function keccak256(value, to_) {
1319
1483
  const bytes = keccak_256(value);
1320
1484
  if (to === "bytes")
1321
1485
  return bytes;
1322
- return encodeHex(bytes);
1486
+ return toHex(bytes);
1323
1487
  }
1324
1488
 
1325
1489
  // src/utils/hash/hashFunction.ts
1326
- var hash = (value) => keccak256(encodeBytes(value));
1490
+ var hash = (value) => keccak256(toBytes(value));
1327
1491
  function hashFunction(def) {
1328
- const name2 = extractFunctionName(def);
1492
+ const name = extractFunctionName(def);
1329
1493
  const params = extractFunctionParams(def);
1330
1494
  if (!params || params.length === 0)
1331
1495
  return hash(def.replace(/ /g, ""));
1332
- return hash(`${name2}(${params.map(({ type }) => type).join(",")})`);
1496
+ return hash(`${name}(${params.map(({ type }) => type).join(",")})`);
1333
1497
  }
1334
1498
 
1335
1499
  // src/utils/hash/getEventSignature.ts
@@ -1339,7 +1503,7 @@ var getEventSignature = (event) => hashFunction(event);
1339
1503
  var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
1340
1504
 
1341
1505
  // src/utils/address/getAddress.ts
1342
- var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
1506
+ var addressRegex = /^0x[a-fA-F0-9]{40}$/;
1343
1507
  function checksumAddress(address_) {
1344
1508
  const hexAddress = address_.substring(2).toLowerCase();
1345
1509
  const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
@@ -1367,30 +1531,26 @@ function getContractAddress2(opts) {
1367
1531
  return getCreateAddress(opts);
1368
1532
  }
1369
1533
  function getCreateAddress(opts) {
1370
- const from = encodeBytes(getAddress(opts.from));
1371
- let nonce = encodeBytes(opts.nonce);
1534
+ const from = toBytes(getAddress(opts.from));
1535
+ let nonce = toBytes(opts.nonce);
1372
1536
  if (nonce[0] === 0)
1373
1537
  nonce = new Uint8Array([]);
1374
1538
  return getAddress(
1375
- `0x${keccak256(encodeRlp([from, nonce], "bytes")).slice(26)}`
1539
+ `0x${keccak256(toRlp([from, nonce], "bytes")).slice(26)}`
1376
1540
  );
1377
1541
  }
1378
1542
  function getCreate2Address(opts) {
1379
- const from = encodeBytes(getAddress(opts.from));
1380
- const salt = pad(
1381
- isBytes(opts.salt) ? opts.salt : encodeBytes(opts.salt),
1382
- { size: 32 }
1383
- );
1384
- const bytecodeHash = encodeBytes(
1543
+ const from = toBytes(getAddress(opts.from));
1544
+ const salt = pad(isBytes(opts.salt) ? opts.salt : toBytes(opts.salt), {
1545
+ size: 32
1546
+ });
1547
+ const bytecodeHash = toBytes(
1385
1548
  keccak256(
1386
- isBytes(opts.bytecode) ? opts.bytecode : encodeBytes(opts.bytecode)
1549
+ isBytes(opts.bytecode) ? opts.bytecode : toBytes(opts.bytecode)
1387
1550
  )
1388
1551
  );
1389
1552
  return getAddress(
1390
- slice(
1391
- keccak256(concat([encodeBytes("0xff"), from, salt, bytecodeHash])),
1392
- 12
1393
- )
1553
+ slice(keccak256(concat([toBytes("0xff"), from, salt, bytecodeHash])), 12)
1394
1554
  );
1395
1555
  }
1396
1556
 
@@ -1459,7 +1619,7 @@ function prepareParam({
1459
1619
  return encodeNumber(value, { signed });
1460
1620
  }
1461
1621
  if (param.type.startsWith("bytes")) {
1462
- return encodeBytes2(value, { param });
1622
+ return toBytes2(value, { param });
1463
1623
  }
1464
1624
  if (param.type === "string") {
1465
1625
  return encodeString(value);
@@ -1533,7 +1693,7 @@ function encodeArray(value, {
1533
1693
  encoded: concat(preparedParams.map(({ encoded }) => encoded))
1534
1694
  };
1535
1695
  }
1536
- function encodeBytes2(value, { param }) {
1696
+ function toBytes2(value, { param }) {
1537
1697
  const [_, size_] = param.type.split("bytes");
1538
1698
  if (!size_) {
1539
1699
  const partsLength = Math.floor(size(value) / 32);
@@ -1647,7 +1807,7 @@ function decodeParam({
1647
1807
  return decodeString(data, { position });
1648
1808
  }
1649
1809
  if (param.type.startsWith("bytes")) {
1650
- return decodeBytes2(data, { param, position });
1810
+ return fromBytes2(data, { param, position });
1651
1811
  }
1652
1812
  let value = slice(data, position, position + 32);
1653
1813
  if (param.type.startsWith("uint") || param.type.startsWith("int")) {
@@ -1720,7 +1880,7 @@ function decodeArray(data, {
1720
1880
  function decodeBool(value) {
1721
1881
  return { consumed: 32, value: hexToBool(value) };
1722
1882
  }
1723
- function decodeBytes2(data, { param, position }) {
1883
+ function fromBytes2(data, { param, position }) {
1724
1884
  const [_, size2] = param.type.split("bytes");
1725
1885
  if (!size2) {
1726
1886
  const offset = hexToNumber(slice(data, position, position + 32));
@@ -1748,7 +1908,7 @@ function decodeString(data, { position }) {
1748
1908
  return { consumed: 32, value };
1749
1909
  }
1750
1910
  function decodeTuple(data, { param, position }) {
1751
- const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name: name2 }) => !name2);
1911
+ const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
1752
1912
  let value = hasUnnamedChild ? [] : {};
1753
1913
  let consumed = 0;
1754
1914
  if (hasDynamicChild(param)) {
@@ -1851,7 +2011,7 @@ function decodeEventLog({
1851
2011
  throw new AbiEventSignatureNotFoundError(signature, {
1852
2012
  docsPath: "/docs/contract/decodeEventLog"
1853
2013
  });
1854
- const { name: name2, inputs } = abiItem;
2014
+ const { name, inputs } = abiItem;
1855
2015
  const isUnnamed = inputs?.some((x) => !("name" in x && x.name));
1856
2016
  let args = isUnnamed ? [] : {};
1857
2017
  for (let i = 0; i < inputs.length; i++) {
@@ -1867,7 +2027,7 @@ function decodeEventLog({
1867
2027
  args[param.name || i] = decodeTopic({ param, value: topic });
1868
2028
  }
1869
2029
  }
1870
- if (data) {
2030
+ if (data && data !== "0x") {
1871
2031
  const params = inputs.filter((x) => !("indexed" in x && x.indexed));
1872
2032
  const decodedData = decodeAbi({ params, data });
1873
2033
  if (decodedData) {
@@ -1881,7 +2041,7 @@ function decodeEventLog({
1881
2041
  }
1882
2042
  }
1883
2043
  return {
1884
- eventName: name2,
2044
+ eventName: name,
1885
2045
  args: Object.values(args).length > 0 ? args : void 0
1886
2046
  };
1887
2047
  }
@@ -1909,8 +2069,8 @@ function decodeFunctionData({ abi, data }) {
1909
2069
  }
1910
2070
 
1911
2071
  // src/utils/abi/getAbiItem.ts
1912
- function getAbiItem({ abi, args = [], name: name2 }) {
1913
- const abiItems = abi.filter((x) => "name" in x && x.name === name2);
2072
+ function getAbiItem({ abi, args = [], name }) {
2073
+ const abiItems = abi.filter((x) => "name" in x && x.name === name);
1914
2074
  if (abiItems.length === 0)
1915
2075
  return void 0;
1916
2076
  if (abiItems.length === 1)
@@ -2076,7 +2236,7 @@ function encodeArg({
2076
2236
  value
2077
2237
  }) {
2078
2238
  if (param.type === "string" || param.type === "bytes")
2079
- return keccak256(encodeBytes(value));
2239
+ return keccak256(toBytes(value));
2080
2240
  if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2081
2241
  throw new FilterTypeNotSupportedError(param.type);
2082
2242
  return encodeAbi({ params: [param], values: [value] });
@@ -2254,7 +2414,7 @@ var isDeterministicError = (error) => {
2254
2414
  if ("code" in error)
2255
2415
  return error.code !== -32603 && error.code !== -32005;
2256
2416
  if (error instanceof HttpRequestError && error.status)
2257
- return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500;
2417
+ return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500 && error.status !== 502 && error.status !== 503 && error.status !== 504;
2258
2418
  return true;
2259
2419
  };
2260
2420
  function buildRequest(request, {
@@ -2422,12 +2582,13 @@ function formatFeeHistory(feeHistory) {
2422
2582
  }
2423
2583
 
2424
2584
  // src/utils/formatters/log.ts
2425
- function formatLog(log) {
2585
+ function formatLog(log, { args, eventName } = {}) {
2426
2586
  return {
2427
2587
  ...log,
2428
2588
  blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
2429
2589
  logIndex: log.logIndex ? BigInt(log.logIndex) : null,
2430
- transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null
2590
+ transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null,
2591
+ ...eventName ? { args, eventName } : {}
2431
2592
  };
2432
2593
  }
2433
2594
 
@@ -2443,7 +2604,7 @@ function formatTransactionReceipt(transactionReceipt) {
2443
2604
  cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
2444
2605
  effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
2445
2606
  gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
2446
- logs: transactionReceipt.logs ? transactionReceipt.logs.map(formatLog) : null,
2607
+ logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
2447
2608
  transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
2448
2609
  status: transactionReceipt.status ? statuses[transactionReceipt.status] : null,
2449
2610
  type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
@@ -2470,7 +2631,6 @@ var defineTransactionRequest = defineFormatter({
2470
2631
  });
2471
2632
 
2472
2633
  // src/utils/rpc.ts
2473
- import fetch from "isomorphic-unfetch";
2474
2634
  import WebSocket from "isomorphic-ws";
2475
2635
 
2476
2636
  // src/utils/stringify.ts
@@ -2485,7 +2645,7 @@ function stringify(value) {
2485
2645
  var id = 0;
2486
2646
  async function http(url, {
2487
2647
  body,
2488
- timeout = 0
2648
+ timeout = 1e4
2489
2649
  }) {
2490
2650
  try {
2491
2651
  const response = await withTimeout(
@@ -2616,7 +2776,7 @@ function webSocket(socket, {
2616
2776
  }
2617
2777
  async function webSocketAsync(socket, {
2618
2778
  body,
2619
- timeout = 0
2779
+ timeout = 1e4
2620
2780
  }) {
2621
2781
  return withTimeout(
2622
2782
  () => new Promise(
@@ -2782,26 +2942,26 @@ export {
2782
2942
  sliceHex,
2783
2943
  boolToHex,
2784
2944
  bytesToHex,
2785
- encodeHex,
2945
+ toHex,
2786
2946
  numberToHex,
2787
2947
  stringToHex,
2788
2948
  boolToBytes,
2789
- encodeBytes,
2949
+ toBytes,
2790
2950
  hexToBytes,
2791
2951
  numberToBytes,
2792
2952
  stringToBytes,
2793
- encodeRlp,
2794
- decodeHex,
2953
+ toRlp,
2954
+ fromHex,
2795
2955
  hexToBigInt,
2796
2956
  hexToBool,
2797
2957
  hexToNumber,
2798
2958
  hexToString,
2799
- decodeBytes,
2959
+ fromBytes,
2800
2960
  bytesToBigint,
2801
2961
  bytesToBool,
2802
2962
  bytesToNumber,
2803
2963
  bytesToString,
2804
- decodeRlp,
2964
+ fromRlp,
2805
2965
  extractFunctionParts,
2806
2966
  extractFunctionName,
2807
2967
  extractFunctionParams,
@@ -2864,4 +3024,4 @@ export {
2864
3024
  parseEther,
2865
3025
  parseGwei
2866
3026
  };
2867
- //# sourceMappingURL=chunk-PRG3BBPZ.mjs.map
3027
+ //# sourceMappingURL=chunk-TDOKFOQ5.mjs.map