viem 0.2.0-canary.20230313T230538 → 0.2.0-canary.20230314T023056

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.
@@ -11,27 +11,27 @@
11
11
 
12
12
 
13
13
 
14
- var _chunkRSEMPS5Hjs = require('./chunk-RSEMPS5H.js');
14
+ var _chunkE6DS7ZIHjs = require('./chunk-E6DS7ZIH.js');
15
15
 
16
16
  // src/utils/ens/labelhash.ts
17
17
  function labelhash(label) {
18
18
  let result = new Uint8Array(32).fill(0);
19
19
  if (!label)
20
- return _chunkRSEMPS5Hjs.bytesToHex.call(void 0, result);
21
- return _chunkRSEMPS5Hjs.keccak256.call(void 0, _chunkRSEMPS5Hjs.stringToBytes.call(void 0, label));
20
+ return _chunkE6DS7ZIHjs.bytesToHex.call(void 0, result);
21
+ return _chunkE6DS7ZIHjs.keccak256.call(void 0, _chunkE6DS7ZIHjs.stringToBytes.call(void 0, label));
22
22
  }
23
23
 
24
24
  // src/utils/ens/namehash.ts
25
25
  function namehash(name) {
26
26
  let result = new Uint8Array(32).fill(0);
27
27
  if (!name)
28
- return _chunkRSEMPS5Hjs.bytesToHex.call(void 0, result);
28
+ return _chunkE6DS7ZIHjs.bytesToHex.call(void 0, result);
29
29
  const labels = name.split(".");
30
30
  for (let i = labels.length - 1; i >= 0; i -= 1) {
31
- const hashed = _chunkRSEMPS5Hjs.keccak256.call(void 0, _chunkRSEMPS5Hjs.stringToBytes.call(void 0, labels[i]), "bytes");
32
- result = _chunkRSEMPS5Hjs.keccak256.call(void 0, _chunkRSEMPS5Hjs.concat.call(void 0, [result, hashed]), "bytes");
31
+ const hashed = _chunkE6DS7ZIHjs.keccak256.call(void 0, _chunkE6DS7ZIHjs.stringToBytes.call(void 0, labels[i]), "bytes");
32
+ result = _chunkE6DS7ZIHjs.keccak256.call(void 0, _chunkE6DS7ZIHjs.concat.call(void 0, [result, hashed]), "bytes");
33
33
  }
34
- return _chunkRSEMPS5Hjs.bytesToHex.call(void 0, result);
34
+ return _chunkE6DS7ZIHjs.bytesToHex.call(void 0, result);
35
35
  }
36
36
 
37
37
  // src/utils/ens/packetToBytes.ts
@@ -39,7 +39,7 @@ function packetToBytes(packet) {
39
39
  function length(value2) {
40
40
  if (value2 === "." || value2 === "..")
41
41
  return 1;
42
- return _chunkRSEMPS5Hjs.toBytes.call(void 0, value2.replace(/^\.|\.$/gm, "")).length + 2;
42
+ return _chunkE6DS7ZIHjs.toBytes.call(void 0, value2.replace(/^\.|\.$/gm, "")).length + 2;
43
43
  }
44
44
  const bytes = new Uint8Array(length(packet));
45
45
  const value = packet.replace(/^\.|\.$/gm, "");
@@ -48,7 +48,7 @@ function packetToBytes(packet) {
48
48
  let offset = 0;
49
49
  const list = value.split(".");
50
50
  for (let i = 0; i < list.length; i++) {
51
- const encoded = _chunkRSEMPS5Hjs.toBytes.call(void 0, list[i]);
51
+ const encoded = _chunkE6DS7ZIHjs.toBytes.call(void 0, list[i]);
52
52
  bytes[offset] = encoded.length;
53
53
  bytes.set(encoded, offset + 1);
54
54
  offset += encoded.length + 1;
@@ -69,13 +69,13 @@ async function getEnsAddress(client, {
69
69
  throw new Error(
70
70
  "client chain not configured. universalResolverAddress is required."
71
71
  );
72
- universalResolverAddress = _chunkRSEMPS5Hjs.getChainContractAddress.call(void 0, {
72
+ universalResolverAddress = _chunkE6DS7ZIHjs.getChainContractAddress.call(void 0, {
73
73
  blockNumber,
74
74
  chain: client.chain,
75
75
  contract: "ensUniversalResolver"
76
76
  });
77
77
  }
78
- const res = await _chunkRSEMPS5Hjs.readContract.call(void 0, client, {
78
+ const res = await _chunkE6DS7ZIHjs.readContract.call(void 0, client, {
79
79
  address: universalResolverAddress,
80
80
  abi: [
81
81
  {
@@ -94,8 +94,8 @@ async function getEnsAddress(client, {
94
94
  ],
95
95
  functionName: "resolve",
96
96
  args: [
97
- _chunkRSEMPS5Hjs.toHex.call(void 0, packetToBytes(name)),
98
- _chunkRSEMPS5Hjs.encodeFunctionData.call(void 0, {
97
+ _chunkE6DS7ZIHjs.toHex.call(void 0, packetToBytes(name)),
98
+ _chunkE6DS7ZIHjs.encodeFunctionData.call(void 0, {
99
99
  abi: [
100
100
  {
101
101
  name: "addr",
@@ -112,7 +112,7 @@ async function getEnsAddress(client, {
112
112
  blockNumber,
113
113
  blockTag
114
114
  });
115
- return _chunkRSEMPS5Hjs.decodeFunctionResult.call(void 0, {
115
+ return _chunkE6DS7ZIHjs.decodeFunctionResult.call(void 0, {
116
116
  abi: [
117
117
  {
118
118
  name: "addr",
@@ -140,7 +140,7 @@ async function getEnsName(client, {
140
140
  throw new Error(
141
141
  "client chain not configured. universalResolverAddress is required."
142
142
  );
143
- universalResolverAddress = _chunkRSEMPS5Hjs.getChainContractAddress.call(void 0, {
143
+ universalResolverAddress = _chunkE6DS7ZIHjs.getChainContractAddress.call(void 0, {
144
144
  blockNumber,
145
145
  chain: client.chain,
146
146
  contract: "ensUniversalResolver"
@@ -148,7 +148,7 @@ async function getEnsName(client, {
148
148
  }
149
149
  const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
150
150
  try {
151
- const res = await _chunkRSEMPS5Hjs.readContract.call(void 0, client, {
151
+ const res = await _chunkE6DS7ZIHjs.readContract.call(void 0, client, {
152
152
  address: universalResolverAddress,
153
153
  abi: [
154
154
  {
@@ -165,13 +165,13 @@ async function getEnsName(client, {
165
165
  }
166
166
  ],
167
167
  functionName: "reverse",
168
- args: [_chunkRSEMPS5Hjs.toHex.call(void 0, packetToBytes(reverseNode))],
168
+ args: [_chunkE6DS7ZIHjs.toHex.call(void 0, packetToBytes(reverseNode))],
169
169
  blockNumber,
170
170
  blockTag
171
171
  });
172
172
  return res[0];
173
173
  } catch (error) {
174
- if (error instanceof _chunkRSEMPS5Hjs.ContractFunctionExecutionError && error.cause.reason === _chunkRSEMPS5Hjs.panicReasons[50])
174
+ if (error instanceof _chunkE6DS7ZIHjs.ContractFunctionExecutionError && error.cause.reason === _chunkE6DS7ZIHjs.panicReasons[50])
175
175
  return null;
176
176
  throw error;
177
177
  }
@@ -183,4 +183,4 @@ async function getEnsName(client, {
183
183
 
184
184
 
185
185
  exports.labelhash = labelhash; exports.namehash = namehash; exports.getEnsAddress = getEnsAddress; exports.getEnsName = getEnsName;
186
- //# sourceMappingURL=chunk-43MIG4FP.js.map
186
+ //# sourceMappingURL=chunk-XPAZ5N5B.js.map
@@ -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.15",
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",
@@ -4384,8 +4384,10 @@ function watchBlockNumber(client, {
4384
4384
  }
4385
4385
  }
4386
4386
  }
4387
- prevBlockNumber = blockNumber;
4388
- emit.onBlockNumber(blockNumber, prevBlockNumber);
4387
+ if (!prevBlockNumber || blockNumber > prevBlockNumber) {
4388
+ emit.onBlockNumber(blockNumber, prevBlockNumber);
4389
+ prevBlockNumber = blockNumber;
4390
+ }
4389
4391
  } catch (err) {
4390
4392
  emit.onError?.(err);
4391
4393
  }
@@ -4441,8 +4443,16 @@ function watchBlocks(client, {
4441
4443
  }
4442
4444
  }
4443
4445
  }
4444
- emit.onBlock(block, prevBlock);
4445
- prevBlock = block;
4446
+ if (
4447
+ // If no previous block exists, emit.
4448
+ !prevBlock?.number || // If the block tag is "pending" with no block number, emit.
4449
+ blockTag === "pending" && !block?.number || // If the next block number is greater than the previous block number, emit.
4450
+ // We don't want to emit blocks in the past.
4451
+ block.number && block.number > prevBlock.number
4452
+ ) {
4453
+ emit.onBlock(block, prevBlock);
4454
+ prevBlock = block;
4455
+ }
4446
4456
  } catch (err) {
4447
4457
  emit.onError?.(err);
4448
4458
  }
@@ -5523,4 +5533,4 @@ export {
5523
5533
  formatGwei,
5524
5534
  parseEther
5525
5535
  };
5526
- //# sourceMappingURL=chunk-H5XRC6PB.mjs.map
5536
+ //# sourceMappingURL=chunk-YJVNIQSC.mjs.map