viem 0.0.1-alpha.19 → 0.0.1-alpha.20
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.
- package/dist/{rpc-858670f1.d.ts → chain-32f56cfa.d.ts} +68 -18
- package/dist/chain-f12cdc7f.d.ts +5 -0
- package/dist/chains.d.ts +757 -170
- package/dist/chains.js +80 -86
- package/dist/chains.js.map +1 -1
- package/dist/chains.mjs +120 -126
- package/dist/chains.mjs.map +1 -1
- package/dist/{chunk-PHSAQQGZ.mjs → chunk-5Q6FSUU2.mjs} +75 -37
- package/dist/chunk-5Q6FSUU2.mjs.map +1 -0
- package/dist/{chunk-24EKKMUO.js → chunk-FHXXG7I6.js} +12 -12
- package/dist/chunk-FHXXG7I6.js.map +1 -0
- package/dist/{chunk-HRE6LYF3.js → chunk-IAQPMSGJ.js} +13 -13
- package/dist/chunk-IAQPMSGJ.js.map +1 -0
- package/dist/{chunk-IVWG22RQ.mjs → chunk-MYQNZSWD.mjs} +69 -12
- package/dist/chunk-MYQNZSWD.mjs.map +1 -0
- package/dist/{chunk-NYMS65YI.js → chunk-NHAKUPTF.js} +124 -67
- package/dist/chunk-NHAKUPTF.js.map +1 -0
- package/dist/{chunk-BZFF747V.js → chunk-SF4I2NKC.js} +81 -43
- package/dist/chunk-SF4I2NKC.js.map +1 -0
- package/dist/{chunk-VAT5CEF7.mjs → chunk-T7CBAKLI.mjs} +2 -2
- package/dist/chunk-T7CBAKLI.mjs.map +1 -0
- package/dist/{chunk-CTU4PQLY.js → chunk-YFKR74XG.js} +14 -14
- package/dist/{chunk-CTU4PQLY.js.map → chunk-YFKR74XG.js.map} +0 -0
- package/dist/{chunk-NSRORL3O.mjs → chunk-YODUQCHJ.mjs} +2 -2
- package/dist/{chunk-NSRORL3O.mjs.map → chunk-YODUQCHJ.mjs.map} +0 -0
- package/dist/{chunk-E7LH5H76.mjs → chunk-ZVGTYLKU.mjs} +2 -2
- package/dist/chunk-ZVGTYLKU.mjs.map +1 -0
- package/dist/clients/index.d.ts +7 -8
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/{transactionReceipt-aed524b4.d.ts → contract-9af4608b.d.ts} +30 -18
- package/dist/{createClient-03ba79e8.d.ts → createClient-5d316c7e.d.ts} +2 -2
- package/dist/{createPublicClient-818241ba.d.ts → createPublicClient-9d2b42e1.d.ts} +3 -3
- package/dist/{createTestClient-24eb7be8.d.ts → createTestClient-79498dab.d.ts} +3 -3
- package/dist/{createWalletClient-7cbd6ad1.d.ts → createWalletClient-f69a5230.d.ts} +3 -3
- package/dist/{eip1193-71d8e27d.d.ts → eip1193-6c485d63.d.ts} +1 -1
- package/dist/index.d.ts +45 -23
- package/dist/index.js +10 -6
- package/dist/index.mjs +9 -5
- package/dist/{parseGwei-dbd12305.d.ts → parseGwei-4308ad80.d.ts} +17 -4
- package/dist/public.d.ts +9 -10
- package/dist/public.js +4 -4
- package/dist/public.mjs +3 -3
- package/dist/{sendTransaction-d09961a7.d.ts → sendTransaction-1c8290a9.d.ts} +3 -4
- package/dist/{stopImpersonatingAccount-c8a00be7.d.ts → stopImpersonatingAccount-7781842a.d.ts} +2 -2
- package/dist/test.d.ts +5 -6
- package/dist/test.js +3 -3
- package/dist/test.mjs +2 -2
- package/dist/transactionRequest-341b6ed2.d.ts +15 -0
- package/dist/utils/index.d.ts +9 -8
- package/dist/utils/index.js +22 -2
- package/dist/utils/index.mjs +25 -5
- package/dist/wallet.d.ts +7 -8
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/dist/{watchAsset-c39645b7.d.ts → watchAsset-afaad3c7.d.ts} +3 -4
- package/dist/{watchPendingTransactions-01e6be4f.d.ts → watchPendingTransactions-3b722547.d.ts} +21 -16
- package/dist/{webSocket-3a00015b.d.ts → webSocket-b180e679.d.ts} +2 -2
- package/dist/window.d.ts +3 -2
- package/package.json +3 -3
- package/src/_test/abis.ts +188 -0
- package/src/_test/constants.ts +0 -3
- package/src/_test/index.ts +5 -2
- package/src/actions/index.test.ts +2 -0
- package/src/actions/index.ts +6 -0
- package/src/actions/public/call.ts +2 -1
- package/src/actions/public/createContractEventFilter.test.ts +119 -0
- package/src/actions/public/createContractEventFilter.ts +69 -0
- package/src/actions/public/createEventFilter.ts +5 -8
- package/src/actions/public/deployContract.ts +1 -2
- package/src/actions/public/getBlock.test.ts +3 -3
- package/src/actions/public/getBlock.ts +1 -2
- package/src/actions/public/getBlockTransactionCount.ts +1 -2
- package/src/actions/public/getFilterChanges.test.ts +9 -7
- package/src/actions/public/getFilterLogs.test.ts +7 -5
- package/src/actions/public/getLogs.test.ts +7 -5
- package/src/actions/public/getLogs.ts +3 -2
- package/src/actions/public/getTransaction.ts +1 -2
- package/src/actions/public/getTransactionConfirmations.ts +1 -2
- package/src/actions/public/getTransactionReceipt.test.ts +24 -62
- package/src/actions/public/getTransactionReceipt.ts +1 -2
- package/src/actions/public/index.test.ts +4 -0
- package/src/actions/public/index.ts +18 -0
- package/src/actions/public/readContract.ts +1 -1
- package/src/actions/public/simulateContract.ts +1 -1
- package/src/actions/public/waitForTransactionReceipt.ts +1 -2
- package/src/actions/public/watchBlocks.test.ts +27 -2
- package/src/actions/public/watchBlocks.ts +33 -14
- package/src/actions/public/watchContractEvent.test.ts +301 -0
- package/src/actions/public/watchContractEvent.ts +108 -0
- package/src/actions/public/watchEvent.test.ts +190 -0
- package/src/actions/public/watchEvent.ts +95 -0
- package/src/actions/public/watchPendingTransactions.ts +1 -0
- package/src/actions/wallet/addChain.ts +1 -1
- package/src/actions/wallet/sendTransaction.ts +2 -1
- package/src/actions/wallet/switchChain.ts +1 -1
- package/src/actions/wallet/writeContract.ts +1 -1
- package/src/chains.test.ts +830 -52
- package/src/chains.ts +90 -158
- package/src/clients/createClient.ts +1 -1
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createTestClient.ts +1 -1
- package/src/clients/createWalletClient.ts +1 -1
- package/src/clients/transports/createTransport.ts +1 -1
- package/src/index.test.ts +2 -0
- package/src/index.ts +10 -2
- package/src/types/chain.ts +6 -0
- package/src/types/contract.ts +17 -2
- package/src/types/formatter.ts +23 -0
- package/src/types/index.ts +6 -0
- package/src/types/transaction.ts +1 -1
- package/src/utils/abi/decodeErrorResult.ts +2 -2
- package/src/utils/abi/decodeFunctionData.ts +2 -2
- package/src/utils/abi/encodeErrorResult.ts +2 -2
- package/src/utils/abi/encodeEventTopics.ts +4 -4
- package/src/utils/abi/encodeFunctionData.ts +2 -2
- package/src/utils/abi/{formatAbiItemWithParams.test.ts → formatAbiItem.test.ts} +11 -11
- package/src/utils/abi/{formatAbiItemWithParams.ts → formatAbiItem.ts} +1 -1
- package/src/utils/abi/index.test.ts +1 -1
- package/src/utils/abi/index.ts +1 -1
- package/src/utils/chain.test.ts +43 -0
- package/src/utils/chain.ts +8 -0
- package/src/utils/contract/getContractError.ts +2 -6
- package/src/utils/formatters/block.ts +4 -3
- package/src/utils/formatters/extract.ts +1 -1
- package/src/utils/formatters/format.ts +39 -2
- package/src/utils/formatters/index.test.ts +10 -0
- package/src/utils/formatters/index.ts +15 -5
- package/src/utils/formatters/transaction.ts +16 -4
- package/src/utils/formatters/transactionReceipt.ts +13 -4
- package/src/utils/formatters/transactionRequest.ts +12 -3
- package/src/utils/hash/getEventSignature.ts +2 -2
- package/src/utils/index.test.ts +24 -1
- package/src/utils/index.ts +12 -1
- package/src/{constants.test.ts → utils/unit/constants.test.ts} +0 -5
- package/src/{constants.ts → utils/unit/constants.ts} +0 -6
- package/src/utils/unit/formatEther.ts +1 -1
- package/src/utils/unit/formatGwei.ts +1 -1
- package/src/utils/unit/index.test.ts +12 -0
- package/src/utils/unit/index.ts +1 -0
- package/src/utils/unit/parseEther.ts +1 -1
- package/src/utils/unit/parseGwei.ts +1 -1
- package/dist/chunk-24EKKMUO.js.map +0 -1
- package/dist/chunk-BZFF747V.js.map +0 -1
- package/dist/chunk-E7LH5H76.mjs.map +0 -1
- package/dist/chunk-HRE6LYF3.js.map +0 -1
- package/dist/chunk-IVWG22RQ.mjs.map +0 -1
- package/dist/chunk-NYMS65YI.js.map +0 -1
- package/dist/chunk-PHSAQQGZ.mjs.map +0 -1
- package/dist/chunk-VAT5CEF7.mjs.map +0 -1
- package/dist/transactionRequest-8e970b0e.d.ts +0 -33
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
2
2
|
|
3
|
-
var
|
3
|
+
var _chunkIAQPMSGJjs = require('./chunk-IAQPMSGJ.js');
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -25,7 +25,8 @@ var _chunkHRE6LYF3js = require('./chunk-HRE6LYF3.js');
|
|
25
25
|
|
26
26
|
|
27
27
|
|
28
|
-
|
28
|
+
|
29
|
+
var _chunkSF4I2NKCjs = require('./chunk-SF4I2NKC.js');
|
29
30
|
|
30
31
|
// src/actions/public/call.ts
|
31
32
|
async function call(client, {
|
@@ -45,10 +46,10 @@ async function call(client, {
|
|
45
46
|
...rest
|
46
47
|
}) {
|
47
48
|
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
48
|
-
throw new (0,
|
49
|
-
const blockNumberHex = blockNumber ?
|
49
|
+
throw new (0, _chunkSF4I2NKCjs.InvalidGasArgumentsError)();
|
50
|
+
const blockNumberHex = blockNumber ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
50
51
|
const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
|
51
|
-
const request_ =
|
52
|
+
const request_ = _chunkSF4I2NKCjs.format.call(void 0,
|
52
53
|
{
|
53
54
|
from,
|
54
55
|
accessList,
|
@@ -60,10 +61,10 @@ async function call(client, {
|
|
60
61
|
nonce,
|
61
62
|
to,
|
62
63
|
value,
|
63
|
-
...
|
64
|
+
..._chunkSF4I2NKCjs.extract.call(void 0, rest, { formatter })
|
64
65
|
},
|
65
66
|
{
|
66
|
-
formatter: formatter ||
|
67
|
+
formatter: formatter || _chunkSF4I2NKCjs.formatTransactionRequest
|
67
68
|
}
|
68
69
|
);
|
69
70
|
const response = await client.request({
|
@@ -83,7 +84,7 @@ async function simulateContract(client, {
|
|
83
84
|
functionName,
|
84
85
|
...callRequest
|
85
86
|
}) {
|
86
|
-
const calldata =
|
87
|
+
const calldata = _chunkSF4I2NKCjs.encodeFunctionData.call(void 0, {
|
87
88
|
abi,
|
88
89
|
args,
|
89
90
|
functionName
|
@@ -94,7 +95,7 @@ async function simulateContract(client, {
|
|
94
95
|
to: address,
|
95
96
|
...callRequest
|
96
97
|
});
|
97
|
-
const result =
|
98
|
+
const result = _chunkSF4I2NKCjs.decodeFunctionResult.call(void 0, {
|
98
99
|
abi,
|
99
100
|
functionName,
|
100
101
|
data: data || "0x"
|
@@ -110,7 +111,7 @@ async function simulateContract(client, {
|
|
110
111
|
}
|
111
112
|
};
|
112
113
|
} catch (err) {
|
113
|
-
throw
|
114
|
+
throw _chunkSF4I2NKCjs.getContractError.call(void 0, err, {
|
114
115
|
abi,
|
115
116
|
address,
|
116
117
|
args,
|
@@ -136,14 +137,75 @@ async function createBlockFilter(client) {
|
|
136
137
|
return { id, type: "block" };
|
137
138
|
}
|
138
139
|
|
140
|
+
// src/actions/public/createEventFilter.ts
|
141
|
+
async function createEventFilter(client, {
|
142
|
+
address,
|
143
|
+
event,
|
144
|
+
args,
|
145
|
+
fromBlock,
|
146
|
+
toBlock
|
147
|
+
} = {}) {
|
148
|
+
let topics = [];
|
149
|
+
if (event) {
|
150
|
+
topics = buildFilterTopics({ event, args });
|
151
|
+
}
|
152
|
+
const id = await client.request({
|
153
|
+
method: "eth_newFilter",
|
154
|
+
params: [
|
155
|
+
{
|
156
|
+
address,
|
157
|
+
fromBlock: typeof fromBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, fromBlock) : fromBlock,
|
158
|
+
toBlock: typeof toBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, toBlock) : toBlock,
|
159
|
+
...topics.length ? { topics } : {}
|
160
|
+
}
|
161
|
+
]
|
162
|
+
});
|
163
|
+
return { id, type: "event" };
|
164
|
+
}
|
165
|
+
function buildFilterTopics({
|
166
|
+
event,
|
167
|
+
args: _args
|
168
|
+
}) {
|
169
|
+
const signature = _chunkSF4I2NKCjs.getEventSignature.call(void 0, event);
|
170
|
+
return [signature];
|
171
|
+
}
|
172
|
+
|
173
|
+
// src/actions/public/createContractEventFilter.ts
|
174
|
+
async function createContractEventFilter(client, {
|
175
|
+
address,
|
176
|
+
abi,
|
177
|
+
args,
|
178
|
+
eventName,
|
179
|
+
fromBlock,
|
180
|
+
toBlock
|
181
|
+
}) {
|
182
|
+
const topics = eventName ? _chunkSF4I2NKCjs.encodeEventTopics.call(void 0, {
|
183
|
+
abi,
|
184
|
+
args,
|
185
|
+
eventName
|
186
|
+
}) : void 0;
|
187
|
+
const id = await client.request({
|
188
|
+
method: "eth_newFilter",
|
189
|
+
params: [
|
190
|
+
{
|
191
|
+
address,
|
192
|
+
fromBlock: typeof fromBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, fromBlock) : fromBlock,
|
193
|
+
toBlock: typeof toBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, toBlock) : toBlock,
|
194
|
+
topics
|
195
|
+
}
|
196
|
+
]
|
197
|
+
});
|
198
|
+
return { id, type: "event" };
|
199
|
+
}
|
200
|
+
|
139
201
|
// src/actions/public/deployContract.ts
|
140
202
|
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
141
|
-
const calldata =
|
203
|
+
const calldata = _chunkSF4I2NKCjs.encodeDeployData.call(void 0, {
|
142
204
|
abi,
|
143
205
|
args,
|
144
206
|
bytecode
|
145
207
|
});
|
146
|
-
return
|
208
|
+
return _chunkIAQPMSGJjs.sendTransaction.call(void 0, walletClient, {
|
147
209
|
...request,
|
148
210
|
data: calldata
|
149
211
|
});
|
@@ -162,16 +224,16 @@ async function estimateGas(client, {
|
|
162
224
|
to,
|
163
225
|
value
|
164
226
|
}) {
|
165
|
-
const blockNumberHex = blockNumber ?
|
227
|
+
const blockNumberHex = blockNumber ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
166
228
|
const parameters = {
|
167
229
|
data,
|
168
230
|
from,
|
169
|
-
gas: gas ?
|
170
|
-
gasPrice: gasPrice ?
|
171
|
-
maxFeePerGas: maxFeePerGas ?
|
172
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas ?
|
231
|
+
gas: gas ? _chunkSF4I2NKCjs.numberToHex.call(void 0, gas) : void 0,
|
232
|
+
gasPrice: gasPrice ? _chunkSF4I2NKCjs.numberToHex.call(void 0, gasPrice) : void 0,
|
233
|
+
maxFeePerGas: maxFeePerGas ? _chunkSF4I2NKCjs.numberToHex.call(void 0, maxFeePerGas) : void 0,
|
234
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas ? _chunkSF4I2NKCjs.numberToHex.call(void 0, maxPriorityFeePerGas) : void 0,
|
173
235
|
to,
|
174
|
-
value: value ?
|
236
|
+
value: value ? _chunkSF4I2NKCjs.numberToHex.call(void 0, value) : void 0
|
175
237
|
};
|
176
238
|
const balance = await client.request({
|
177
239
|
method: "eth_estimateGas",
|
@@ -182,7 +244,7 @@ async function estimateGas(client, {
|
|
182
244
|
|
183
245
|
// src/actions/public/getBalance.ts
|
184
246
|
async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
|
185
|
-
const blockNumberHex = blockNumber ?
|
247
|
+
const blockNumberHex = blockNumber ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
186
248
|
const balance = await client.request({
|
187
249
|
method: "eth_getBalance",
|
188
250
|
params: [address, blockNumberHex || blockTag]
|
@@ -197,7 +259,7 @@ async function getBlock(client, {
|
|
197
259
|
blockTag = "latest",
|
198
260
|
includeTransactions = false
|
199
261
|
} = {}) {
|
200
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
262
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
201
263
|
let block = null;
|
202
264
|
if (blockHash) {
|
203
265
|
block = await client.request({
|
@@ -211,19 +273,19 @@ async function getBlock(client, {
|
|
211
273
|
});
|
212
274
|
}
|
213
275
|
if (!block)
|
214
|
-
throw new (0,
|
215
|
-
return
|
216
|
-
formatter: _optionalChain([client, 'access', _3 => _3.chain, 'optionalAccess', _4 => _4.formatters, 'optionalAccess', _5 => _5.block]) ||
|
276
|
+
throw new (0, _chunkSF4I2NKCjs.BlockNotFoundError)({ blockHash, blockNumber });
|
277
|
+
return _chunkSF4I2NKCjs.format.call(void 0, block, {
|
278
|
+
formatter: _optionalChain([client, 'access', _3 => _3.chain, 'optionalAccess', _4 => _4.formatters, 'optionalAccess', _5 => _5.block]) || _chunkSF4I2NKCjs.formatBlock
|
217
279
|
});
|
218
280
|
}
|
219
281
|
|
220
282
|
// src/actions/public/getBlockNumber.ts
|
221
283
|
var cacheKey = (id) => `blockNumber.${id}`;
|
222
284
|
function getBlockNumberCache(id) {
|
223
|
-
return
|
285
|
+
return _chunkSF4I2NKCjs.getCache.call(void 0, cacheKey(id));
|
224
286
|
}
|
225
287
|
async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
|
226
|
-
const blockNumberHex = await
|
288
|
+
const blockNumberHex = await _chunkSF4I2NKCjs.withCache.call(void 0,
|
227
289
|
() => client.request({
|
228
290
|
method: "eth_blockNumber"
|
229
291
|
}),
|
@@ -238,7 +300,7 @@ async function getBlockTransactionCount(client, {
|
|
238
300
|
blockNumber,
|
239
301
|
blockTag = "latest"
|
240
302
|
} = {}) {
|
241
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
303
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
242
304
|
let count = null;
|
243
305
|
if (blockHash) {
|
244
306
|
count = await client.request({
|
@@ -251,12 +313,12 @@ async function getBlockTransactionCount(client, {
|
|
251
313
|
params: [blockNumberHex || blockTag]
|
252
314
|
});
|
253
315
|
}
|
254
|
-
return
|
316
|
+
return _chunkSF4I2NKCjs.hexToNumber.call(void 0, count);
|
255
317
|
}
|
256
318
|
|
257
319
|
// src/actions/public/getBytecode.ts
|
258
320
|
async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
|
259
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
321
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
260
322
|
const hex = await client.request({
|
261
323
|
method: "eth_getCode",
|
262
324
|
params: [address, blockNumberHex || blockTag]
|
@@ -269,7 +331,7 @@ async function getBytecode(client, { address, blockNumber, blockTag = "latest" }
|
|
269
331
|
// src/actions/public/getChainId.ts
|
270
332
|
async function getChainId(client) {
|
271
333
|
const chainIdHex = await client.request({ method: "eth_chainId" });
|
272
|
-
return
|
334
|
+
return _chunkSF4I2NKCjs.hexToNumber.call(void 0, chainIdHex);
|
273
335
|
}
|
274
336
|
|
275
337
|
// src/actions/public/getFeeHistory.ts
|
@@ -279,16 +341,16 @@ async function getFeeHistory(client, {
|
|
279
341
|
blockTag = "latest",
|
280
342
|
rewardPercentiles
|
281
343
|
}) {
|
282
|
-
const blockNumberHex = blockNumber ?
|
344
|
+
const blockNumberHex = blockNumber ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
283
345
|
const feeHistory = await client.request({
|
284
346
|
method: "eth_feeHistory",
|
285
347
|
params: [
|
286
|
-
|
348
|
+
_chunkSF4I2NKCjs.numberToHex.call(void 0, blockCount),
|
287
349
|
blockNumberHex || blockTag,
|
288
350
|
rewardPercentiles
|
289
351
|
]
|
290
352
|
});
|
291
|
-
return
|
353
|
+
return _chunkSF4I2NKCjs.formatFeeHistory.call(void 0, feeHistory);
|
292
354
|
}
|
293
355
|
|
294
356
|
// src/actions/public/getFilterChanges.ts
|
@@ -298,7 +360,7 @@ async function getFilterChanges(client, { filter }) {
|
|
298
360
|
params: [filter.id]
|
299
361
|
});
|
300
362
|
return logs.map(
|
301
|
-
(log) => typeof log === "string" ? log :
|
363
|
+
(log) => typeof log === "string" ? log : _chunkSF4I2NKCjs.formatLog.call(void 0, log)
|
302
364
|
);
|
303
365
|
}
|
304
366
|
|
@@ -308,7 +370,7 @@ async function getFilterLogs(client, { filter }) {
|
|
308
370
|
method: "eth_getFilterLogs",
|
309
371
|
params: [filter.id]
|
310
372
|
});
|
311
|
-
return logs.map(
|
373
|
+
return logs.map(_chunkSF4I2NKCjs.formatLog);
|
312
374
|
}
|
313
375
|
|
314
376
|
// src/actions/public/getGasPrice.ts
|
@@ -319,15 +381,6 @@ async function getGasPrice(client) {
|
|
319
381
|
return BigInt(gasPrice);
|
320
382
|
}
|
321
383
|
|
322
|
-
// src/actions/public/createEventFilter.ts
|
323
|
-
function buildFilterTopics({
|
324
|
-
event,
|
325
|
-
args: _args
|
326
|
-
}) {
|
327
|
-
const signature = _chunkBZFF747Vjs.getEventSignature.call(void 0, event);
|
328
|
-
return [signature];
|
329
|
-
}
|
330
|
-
|
331
384
|
// src/actions/public/getLogs.ts
|
332
385
|
async function getLogs(client, {
|
333
386
|
address,
|
@@ -354,18 +407,18 @@ async function getLogs(client, {
|
|
354
407
|
{
|
355
408
|
address,
|
356
409
|
topics,
|
357
|
-
fromBlock: typeof fromBlock === "bigint" ?
|
358
|
-
toBlock: typeof toBlock === "bigint" ?
|
410
|
+
fromBlock: typeof fromBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, fromBlock) : fromBlock,
|
411
|
+
toBlock: typeof toBlock === "bigint" ? _chunkSF4I2NKCjs.numberToHex.call(void 0, toBlock) : toBlock
|
359
412
|
}
|
360
413
|
]
|
361
414
|
});
|
362
415
|
}
|
363
|
-
return logs.map(
|
416
|
+
return logs.map(_chunkSF4I2NKCjs.formatLog);
|
364
417
|
}
|
365
418
|
|
366
419
|
// src/actions/public/getStorageAt.ts
|
367
420
|
async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
|
368
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
421
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
369
422
|
const data = await client.request({
|
370
423
|
method: "eth_getStorageAt",
|
371
424
|
params: [address, slot, blockNumberHex || blockTag]
|
@@ -381,7 +434,7 @@ async function getTransaction(client, {
|
|
381
434
|
hash,
|
382
435
|
index
|
383
436
|
}) {
|
384
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
437
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : void 0;
|
385
438
|
let transaction = null;
|
386
439
|
if (hash) {
|
387
440
|
transaction = await client.request({
|
@@ -391,24 +444,24 @@ async function getTransaction(client, {
|
|
391
444
|
} else if (blockHash) {
|
392
445
|
transaction = await client.request({
|
393
446
|
method: "eth_getTransactionByBlockHashAndIndex",
|
394
|
-
params: [blockHash,
|
447
|
+
params: [blockHash, _chunkSF4I2NKCjs.numberToHex.call(void 0, index)]
|
395
448
|
});
|
396
449
|
} else if (blockNumberHex || blockTag) {
|
397
450
|
transaction = await client.request({
|
398
451
|
method: "eth_getTransactionByBlockNumberAndIndex",
|
399
|
-
params: [blockNumberHex || blockTag,
|
452
|
+
params: [blockNumberHex || blockTag, _chunkSF4I2NKCjs.numberToHex.call(void 0, index)]
|
400
453
|
});
|
401
454
|
}
|
402
455
|
if (!transaction)
|
403
|
-
throw new (0,
|
456
|
+
throw new (0, _chunkSF4I2NKCjs.TransactionNotFoundError)({
|
404
457
|
blockHash,
|
405
458
|
blockNumber,
|
406
459
|
blockTag,
|
407
460
|
hash,
|
408
461
|
index
|
409
462
|
});
|
410
|
-
return
|
411
|
-
formatter: _optionalChain([client, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.formatters, 'optionalAccess', _8 => _8.transaction]) ||
|
463
|
+
return _chunkSF4I2NKCjs.format.call(void 0, transaction, {
|
464
|
+
formatter: _optionalChain([client, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.formatters, 'optionalAccess', _8 => _8.transaction]) || _chunkSF4I2NKCjs.formatTransaction
|
412
465
|
});
|
413
466
|
}
|
414
467
|
|
@@ -428,9 +481,9 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
|
|
428
481
|
async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
|
429
482
|
const count = await client.request({
|
430
483
|
method: "eth_getTransactionCount",
|
431
|
-
params: [address, blockNumber ?
|
484
|
+
params: [address, blockNumber ? _chunkSF4I2NKCjs.numberToHex.call(void 0, blockNumber) : blockTag]
|
432
485
|
});
|
433
|
-
return
|
486
|
+
return _chunkSF4I2NKCjs.hexToNumber.call(void 0, count);
|
434
487
|
}
|
435
488
|
|
436
489
|
// src/actions/public/getTransactionReceipt.ts
|
@@ -440,9 +493,9 @@ async function getTransactionReceipt(client, { hash }) {
|
|
440
493
|
params: [hash]
|
441
494
|
});
|
442
495
|
if (!receipt)
|
443
|
-
throw new (0,
|
444
|
-
return
|
445
|
-
formatter: _optionalChain([client, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.formatters, 'optionalAccess', _13 => _13.transactionReceipt]) ||
|
496
|
+
throw new (0, _chunkSF4I2NKCjs.TransactionReceiptNotFoundError)({ hash });
|
497
|
+
return _chunkSF4I2NKCjs.format.call(void 0, receipt, {
|
498
|
+
formatter: _optionalChain([client, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.formatters, 'optionalAccess', _13 => _13.transactionReceipt]) || _chunkSF4I2NKCjs.formatTransactionReceipt
|
446
499
|
});
|
447
500
|
}
|
448
501
|
|
@@ -454,7 +507,7 @@ async function readContract(client, {
|
|
454
507
|
functionName,
|
455
508
|
...callRequest
|
456
509
|
}) {
|
457
|
-
const calldata =
|
510
|
+
const calldata = _chunkSF4I2NKCjs.encodeFunctionData.call(void 0, {
|
458
511
|
abi,
|
459
512
|
args,
|
460
513
|
functionName
|
@@ -465,13 +518,13 @@ async function readContract(client, {
|
|
465
518
|
to: address,
|
466
519
|
...callRequest
|
467
520
|
});
|
468
|
-
return
|
521
|
+
return _chunkSF4I2NKCjs.decodeFunctionResult.call(void 0, {
|
469
522
|
abi,
|
470
523
|
functionName,
|
471
524
|
data: data || "0x"
|
472
525
|
});
|
473
526
|
} catch (err) {
|
474
|
-
throw
|
527
|
+
throw _chunkSF4I2NKCjs.getContractError.call(void 0, err, {
|
475
528
|
abi,
|
476
529
|
address,
|
477
530
|
args,
|
@@ -539,12 +592,12 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
539
592
|
if (emitOnBegin)
|
540
593
|
data = await fn({ unpoll: unwatch });
|
541
594
|
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _17 => _17(data)]), async () => ( interval));
|
542
|
-
await
|
595
|
+
await _chunkSF4I2NKCjs.wait.call(void 0, initialWait);
|
543
596
|
const poll2 = async () => {
|
544
597
|
if (!active)
|
545
598
|
return;
|
546
599
|
await fn({ unpoll: unwatch });
|
547
|
-
await
|
600
|
+
await _chunkSF4I2NKCjs.wait.call(void 0, interval);
|
548
601
|
poll2();
|
549
602
|
};
|
550
603
|
poll2();
|
@@ -685,6 +738,8 @@ function watchPendingTransactions(client, {
|
|
685
738
|
}
|
686
739
|
}
|
687
740
|
const hashes = await getFilterChanges(client, { filter });
|
741
|
+
if (hashes.length === 0)
|
742
|
+
return;
|
688
743
|
if (batch)
|
689
744
|
emit.onTransactions(hashes);
|
690
745
|
else
|
@@ -725,7 +780,7 @@ async function waitForTransactionReceipt(client, {
|
|
725
780
|
return new Promise((resolve, reject) => {
|
726
781
|
if (timeout)
|
727
782
|
setTimeout(
|
728
|
-
() => reject(new (0,
|
783
|
+
() => reject(new (0, _chunkSF4I2NKCjs.WaitForTransactionReceiptTimeoutError)({ hash })),
|
729
784
|
timeout
|
730
785
|
);
|
731
786
|
const unobserve = observe(
|
@@ -755,7 +810,7 @@ async function waitForTransactionReceipt(client, {
|
|
755
810
|
return;
|
756
811
|
done(() => emit.resolve(receipt));
|
757
812
|
} catch (err) {
|
758
|
-
if (transaction && (err instanceof
|
813
|
+
if (transaction && (err instanceof _chunkSF4I2NKCjs.TransactionNotFoundError || err instanceof _chunkSF4I2NKCjs.TransactionReceiptNotFoundError)) {
|
759
814
|
replacedTransaction = transaction;
|
760
815
|
const block = await getBlock(client, {
|
761
816
|
blockNumber,
|
@@ -828,5 +883,7 @@ async function waitForTransactionReceipt(client, {
|
|
828
883
|
|
829
884
|
|
830
885
|
|
831
|
-
|
832
|
-
|
886
|
+
|
887
|
+
|
888
|
+
exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.deployContract = deployContract; exports.estimateGas = estimateGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchPendingTransactions = watchPendingTransactions;
|
889
|
+
//# sourceMappingURL=chunk-NHAKUPTF.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/actions/public/call.ts","../src/actions/public/simulateContract.ts","../src/actions/public/createPendingTransactionFilter.ts","../src/actions/public/createBlockFilter.ts","../src/actions/public/createEventFilter.ts","../src/actions/public/createContractEventFilter.ts","../src/actions/public/deployContract.ts","../src/actions/public/estimateGas.ts","../src/actions/public/getBalance.ts","../src/actions/public/getBlock.ts","../src/actions/public/getBlockNumber.ts","../src/actions/public/getBlockTransactionCount.ts","../src/actions/public/getBytecode.ts","../src/actions/public/getChainId.ts","../src/actions/public/getFeeHistory.ts","../src/actions/public/getFilterChanges.ts","../src/actions/public/getFilterLogs.ts","../src/actions/public/getGasPrice.ts","../src/actions/public/getLogs.ts","../src/actions/public/getStorageAt.ts","../src/actions/public/getTransaction.ts","../src/actions/public/getTransactionConfirmations.ts","../src/actions/public/getTransactionCount.ts","../src/actions/public/getTransactionReceipt.ts","../src/actions/public/readContract.ts","../src/actions/public/uninstallFilter.ts","../src/utils/observe.ts","../src/utils/poll.ts","../src/actions/public/watchBlockNumber.ts","../src/actions/public/watchBlocks.ts","../src/actions/public/watchPendingTransactions.ts","../src/actions/public/waitForTransactionReceipt.ts"],"names":["listeners","cleanup","poll","block"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,eAAsB,KACpB,QACA;AAAA,EACE;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AC;AAAA,cACH,OAAO;AACL,qBAAK,MAAM,KAAK,OAAO,GAAG,CAAC;AAAA,cAC7B;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,CAAC;AACH","sourcesContent":["import type { PublicClient } from '../../clients'\nimport { InvalidGasArgumentsError } from '../../errors'\nimport type {\n Address,\n BlockTag,\n Chain,\n Formatter,\n Hex,\n MergeIntersectionProperties,\n TransactionRequest,\n} from '../../types'\nimport { extract, Formatted, TransactionRequestFormatter } from '../../utils'\nimport { format, formatTransactionRequest, numberToHex } from '../../utils'\n\nexport type FormattedCall<\n TFormatter extends Formatter | undefined = Formatter,\n> = MergeIntersectionProperties<\n Formatted<TFormatter, TransactionRequest, true>,\n TransactionRequest\n>\n\nexport type CallArgs<TChain extends Chain = Chain> = FormattedCall<\n TransactionRequestFormatter<TChain>\n> & {\n chain?: TChain\n from?: Address\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockNumber?: never\n /** The balance of the account at a block tag. */\n blockTag?: BlockTag\n }\n )\n\nexport type CallResponse = { data: Hex | undefined }\n\nexport async function call<TChain extends Chain>(\n client: PublicClient,\n {\n blockNumber,\n blockTag = 'latest',\n chain,\n from,\n accessList,\n data,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n ...rest\n }: CallArgs<TChain>,\n): Promise<CallResponse> {\n if (\n maxFeePerGas !== undefined &&\n maxPriorityFeePerGas !== undefined &&\n maxFeePerGas < maxPriorityFeePerGas\n )\n throw new InvalidGasArgumentsError()\n\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n\n const formatter = chain?.formatters?.transactionRequest\n const request_ = format(\n {\n from,\n accessList,\n data,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n // Pick out extra data that might exist on the chain's transaction request type.\n ...extract(rest, { formatter }),\n } as TransactionRequest,\n {\n formatter: formatter || formatTransactionRequest,\n },\n )\n\n const response = await client.request({\n method: 'eth_call',\n params: [request_, blockNumberHex || blockTag],\n })\n if (response === '0x') return { data: undefined }\n return { data: response }\n}\n","import { Abi } from 'abitype'\n\nimport type { PublicClient } from '../../clients'\nimport type {\n Address,\n Chain,\n ExtractArgsFromAbi,\n ExtractResultFromAbi,\n ExtractFunctionNameFromAbi,\n GetValue,\n} from '../../types'\nimport {\n EncodeFunctionDataArgs,\n decodeFunctionResult,\n encodeFunctionData,\n getContractError,\n} from '../../utils'\nimport { WriteContractArgs } from '../wallet'\nimport { call, CallArgs } from './call'\n\nexport type SimulateContractArgs<\n TChain extends Chain = Chain,\n TAbi extends Abi | readonly unknown[] = Abi,\n TFunctionName extends string = any,\n> = Omit<CallArgs<TChain>, 'to' | 'data' | 'value'> & {\n address: Address\n abi: TAbi\n functionName: ExtractFunctionNameFromAbi<\n TAbi,\n TFunctionName,\n 'payable' | 'nonpayable'\n >\n value?: GetValue<TAbi, TFunctionName, CallArgs<TChain>['value']>\n} & ExtractArgsFromAbi<TAbi, TFunctionName>\n\nexport type SimulateContractResponse<\n TChain extends Chain = Chain,\n TAbi extends Abi | readonly unknown[] = Abi,\n TFunctionName extends string = string,\n> = {\n result: ExtractResultFromAbi<TAbi, TFunctionName>\n request: WriteContractArgs<TChain, TAbi, TFunctionName> & {\n address: Address\n abi: TAbi\n functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>\n } & ExtractArgsFromAbi<TAbi, TFunctionName>\n}\n\nexport async function simulateContract<\n TChain extends Chain,\n TAbi extends Abi = Abi,\n TFunctionName extends string = any,\n>(\n client: PublicClient,\n {\n abi,\n address,\n args,\n functionName,\n ...callRequest\n }: SimulateContractArgs<TChain, TAbi, TFunctionName>,\n): Promise<SimulateContractResponse<TChain, TAbi, TFunctionName>> {\n const calldata = encodeFunctionData({\n abi,\n args,\n functionName,\n } as unknown as EncodeFunctionDataArgs<TAbi, TFunctionName>)\n try {\n const { data } = await call(client, {\n data: calldata,\n to: address,\n ...callRequest,\n } as unknown as CallArgs<TChain>)\n const result = decodeFunctionResult({\n abi,\n functionName,\n data: data || '0x',\n })\n return {\n result,\n request: {\n abi,\n address,\n args,\n functionName,\n ...callRequest,\n },\n } as unknown as SimulateContractResponse<TChain, TAbi, TFunctionName>\n } catch (err) {\n throw getContractError(err, {\n abi,\n address,\n args,\n functionName,\n sender: callRequest.from,\n })\n }\n}\n","import type { PublicClient } from '../../clients'\n\nimport type { Filter } from '../../types'\n\nexport type CreatePendingTransactionFilterResponse = Filter<'transaction'>\n\nexport async function createPendingTransactionFilter(\n client: PublicClient,\n): Promise<CreatePendingTransactionFilterResponse> {\n const id = await client.request({\n method: 'eth_newPendingTransactionFilter',\n })\n return { id, type: 'transaction' }\n}\n","import type { PublicClient } from '../../clients'\n\nimport type { Filter } from '../../types'\n\nexport type CreateBlockFilterResponse = Filter<'block'>\n\nexport async function createBlockFilter(\n client: PublicClient,\n): Promise<CreateBlockFilterResponse> {\n const id = await client.request({\n method: 'eth_newBlockFilter',\n })\n return { id, type: 'block' }\n}\n","import type { PublicClient } from '../../clients'\n\nimport type {\n Address,\n BlockNumber,\n BlockTag,\n EventDefinition,\n ExtractArgsFromEventDefinition,\n Filter,\n LogTopic,\n} from '../../types'\nimport { getEventSignature, numberToHex } from '../../utils'\n\nexport type EventFilterArgs<TEventDefinition extends EventDefinition> =\n ExtractArgsFromEventDefinition<TEventDefinition>\n\nexport type CreateEventFilterArgs<TEventDefinition extends EventDefinition> = {\n address?: Address | Address[]\n fromBlock?: BlockNumber | BlockTag\n toBlock?: BlockNumber | BlockTag\n} & (\n | {\n event: TEventDefinition\n args?: EventFilterArgs<TEventDefinition>\n }\n | {\n event?: never\n args?: never\n }\n)\nexport type CreateEventFilterResponse = Filter<'event'>\n\nexport async function createEventFilter<\n TEventDefinition extends EventDefinition,\n>(\n client: PublicClient,\n {\n address,\n event,\n args,\n fromBlock,\n toBlock,\n }: CreateEventFilterArgs<TEventDefinition> = {},\n): Promise<CreateEventFilterResponse> {\n let topics: LogTopic[] = []\n if (event) {\n topics = buildFilterTopics({ event, args })\n }\n const id = await client.request({\n method: 'eth_newFilter',\n params: [\n {\n address,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n ...(topics.length ? { topics } : {}),\n },\n ],\n })\n return { id, type: 'event' }\n}\n\nexport function buildFilterTopics<TEventDefinition extends EventDefinition,>({\n event,\n args: _args,\n}: {\n event: TEventDefinition\n args?: EventFilterArgs<TEventDefinition>\n}) {\n const signature = getEventSignature(event)\n\n // TODO: support args\n\n return [signature]\n}\n","import { Abi } from 'abitype'\nimport type { PublicClient } from '../../clients'\n\nimport type {\n Address,\n BlockNumber,\n BlockTag,\n EventDefinition,\n ExtractArgsFromEventDefinition,\n ExtractEventArgsFromAbi,\n ExtractEventNameFromAbi,\n Filter,\n} from '../../types'\nimport {\n encodeEventTopics,\n EncodeEventTopicsArgs,\n numberToHex,\n} from '../../utils'\n\nexport type EventFilterArgs<TEventDefinition extends EventDefinition> =\n ExtractArgsFromEventDefinition<TEventDefinition>\n\nexport type CreateContractEventFilterArgs<\n TAbi extends Abi | readonly unknown[] = Abi,\n TEventName extends string = any,\n> = {\n address?: Address | Address[]\n abi: TAbi\n eventName: ExtractEventNameFromAbi<TAbi, TEventName>\n fromBlock?: BlockNumber | BlockTag\n toBlock?: BlockNumber | BlockTag\n} & ExtractEventArgsFromAbi<TAbi, TEventName>\nexport type CreateContractEventFilterResponse = Filter<'event'>\n\nexport async function createContractEventFilter<\n TAbi extends Abi | readonly unknown[] = Abi,\n TEventName extends string = any,\n>(\n client: PublicClient,\n {\n address,\n abi,\n args,\n eventName,\n fromBlock,\n toBlock,\n }: CreateContractEventFilterArgs<TAbi, TEventName>,\n): Promise<CreateContractEventFilterResponse> {\n const topics = eventName\n ? encodeEventTopics({\n abi,\n args,\n eventName,\n } as unknown as EncodeEventTopicsArgs)\n : undefined\n const id = await client.request({\n method: 'eth_newFilter',\n params: [\n {\n address,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n topics,\n },\n ],\n })\n return { id, type: 'event' }\n}\n","import { Abi } from 'abitype'\nimport { WalletClient } from '../../clients'\n\nimport { Chain, ExtractConstructorArgsFromAbi, Hex } from '../../types'\nimport { encodeDeployData } from '../../utils'\nimport {\n sendTransaction,\n SendTransactionArgs,\n SendTransactionResponse,\n} from '../wallet'\n\nexport type DeployContractArgs<\n TChain extends Chain = Chain,\n TAbi extends Abi = Abi,\n> = Omit<\n SendTransactionArgs<TChain>,\n 'accessList' | 'to' | 'data' | 'value'\n> & {\n abi: TAbi\n bytecode: Hex\n} & ExtractConstructorArgsFromAbi<TAbi>\n\nexport type DeployContractResponse = SendTransactionResponse\n\nexport function deployContract<TChain extends Chain, TAbi extends Abi = Abi>(\n walletClient: WalletClient,\n { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>,\n): Promise<DeployContractResponse> {\n const calldata = encodeDeployData({\n abi,\n args,\n bytecode,\n } as unknown as DeployContractArgs<TChain, TAbi>)\n return sendTransaction(walletClient, {\n ...request,\n data: calldata,\n } as unknown as SendTransactionArgs<TChain>)\n}\n","import type { PublicClient } from '../../clients'\nimport type {\n BlockTag,\n EstimateGasParameters,\n RpcEstimateGasParameters,\n} from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport type EstimateGasArgs = EstimateGasParameters &\n (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockNumber?: never\n /** The balance of the account at a block tag. */\n blockTag?: BlockTag\n }\n )\n\nexport type EstimateGasResponse = bigint\n\n/**\n * @description Estimates the gas necessary to complete a transaction without submitting it to the network.\n */\nexport async function estimateGas(\n client: PublicClient,\n {\n blockNumber,\n blockTag = 'latest',\n data,\n from,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n to,\n value,\n }: EstimateGasArgs,\n): Promise<EstimateGasResponse> {\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const parameters = {\n data,\n from,\n gas: gas ? numberToHex(gas) : undefined,\n gasPrice: gasPrice ? numberToHex(gasPrice) : undefined,\n maxFeePerGas: maxFeePerGas ? numberToHex(maxFeePerGas) : undefined,\n maxPriorityFeePerGas: maxPriorityFeePerGas\n ? numberToHex(maxPriorityFeePerGas)\n : undefined,\n to,\n value: value ? numberToHex(value) : undefined,\n } as RpcEstimateGasParameters\n const balance = await client.request({\n method: 'eth_estimateGas',\n params: [parameters, blockNumberHex || blockTag],\n })\n return BigInt(balance)\n}\n","import type { PublicClient } from '../../clients'\nimport type { Address, BlockTag } from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport type GetBalanceArgs = {\n /** The address of the account. */\n address: Address\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockNumber?: never\n /** The balance of the account at a block tag. */\n blockTag?: BlockTag\n }\n)\n\nexport type GetBalanceResponse = bigint\n\n/**\n * @description Returns the balance of an address in wei.\n */\nexport async function getBalance(\n client: PublicClient,\n { address, blockNumber, blockTag = 'latest' }: GetBalanceArgs,\n): Promise<GetBalanceResponse> {\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n\n const balance = await client.request({\n method: 'eth_getBalance',\n params: [address, blockNumberHex || blockTag],\n })\n return BigInt(balance)\n}\n","import type { PublicClient } from '../../clients'\nimport { BlockNotFoundError } from '../../errors'\nimport type { BlockTag, Chain, Hash, RpcBlock } from '../../types'\nimport type { BlockFormatter, FormattedBlock } from '../../utils'\nimport { format, formatBlock, numberToHex } from '../../utils'\n\nexport type GetBlockArgs = {\n /** Whether or not to include transaction data in the response. */\n includeTransactions?: boolean\n} & (\n | {\n /** Hash of the block. */\n blockHash?: Hash\n blockNumber?: never\n blockTag?: never\n }\n | {\n blockHash?: never\n /** The block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockHash?: never\n blockNumber?: never\n /** The block tag. Defaults to 'latest'. */\n blockTag?: BlockTag\n }\n)\n\nexport type GetBlockResponse<TChain extends Chain = Chain> = FormattedBlock<\n BlockFormatter<TChain>\n>\n\nexport async function getBlock<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n {\n blockHash,\n blockNumber,\n blockTag = 'latest',\n includeTransactions = false,\n }: GetBlockArgs = {},\n): Promise<GetBlockResponse<TChain>> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let block: RpcBlock | null = null\n if (blockHash) {\n block = await client.request({\n method: 'eth_getBlockByHash',\n params: [blockHash, includeTransactions],\n })\n } else {\n block = await client.request({\n method: 'eth_getBlockByNumber',\n params: [blockNumberHex || blockTag, includeTransactions],\n })\n }\n\n if (!block) throw new BlockNotFoundError({ blockHash, blockNumber })\n\n return format(block, {\n formatter: client.chain?.formatters?.block || formatBlock,\n })\n}\n","import type { PublicClient } from '../../clients'\nimport { getCache, withCache } from '../../utils/promise'\n\nexport type GetBlockNumberArgs = {\n /** The maximum age (in ms) of the cached value. */\n maxAge?: number\n}\n\nexport type GetBlockNumberResponse = bigint\n\nconst cacheKey = (id: string) => `blockNumber.${id}`\n\nexport function getBlockNumberCache(id: string) {\n return getCache(cacheKey(id))\n}\n\n/**\n * @description Returns the number of the most recent block seen.\n */\nexport async function getBlockNumber(\n client: PublicClient,\n { maxAge = client.pollingInterval }: GetBlockNumberArgs = {},\n): Promise<GetBlockNumberResponse> {\n const blockNumberHex = await withCache(\n () =>\n client.request({\n method: 'eth_blockNumber',\n }),\n { cacheKey: cacheKey(client.uid), maxAge },\n )\n return BigInt(blockNumberHex)\n}\n","import type { PublicClient } from '../../clients'\nimport type { BlockTag, Chain, Hash, Quantity } from '../../types'\nimport { hexToNumber, numberToHex } from '../../utils'\n\nexport type GetBlockTransactionCountArgs =\n | {\n /** Hash of the block. */\n blockHash?: Hash\n blockNumber?: never\n blockTag?: never\n }\n | {\n blockHash?: never\n /** The block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockHash?: never\n blockNumber?: never\n /** The block tag. Defaults to 'latest'. */\n blockTag?: BlockTag\n }\n\nexport type GetBlockTransactionCountResponse = number\n\nexport async function getBlockTransactionCount<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n {\n blockHash,\n blockNumber,\n blockTag = 'latest',\n }: GetBlockTransactionCountArgs = {},\n): Promise<GetBlockTransactionCountResponse> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let count: Quantity | null = null\n if (blockHash) {\n count = await client.request({\n method: 'eth_getBlockTransactionCountByHash',\n params: [blockHash],\n })\n } else {\n count = await client.request({\n method: 'eth_getBlockTransactionCountByNumber',\n params: [blockNumberHex || blockTag],\n })\n }\n\n return hexToNumber(count)\n}\n","import { PublicClient } from '../../clients'\nimport { Address, BlockTag, Hex } from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport type GetBytecodeArgs = {\n address: Address\n} & (\n | {\n blockNumber?: never\n blockTag?: BlockTag\n }\n | {\n blockNumber?: bigint\n blockTag?: never\n }\n)\n\nexport type GetBytecodeResponse = Hex | undefined\n\nexport async function getBytecode(\n client: PublicClient,\n { address, blockNumber, blockTag = 'latest' }: GetBytecodeArgs,\n): Promise<GetBytecodeResponse> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n const hex = await client.request({\n method: 'eth_getCode',\n params: [address, blockNumberHex || blockTag],\n })\n if (hex === '0x') return undefined\n return hex\n}\n","import type { PublicClient } from '../../clients'\nimport { hexToNumber } from '../../utils'\n\nexport async function getChainId(client: PublicClient) {\n const chainIdHex = await client.request({ method: 'eth_chainId' })\n return hexToNumber(chainIdHex)\n}\n","import type { PublicClient } from '../../clients'\nimport type { BlockTag, FeeHistory } from '../../types'\n\nimport { numberToHex } from '../../utils'\nimport { formatFeeHistory } from '../../utils/formatters'\n\nexport type GetFeeHistoryArgs = {\n blockCount: number\n rewardPercentiles: number[]\n} & (\n | {\n blockNumber?: never\n blockTag?: BlockTag\n }\n | {\n blockNumber?: bigint\n blockTag?: never\n }\n)\nexport type GetFeeHistoryResponse = FeeHistory\n\n/**\n * @description Returns a collection of historical gas information.\n */\nexport async function getFeeHistory(\n client: PublicClient,\n {\n blockCount,\n blockNumber,\n blockTag = 'latest',\n rewardPercentiles,\n }: GetFeeHistoryArgs,\n): Promise<GetFeeHistoryResponse> {\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const feeHistory = await client.request({\n method: 'eth_feeHistory',\n params: [\n numberToHex(blockCount),\n blockNumberHex || blockTag,\n rewardPercentiles,\n ],\n })\n return formatFeeHistory(feeHistory)\n}\n","import type { PublicClient } from '../../clients'\nimport type { Filter, FilterType, Hash, Log } from '../../types'\n\nimport { formatLog } from '../../utils/formatters/log'\n\nexport type GetFilterChangesArgs<TFilterType extends FilterType> = {\n filter: Filter<TFilterType>\n}\nexport type GetFilterChangesResponse<TFilterType extends FilterType> =\n TFilterType extends 'event' ? Log[] : Hash[]\n\nexport async function getFilterChanges<TFilterType extends FilterType>(\n client: PublicClient,\n { filter }: GetFilterChangesArgs<TFilterType>,\n) {\n const logs = await client.request({\n method: 'eth_getFilterChanges',\n params: [filter.id],\n })\n return logs.map((log) =>\n typeof log === 'string' ? log : formatLog(log),\n ) as GetFilterChangesResponse<TFilterType>\n}\n","import type { PublicClient } from '../../clients'\nimport type { Filter, FilterType, Hash, Log } from '../../types'\n\nimport { formatLog } from '../../utils/formatters/log'\n\nexport type GetFilterLogsArgs = {\n filter: Filter<'event'>\n}\nexport type GetFilterLogsResponse = Log[]\n\nexport async function getFilterLogs<TFilterType extends FilterType>(\n client: PublicClient,\n { filter }: GetFilterLogsArgs,\n): Promise<GetFilterLogsResponse> {\n const logs = await client.request({\n method: 'eth_getFilterLogs',\n params: [filter.id],\n })\n return logs.map(formatLog)\n}\n","import type { PublicClient } from '../../clients'\n\nexport type GetGasPriceResponse = bigint\n\n/**\n * @description Returns the current price of gas (in wei).\n */\nexport async function getGasPrice(\n client: PublicClient,\n): Promise<GetGasPriceResponse> {\n const gasPrice = await client.request({\n method: 'eth_gasPrice',\n })\n return BigInt(gasPrice)\n}\n","import type { PublicClient } from '../../clients'\nimport type {\n Log,\n RpcLog,\n Address,\n BlockNumber,\n BlockTag,\n EventDefinition,\n Hash,\n LogTopic,\n} from '../../types'\nimport { numberToHex } from '../../utils'\nimport { formatLog } from '../../utils/formatters/log'\nimport { buildFilterTopics, EventFilterArgs } from './createEventFilter'\n\nexport type GetLogsArgs<TEventDefinition extends EventDefinition> = {\n /** Address or list of addresses from which logs originated */\n address?: Address | Address[]\n} & (\n | { event: TEventDefinition; args?: EventFilterArgs<TEventDefinition> }\n | {\n event?: never\n args?: never\n }\n) &\n (\n | {\n /** Block number or tag after which to include logs */\n fromBlock?: BlockNumber<bigint> | BlockTag\n /** Block number or tag before which to include logs */\n toBlock?: BlockNumber<bigint> | BlockTag\n blockHash?: never\n }\n | {\n fromBlock?: never\n toBlock?: never\n /** Hash of block to include logs from */\n blockHash?: Hash\n }\n )\n\nexport type GetLogsResponse = Log[]\n\n/**\n * @description Returns a collection of event logs.\n */\nexport async function getLogs<TEventDefinition extends EventDefinition,>(\n client: PublicClient,\n {\n address,\n blockHash,\n fromBlock,\n toBlock,\n event,\n args,\n }: GetLogsArgs<TEventDefinition> = {},\n): Promise<GetLogsResponse> {\n let topics: LogTopic[] = []\n if (event) {\n topics = buildFilterTopics({ event, args })\n }\n let logs: RpcLog[]\n if (blockHash) {\n logs = await client.request({\n method: 'eth_getLogs',\n params: [{ address, topics, blockHash }],\n })\n } else {\n logs = await client.request({\n method: 'eth_getLogs',\n params: [\n {\n address,\n topics,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n },\n ],\n })\n }\n\n return logs.map(formatLog)\n}\n","import { PublicClient } from '../../clients'\nimport { Address, BlockTag, Hex } from '../../types'\nimport { numberToHex } from '../../utils'\n\nexport type GetStorageAtArgs = {\n address: Address\n slot: Hex\n} & (\n | {\n blockNumber?: never\n blockTag?: BlockTag\n }\n | {\n blockNumber?: bigint\n blockTag?: never\n }\n)\n\nexport type GetStorageAtResponse = Hex | undefined\n\nexport async function getStorageAt(\n client: PublicClient,\n { address, blockNumber, blockTag = 'latest', slot }: GetStorageAtArgs,\n): Promise<GetStorageAtResponse> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n const data = await client.request({\n method: 'eth_getStorageAt',\n params: [address, slot, blockNumberHex || blockTag],\n })\n return data\n}\n","import type { PublicClient } from '../../clients'\nimport { TransactionNotFoundError } from '../../errors'\nimport type { BlockTag, Chain, Hash, RpcTransaction } from '../../types'\nimport { format, numberToHex } from '../../utils'\nimport type {\n FormattedTransaction,\n TransactionFormatter,\n} from '../../utils/formatters/transaction'\nimport { formatTransaction } from '../../utils/formatters/transaction'\n\nexport type GetTransactionArgs =\n | {\n /** The block hash */\n blockHash: Hash\n blockNumber?: never\n blockTag?: never\n hash?: never\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: never\n /** The block number */\n blockNumber: bigint\n blockTag?: never\n hash?: never\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: never\n blockNumber?: never\n /** The block tag. */\n blockTag: BlockTag\n hash?: never\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: never\n blockNumber?: never\n blockTag?: never\n /** The hash of the transaction. */\n hash: Hash\n index?: number\n }\n\nexport type GetTransactionResponse<TChain extends Chain = Chain> =\n FormattedTransaction<TransactionFormatter<TChain>>\n\n/** @description Returns information about a transaction given a hash or block identifier. */\nexport async function getTransaction<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n {\n blockHash,\n blockNumber,\n blockTag = 'latest',\n hash,\n index,\n }: GetTransactionArgs,\n): Promise<GetTransactionResponse<TChain>> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let transaction: RpcTransaction | null = null\n if (hash) {\n transaction = await client.request({\n method: 'eth_getTransactionByHash',\n params: [hash],\n })\n } else if (blockHash) {\n transaction = await client.request({\n method: 'eth_getTransactionByBlockHashAndIndex',\n params: [blockHash, numberToHex(index)],\n })\n } else if (blockNumberHex || blockTag) {\n transaction = await client.request({\n method: 'eth_getTransactionByBlockNumberAndIndex',\n params: [blockNumberHex || blockTag, numberToHex(index)],\n })\n }\n\n if (!transaction)\n throw new TransactionNotFoundError({\n blockHash,\n blockNumber,\n blockTag,\n hash,\n index,\n })\n\n return format(transaction, {\n formatter: client.chain?.formatters?.transaction || formatTransaction,\n })\n}\n","import type { PublicClient } from '../../clients'\nimport type { Chain, Hash } from '../../types'\nimport type {\n FormattedTransactionReceipt,\n TransactionReceiptFormatter,\n} from '../../utils'\nimport { getBlockNumber } from './getBlockNumber'\nimport { getTransaction } from './getTransaction'\n\nexport type GetTransactionConfirmationsArgs<TChain extends Chain> =\n | {\n /** The transaction hash. */\n hash: Hash\n transactionReceipt?: never\n }\n | {\n hash?: never\n /** The transaction receipt. */\n transactionReceipt: FormattedTransactionReceipt<\n TransactionReceiptFormatter<TChain>\n >\n }\n\nexport type GetTransactionConfirmationsResponse = bigint\n\nexport async function getTransactionConfirmations<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n { hash, transactionReceipt }: GetTransactionConfirmationsArgs<TChain>,\n): Promise<GetTransactionConfirmationsResponse> {\n const [blockNumber, transaction] = await Promise.all([\n getBlockNumber(client),\n hash ? getTransaction(client, { hash }) : undefined,\n ])\n const transactionBlockNumber =\n transactionReceipt?.blockNumber || transaction?.blockNumber\n if (!transactionBlockNumber) return 0n\n return blockNumber - transactionBlockNumber! + 1n\n}\n","import type { PublicClient } from '../../clients'\nimport type { Address, BlockTag } from '../../types'\nimport { hexToNumber, numberToHex } from '../../utils'\n\nexport type GetTransactionCountArgs = {\n /** The account address. */\n address: Address\n} & (\n | {\n /** The block number. */\n blockNumber?: bigint\n blockTag?: never\n }\n | {\n blockNumber?: never\n /** The block tag. Defaults to 'latest'. */\n blockTag?: BlockTag\n }\n)\nexport type GetTransactionCountResponse = number\n\n/**\n * @description Returns the number of transactions an account has broadcast / sent.\n */\nexport async function getTransactionCount(\n client: PublicClient,\n { address, blockTag = 'latest', blockNumber }: GetTransactionCountArgs,\n): Promise<GetTransactionCountResponse> {\n const count = await client.request({\n method: 'eth_getTransactionCount',\n params: [address, blockNumber ? numberToHex(blockNumber) : blockTag],\n })\n return hexToNumber(count)\n}\n","import type { PublicClient } from '../../clients'\nimport { TransactionReceiptNotFoundError } from '../../errors'\nimport type { Chain, Hash } from '../../types'\nimport { format } from '../../utils'\nimport type {\n FormattedTransactionReceipt,\n TransactionReceiptFormatter,\n} from '../../utils/formatters/transactionReceipt'\nimport { formatTransactionReceipt } from '../../utils/formatters/transactionReceipt'\n\nexport type GetTransactionReceiptArgs = {\n /** The hash of the transaction. */\n hash: Hash\n}\n\nexport type GetTransactionReceiptResponse<TChain extends Chain = Chain> =\n FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>\n\nexport async function getTransactionReceipt<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n { hash }: GetTransactionReceiptArgs,\n) {\n const receipt = await client.request({\n method: 'eth_getTransactionReceipt',\n params: [hash],\n })\n\n if (!receipt) throw new TransactionReceiptNotFoundError({ hash })\n\n return format(receipt, {\n formatter:\n client.chain?.formatters?.transactionReceipt || formatTransactionReceipt,\n }) as GetTransactionReceiptResponse<TChain>\n}\n","import { Abi } from 'abitype'\n\nimport type { PublicClient } from '../../clients'\nimport type {\n Address,\n ExtractArgsFromAbi,\n ExtractResultFromAbi,\n ExtractFunctionNameFromAbi,\n Formatter,\n} from '../../types'\nimport {\n EncodeFunctionDataArgs,\n decodeFunctionResult,\n encodeFunctionData,\n getContractError,\n} from '../../utils'\nimport { call, CallArgs, FormattedCall } from './call'\n\nexport type FormattedReadContract<\n TFormatter extends Formatter | undefined = Formatter,\n> = FormattedCall<TFormatter>\n\nexport type ReadContractArgs<\n TAbi extends Abi | readonly unknown[] = Abi,\n TFunctionName extends string = any,\n> = Omit<\n CallArgs,\n | 'accessList'\n | 'chain'\n | 'from'\n | 'gas'\n | 'gasPrice'\n | 'maxFeePerGas'\n | 'maxPriorityFeePerGas'\n | 'nonce'\n | 'to'\n | 'data'\n | 'value'\n> & {\n address: Address\n abi: TAbi\n functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName, 'pure' | 'view'>\n} & ExtractArgsFromAbi<TAbi, TFunctionName>\n\nexport type ReadContractResponse<\n TAbi extends Abi | readonly unknown[] = Abi,\n TFunctionName extends string = string,\n> = ExtractResultFromAbi<TAbi, TFunctionName>\n\nexport async function readContract<\n TAbi extends Abi = Abi,\n TFunctionName extends string = any,\n>(\n client: PublicClient,\n {\n abi,\n address,\n args,\n functionName,\n ...callRequest\n }: ReadContractArgs<TAbi, TFunctionName>,\n): Promise<ReadContractResponse<TAbi, TFunctionName>> {\n const calldata = encodeFunctionData({\n abi,\n args,\n functionName,\n } as unknown as EncodeFunctionDataArgs<TAbi, TFunctionName>)\n try {\n const { data } = await call(client, {\n data: calldata,\n to: address,\n ...callRequest,\n } as unknown as CallArgs)\n return decodeFunctionResult({\n abi,\n functionName,\n data: data || '0x',\n })\n } catch (err) {\n throw getContractError(err, {\n abi,\n address,\n args,\n functionName,\n })\n }\n}\n","import type { PublicClient } from '../../clients'\nimport type { Filter } from '../../types'\n\nexport type UninstallFilterArgs = {\n filter: Filter<any>\n}\nexport type UninstallFilterResponse = boolean\n\nexport async function uninstallFilter(\n client: PublicClient,\n { filter }: UninstallFilterArgs,\n): Promise<UninstallFilterResponse> {\n return client.request({\n method: 'eth_uninstallFilter',\n params: [filter.id],\n })\n}\n","import type { MaybePromise } from '../types/utils'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\nconst listenersCache = new Map<string, { id: number; fns: Callbacks }[]>()\nconst cleanupCache = new Map<string, () => void>()\n\ntype EmitFunction<TCallbacks extends Callbacks> = (\n emit: TCallbacks,\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<TCallbacks extends Callbacks>(\n observerId: string,\n callbacks: TCallbacks,\n fn: EmitFunction<TCallbacks>,\n) {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId),\n )\n }\n\n const unwatch = () => {\n const cleanup = cleanupCache.get(observerId)\n if (getListeners().length === 1 && cleanup) cleanup()\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) return unwatch\n\n let emit: TCallbacks = {} as TCallbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<TCallbacks[keyof TCallbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) return\n listeners.forEach((listener) => listener.fns[key]?.(...args))\n }) as TCallbacks[Extract<keyof TCallbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') cleanupCache.set(observerId, cleanup)\n\n return unwatch\n}\n","import { wait } from './wait'\n\ntype PollOptions<TData> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean\n // The initial wait time (in ms) before polling.\n initialWaitTime?: (data: TData | void) => Promise<number>\n // The interval (in ms).\n interval: number\n}\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<TData>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<TData | void>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<TData>,\n) {\n let active = true\n\n const unwatch = () => (active = false)\n\n const watch = async () => {\n let data: TData | void\n if (emitOnBegin) data = await fn({ unpoll: unwatch })\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await wait(initialWait)\n\n const poll = async () => {\n if (!active) return\n await fn({ unpoll: unwatch })\n await wait(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n","import type { PublicClient } from '../../clients'\nimport { observe } from '../../utils/observe'\nimport { poll } from '../../utils/poll'\nimport type { GetBlockNumberResponse } from './getBlockNumber'\nimport { getBlockNumber } from './getBlockNumber'\n\nexport type OnBlockNumberResponse = GetBlockNumberResponse\nexport type OnBlockNumber = (\n blockNumber: OnBlockNumberResponse,\n prevBlockNumber: OnBlockNumberResponse | undefined,\n) => void\n\nexport type WatchBlockNumberArgs = {\n /** Whether or not to emit the missed block numbers to the callback. */\n emitMissed?: boolean\n /** Whether or not to emit the latest block number to the callback when the subscription opens. */\n emitOnBegin?: boolean\n /** The callback to call when a new block number is received. */\n onBlockNumber: OnBlockNumber\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: (error: Error) => void\n /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */\n pollingInterval?: number\n}\n\n/** @description Watches and returns incoming block numbers. */\nexport function watchBlockNumber(\n client: PublicClient,\n {\n emitOnBegin = false,\n emitMissed = false,\n onBlockNumber,\n onError,\n pollingInterval = client.pollingInterval,\n }: WatchBlockNumberArgs,\n) {\n const observerId = JSON.stringify([\n 'watchBlockNumber',\n client.uid,\n emitOnBegin,\n emitMissed,\n pollingInterval,\n ])\n\n let prevBlockNumber: GetBlockNumberResponse | undefined\n\n return observe(observerId, { onBlockNumber, onError }, (emit) =>\n poll(\n async () => {\n try {\n const blockNumber = await getBlockNumber(client, { maxAge: 0 })\n\n if (prevBlockNumber) {\n // If the current block number is the same as the previous,\n // we can skip.\n if (blockNumber === prevBlockNumber) return\n\n // If we have missed out on some previous blocks, and the\n // `emitMissed` flag is truthy, let's emit those blocks.\n if (blockNumber - prevBlockNumber > 1 && emitMissed) {\n for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {\n emit.onBlockNumber(i, prevBlockNumber)\n prevBlockNumber = i\n }\n }\n }\n prevBlockNumber = blockNumber\n emit.onBlockNumber(blockNumber, prevBlockNumber)\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin,\n interval: pollingInterval,\n },\n ),\n )\n}\n","import type { PublicClient } from '../../clients'\nimport type { BlockTag, Chain } from '../../types'\nimport { observe } from '../../utils/observe'\nimport { poll } from '../../utils/poll'\nimport type { GetBlockResponse } from './getBlock'\nimport { getBlock } from './getBlock'\n\nexport type OnBlockResponse<\n TChain extends Chain = Chain,\n TIncludeTransactions = false,\n> = Omit<\n GetBlockResponse<TChain>,\n TIncludeTransactions extends false ? 'transactions' : ''\n>\nexport type OnBlock<\n TChain extends Chain = Chain,\n TIncludeTransactions = false,\n> = (\n block: OnBlockResponse<TChain, TIncludeTransactions>,\n prevBlock: OnBlockResponse<TChain, TIncludeTransactions> | undefined,\n) => void\n\nexport type WatchBlocksArgs<TChain extends Chain = Chain> = {\n /** The block tag. Defaults to \"latest\". */\n blockTag?: BlockTag\n /** Whether or not to emit the missed blocks to the callback. */\n emitMissed?: boolean\n /** Whether or not to emit the block to the callback when the subscription opens. */\n emitOnBegin?: boolean\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: (error: Error) => void\n /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */\n pollingInterval?: number\n} & (\n | {\n /** Whether or not to include transaction data in the response. */\n includeTransactions: true\n /** The callback to call when a new block is received. */\n onBlock: OnBlock<TChain, true>\n }\n | {\n /** Whether or not to include transaction data in the response. */\n includeTransactions?: false\n /** The callback to call when a new block is received. */\n onBlock: OnBlock<TChain>\n }\n)\n\n/** @description Watches and returns information for incoming blocks. */\nexport function watchBlocks<\n TChain extends Chain,\n TWatchBlocksArgs extends WatchBlocksArgs<TChain>,\n>(\n client: PublicClient<any, TChain>,\n {\n blockTag = 'latest',\n emitMissed = false,\n emitOnBegin = false,\n onBlock,\n onError,\n includeTransactions = false,\n pollingInterval = client.pollingInterval,\n }: TWatchBlocksArgs,\n) {\n const observerId = JSON.stringify([\n 'watchBlocks',\n client.uid,\n emitMissed,\n emitOnBegin,\n includeTransactions,\n pollingInterval,\n ])\n\n let prevBlock: GetBlockResponse<TChain> | undefined\n\n return observe(observerId, { onBlock, onError }, (emit) =>\n poll(\n async () => {\n try {\n const block = await getBlock(client, {\n blockTag,\n includeTransactions,\n })\n if (block.number && prevBlock?.number) {\n // If the current block number is the same as the previous,\n // we can skip.\n if (block.number === prevBlock.number) return\n\n // If we have missed out on some previous blocks, and the\n // `emitMissed` flag is truthy, let's emit those blocks.\n if (block.number - prevBlock.number > 1 && emitMissed) {\n for (let i = prevBlock?.number + 1n; i < block.number; i++) {\n const block = await getBlock(client, {\n blockNumber: i,\n includeTransactions,\n })\n emit.onBlock(block, prevBlock)\n prevBlock = block\n }\n }\n }\n emit.onBlock(block, prevBlock)\n prevBlock = block\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin,\n interval: pollingInterval,\n },\n ),\n )\n}\n","import type { PublicClient } from '../../clients'\nimport type { Filter, Hash } from '../../types'\nimport { observe } from '../../utils/observe'\nimport { poll } from '../../utils/poll'\nimport { createPendingTransactionFilter } from './createPendingTransactionFilter'\nimport { getFilterChanges } from './getFilterChanges'\nimport { uninstallFilter } from './uninstallFilter'\n\nexport type OnTransactionsResponse = Hash[]\nexport type OnTransactions = (transactions: OnTransactionsResponse) => void\n\nexport type WatchPendingTransactionsArgs = {\n /** Whether or not the transaction hashes should be batched on each invocation. */\n batch?: boolean\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: (error: Error) => void\n /** The callback to call when new transactions are received. */\n onTransactions: OnTransactions\n /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */\n pollingInterval?: number\n}\n\nexport function watchPendingTransactions(\n client: PublicClient,\n {\n batch = true,\n onError,\n onTransactions,\n pollingInterval = client.pollingInterval,\n }: WatchPendingTransactionsArgs,\n) {\n const observerId = JSON.stringify([\n 'watchPendingTransactions',\n client.uid,\n batch,\n pollingInterval,\n ])\n\n return observe(observerId, { onTransactions, onError }, (emit) => {\n let filter: Filter<'transaction'>\n\n const unwatch = poll(\n async () => {\n try {\n if (!filter) {\n try {\n filter = await createPendingTransactionFilter(client)\n return\n } catch (err) {\n unwatch()\n throw err\n }\n }\n\n const hashes = await getFilterChanges(client, { filter })\n if (hashes.length === 0) return\n if (batch) emit.onTransactions(hashes)\n else hashes.forEach((hash) => emit.onTransactions([hash]))\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin: true,\n interval: pollingInterval,\n },\n )\n\n return async () => {\n if (filter) await uninstallFilter(client, { filter })\n unwatch()\n }\n })\n}\n","import type { PublicClient } from '../../clients'\nimport {\n TransactionNotFoundError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n} from '../../errors'\nimport type { Chain, Hash, Transaction } from '../../types'\nimport { observe } from '../../utils/observe'\nimport { getBlock, watchBlockNumber } from '../public'\n\nimport type { GetTransactionResponse } from './getTransaction'\nimport { getTransaction } from './getTransaction'\nimport type { GetTransactionReceiptResponse } from './getTransactionReceipt'\nimport { getTransactionReceipt } from './getTransactionReceipt'\n\nexport type ReplacementReason = 'cancelled' | 'replaced' | 'repriced'\nexport type ReplacementResponse<TChain extends Chain = Chain> = {\n reason: ReplacementReason\n replacedTransaction: Transaction\n transaction: Transaction\n transactionReceipt: GetTransactionReceiptResponse<TChain>\n}\n\nexport type WaitForTransactionReceiptResponse<TChain extends Chain = Chain> =\n GetTransactionReceiptResponse<TChain>\n\nexport type WaitForTransactionReceiptArgs<TChain extends Chain = Chain> = {\n /** The number of confirmations (blocks that have passed) to wait before resolving. */\n confirmations?: number\n /** The hash of the transaction. */\n hash: Hash\n onReplaced?: (response: ReplacementResponse<TChain>) => void\n /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */\n pollingInterval?: number\n /** Optional timeout (in milliseconds) to wait before stopping polling. */\n timeout?: number\n}\n\nexport async function waitForTransactionReceipt<TChain extends Chain>(\n client: PublicClient<any, TChain>,\n {\n confirmations = 1,\n hash,\n onReplaced,\n pollingInterval = client.pollingInterval,\n timeout,\n }: WaitForTransactionReceiptArgs<TChain>,\n): Promise<WaitForTransactionReceiptResponse<TChain>> {\n const observerId = JSON.stringify([\n 'waitForTransactionReceipt',\n client.uid,\n hash,\n ])\n\n let transaction: GetTransactionResponse<TChain> | undefined\n let replacedTransaction: GetTransactionResponse<TChain> | undefined\n let receipt: GetTransactionReceiptResponse<TChain>\n\n return new Promise((resolve, reject) => {\n if (timeout)\n setTimeout(\n () => reject(new WaitForTransactionReceiptTimeoutError({ hash })),\n timeout,\n )\n\n const unobserve = observe(\n observerId,\n { onReplaced, resolve, reject },\n (emit) => {\n const unwatch = watchBlockNumber(client, {\n emitMissed: true,\n emitOnBegin: true,\n pollingInterval,\n async onBlockNumber(blockNumber) {\n const done = async (fn: () => void) => {\n unwatch()\n fn()\n unobserve()\n }\n\n try {\n // If we already have a valid receipt, let's check if we have enough\n // confirmations. If we do, then we can resolve.\n if (receipt) {\n if (blockNumber - receipt.blockNumber + 1n < confirmations)\n return\n\n done(() => emit.resolve(receipt))\n return\n }\n\n // Get the transaction to check if it's been replaced.\n transaction = await getTransaction(client, { hash })\n\n // Get the receipt to check if it's been processed.\n receipt = await getTransactionReceipt(client, { hash })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (blockNumber - receipt.blockNumber + 1n < confirmations) return\n\n done(() => emit.resolve(receipt))\n } catch (err) {\n // If the receipt is not found, the transaction will be pending.\n // We need to check if it has potentially been replaced.\n if (\n transaction &&\n (err instanceof TransactionNotFoundError ||\n err instanceof TransactionReceiptNotFoundError)\n ) {\n replacedTransaction = transaction\n\n // Let's retrieve the transactions from the current block.\n const block = await getBlock(client, {\n blockNumber,\n includeTransactions: true,\n })\n\n const replacementTransaction = (\n block.transactions as Transaction[]\n ).find(\n ({ from, nonce }) =>\n from === replacedTransaction!.from &&\n nonce === replacedTransaction!.nonce,\n )\n\n // If we couldn't find a replacement transaction, continue polling.\n if (!replacementTransaction) return\n\n // If we found a replacement transaction, return it's receipt.\n receipt = await getTransactionReceipt(client, {\n hash: replacementTransaction.hash,\n })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (blockNumber - receipt.blockNumber + 1n < confirmations)\n return\n\n let reason: ReplacementReason = 'replaced'\n if (\n replacementTransaction.to === replacedTransaction.to &&\n replacementTransaction.value === replacedTransaction.value\n ) {\n reason = 'repriced'\n } else if (\n replacementTransaction.from === replacementTransaction.to &&\n replacementTransaction.value === 0n\n ) {\n reason = 'cancelled'\n }\n\n done(() => {\n emit.onReplaced?.({\n reason,\n replacedTransaction: replacedTransaction!,\n transaction: replacementTransaction,\n transactionReceipt: receipt,\n })\n emit.resolve(receipt)\n })\n } else {\n done(() => emit.reject(err))\n }\n }\n },\n })\n return unwatch\n },\n )\n })\n}\n"]}
|