viem 1.19.1 → 1.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/_cjs/actions/ens/getEnsAddress.js +1 -1
- package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/_cjs/actions/ens/getEnsAvatar.js +1 -1
- package/_cjs/actions/ens/getEnsAvatar.js.map +1 -1
- package/_cjs/actions/ens/getEnsName.js +1 -1
- package/_cjs/actions/ens/getEnsName.js.map +1 -1
- package/_cjs/actions/ens/getEnsResolver.js +1 -1
- package/_cjs/actions/ens/getEnsResolver.js.map +1 -1
- package/_cjs/actions/ens/getEnsText.js +1 -1
- package/_cjs/actions/ens/getEnsText.js.map +1 -1
- package/_cjs/actions/getContract.js +7 -7
- package/_cjs/actions/getContract.js.map +1 -1
- package/_cjs/actions/public/estimateContractGas.js +1 -1
- package/_cjs/actions/public/estimateContractGas.js.map +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js +5 -2
- package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js +5 -3
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_cjs/actions/public/getContractEvents.js +1 -1
- package/_cjs/actions/public/getContractEvents.js.map +1 -1
- package/_cjs/actions/public/getTransactionConfirmations.js +4 -2
- package/_cjs/actions/public/getTransactionConfirmations.js.map +1 -1
- package/_cjs/actions/public/multicall.js +1 -1
- package/_cjs/actions/public/multicall.js.map +1 -1
- package/_cjs/actions/public/readContract.js +1 -1
- package/_cjs/actions/public/readContract.js.map +1 -1
- package/_cjs/actions/public/simulateContract.js +1 -1
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/public/verifyHash.js +1 -1
- package/_cjs/actions/public/verifyHash.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +5 -5
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchBlockNumber.js +1 -1
- package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/_cjs/actions/public/watchBlocks.js +2 -2
- package/_cjs/actions/public/watchBlocks.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +7 -6
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +7 -6
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/actions/public/watchPendingTransactions.js +5 -4
- package/_cjs/actions/public/watchPendingTransactions.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +3 -3
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +4 -4
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/signTransaction.js +1 -1
- package/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js +1 -1
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/errors/node.js +11 -11
- package/_cjs/errors/node.js.map +1 -1
- package/_cjs/errors/rpc.js +18 -18
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/utils/encoding/toRlp.js +3 -1
- package/_cjs/utils/encoding/toRlp.js.map +1 -1
- package/_cjs/utils/getAction.js +2 -2
- package/_cjs/utils/getAction.js.map +1 -1
- package/_cjs/utils/observe.js +2 -1
- package/_cjs/utils/observe.js.map +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js +8 -2
- package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/_esm/actions/ens/getEnsAddress.js +1 -1
- package/_esm/actions/ens/getEnsAddress.js.map +1 -1
- package/_esm/actions/ens/getEnsAvatar.js +1 -1
- package/_esm/actions/ens/getEnsAvatar.js.map +1 -1
- package/_esm/actions/ens/getEnsName.js +1 -1
- package/_esm/actions/ens/getEnsName.js.map +1 -1
- package/_esm/actions/ens/getEnsResolver.js +1 -1
- package/_esm/actions/ens/getEnsResolver.js.map +1 -1
- package/_esm/actions/ens/getEnsText.js +1 -1
- package/_esm/actions/ens/getEnsText.js.map +1 -1
- package/_esm/actions/getContract.js +7 -7
- package/_esm/actions/getContract.js.map +1 -1
- package/_esm/actions/public/estimateContractGas.js +1 -1
- package/_esm/actions/public/estimateContractGas.js.map +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js +5 -2
- package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js +5 -3
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_esm/actions/public/getContractEvents.js +1 -1
- package/_esm/actions/public/getContractEvents.js.map +1 -1
- package/_esm/actions/public/getTransactionConfirmations.js +4 -2
- package/_esm/actions/public/getTransactionConfirmations.js.map +1 -1
- package/_esm/actions/public/multicall.js +1 -1
- package/_esm/actions/public/multicall.js.map +1 -1
- package/_esm/actions/public/readContract.js +1 -1
- package/_esm/actions/public/readContract.js.map +1 -1
- package/_esm/actions/public/simulateContract.js +1 -1
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/public/verifyHash.js +1 -1
- package/_esm/actions/public/verifyHash.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +5 -5
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchBlockNumber.js +1 -1
- package/_esm/actions/public/watchBlockNumber.js.map +1 -1
- package/_esm/actions/public/watchBlocks.js +2 -2
- package/_esm/actions/public/watchBlocks.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +7 -6
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +7 -6
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/actions/public/watchPendingTransactions.js +5 -4
- package/_esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +3 -3
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +4 -4
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/signTransaction.js +1 -1
- package/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js +1 -1
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/errors/node.js +11 -22
- package/_esm/errors/node.js.map +1 -1
- package/_esm/errors/rpc.js +18 -36
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/utils/encoding/toRlp.js +3 -1
- package/_esm/utils/encoding/toRlp.js.map +1 -1
- package/_esm/utils/getAction.js +12 -2
- package/_esm/utils/getAction.js.map +1 -1
- package/_esm/utils/observe.js +2 -1
- package/_esm/utils/observe.js.map +1 -1
- package/_esm/utils/promise/createBatchScheduler.js +8 -2
- package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/_types/actions/ens/getEnsAvatar.d.ts.map +1 -1
- package/_types/actions/ens/getEnsName.d.ts.map +1 -1
- package/_types/actions/ens/getEnsResolver.d.ts.map +1 -1
- package/_types/actions/ens/getEnsText.d.ts.map +1 -1
- package/_types/actions/getContract.d.ts +8 -8
- package/_types/actions/getContract.d.ts.map +1 -1
- package/_types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/_types/actions/public/estimateFeesPerGas.d.ts.map +1 -1
- package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -1
- package/_types/actions/public/getContractEvents.d.ts.map +1 -1
- package/_types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
- package/_types/actions/public/multicall.d.ts.map +1 -1
- package/_types/actions/public/readContract.d.ts.map +1 -1
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/public/verifyHash.d.ts.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/_types/actions/public/watchBlocks.d.ts.map +1 -1
- package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.d.ts.map +1 -1
- package/_types/actions/public/watchPendingTransactions.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/clients/createClient.d.ts +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/types/ens.d.ts +1 -1
- package/_types/types/ens.d.ts.map +1 -1
- package/_types/utils/formatters/block.d.ts +2 -2
- package/_types/utils/formatters/block.d.ts.map +1 -1
- package/_types/utils/formatters/formatter.d.ts +1 -1
- package/_types/utils/formatters/transaction.d.ts +2 -2
- package/_types/utils/formatters/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/transactionReceipt.d.ts +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +1 -1
- package/_types/utils/getAction.d.ts +8 -1
- package/_types/utils/getAction.d.ts.map +1 -1
- package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/actions/ens/getEnsAddress.ts +1 -0
- package/actions/ens/getEnsAvatar.ts +1 -0
- package/actions/ens/getEnsName.ts +1 -0
- package/actions/ens/getEnsResolver.ts +1 -0
- package/actions/ens/getEnsText.ts +1 -0
- package/actions/getContract.ts +23 -16
- package/actions/public/estimateContractGas.ts +1 -0
- package/actions/public/estimateFeesPerGas.ts +5 -2
- package/actions/public/estimateMaxPriorityFeePerGas.ts +5 -3
- package/actions/public/getContractEvents.ts +1 -0
- package/actions/public/getTransactionConfirmations.ts +4 -2
- package/actions/public/multicall.ts +1 -0
- package/actions/public/readContract.ts +1 -0
- package/actions/public/simulateContract.ts +1 -0
- package/actions/public/verifyHash.ts +1 -0
- package/actions/public/waitForTransactionReceipt.ts +9 -1
- package/actions/public/watchBlockNumber.ts +1 -0
- package/actions/public/watchBlocks.ts +2 -0
- package/actions/public/watchContractEvent.ts +19 -4
- package/actions/public/watchEvent.ts +19 -4
- package/actions/public/watchPendingTransactions.ts +13 -3
- package/actions/wallet/prepareTransactionRequest.ts +7 -1
- package/actions/wallet/sendTransaction.ts +5 -2
- package/actions/wallet/signTransaction.ts +1 -1
- package/actions/wallet/writeContract.ts +1 -0
- package/clients/createClient.ts +1 -1
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/types/ens.ts +1 -1
- package/utils/encoding/toRlp.ts +3 -1
- package/utils/formatters/block.ts +1 -1
- package/utils/formatters/formatter.ts +1 -1
- package/utils/formatters/transaction.ts +1 -1
- package/utils/getAction.ts +11 -1
- package/utils/observe.ts +1 -1
- package/utils/promise/createBatchScheduler.ts +8 -4
package/actions/getContract.ts
CHANGED
@@ -156,10 +156,10 @@ export type GetContractReturnType<
|
|
156
156
|
* // 424122n
|
157
157
|
*/
|
158
158
|
read: {
|
159
|
-
[
|
159
|
+
[_FunctionName in _ReadFunctionNames]: GetReadFunction<
|
160
160
|
_Narrowable,
|
161
161
|
TAbi,
|
162
|
-
|
162
|
+
_FunctionName
|
163
163
|
>
|
164
164
|
}
|
165
165
|
}) &
|
@@ -187,12 +187,12 @@ export type GetContractReturnType<
|
|
187
187
|
* })
|
188
188
|
*/
|
189
189
|
estimateGas: {
|
190
|
-
[
|
190
|
+
[_FunctionName in _WriteFunctionNames]: GetEstimateFunction<
|
191
191
|
_Narrowable,
|
192
192
|
TPublicClient['chain'],
|
193
193
|
undefined,
|
194
194
|
TAbi,
|
195
|
-
|
195
|
+
_FunctionName
|
196
196
|
>
|
197
197
|
}
|
198
198
|
/**
|
@@ -220,11 +220,11 @@ export type GetContractReturnType<
|
|
220
220
|
* })
|
221
221
|
*/
|
222
222
|
simulate: {
|
223
|
-
[
|
223
|
+
[_FunctionName in _WriteFunctionNames]: GetSimulateFunction<
|
224
224
|
_Narrowable,
|
225
225
|
TPublicClient['chain'],
|
226
226
|
TAbi,
|
227
|
-
|
227
|
+
_FunctionName
|
228
228
|
>
|
229
229
|
}
|
230
230
|
}) &
|
@@ -250,10 +250,10 @@ export type GetContractReturnType<
|
|
250
250
|
* const filter = await contract.createEventFilter.Transfer()
|
251
251
|
*/
|
252
252
|
createEventFilter: {
|
253
|
-
[
|
253
|
+
[_EventName in _EventNames]: GetEventFilter<
|
254
254
|
_Narrowable,
|
255
255
|
TAbi,
|
256
|
-
|
256
|
+
_EventName
|
257
257
|
>
|
258
258
|
}
|
259
259
|
/**
|
@@ -275,10 +275,10 @@ export type GetContractReturnType<
|
|
275
275
|
* const filter = await contract.createEventFilter.Transfer()
|
276
276
|
*/
|
277
277
|
getEvents: {
|
278
|
-
[
|
278
|
+
[_EventName in _EventNames]: GetEventsFunction<
|
279
279
|
_Narrowable,
|
280
280
|
TAbi,
|
281
|
-
|
281
|
+
_EventName
|
282
282
|
>
|
283
283
|
}
|
284
284
|
/**
|
@@ -308,10 +308,10 @@ export type GetContractReturnType<
|
|
308
308
|
* )
|
309
309
|
*/
|
310
310
|
watchEvent: {
|
311
|
-
[
|
311
|
+
[_EventName in _EventNames]: GetWatchEvent<
|
312
312
|
_Narrowable,
|
313
313
|
TAbi,
|
314
|
-
|
314
|
+
_EventName
|
315
315
|
>
|
316
316
|
}
|
317
317
|
})
|
@@ -341,12 +341,12 @@ export type GetContractReturnType<
|
|
341
341
|
* })
|
342
342
|
*/
|
343
343
|
estimateGas: {
|
344
|
-
[
|
344
|
+
[_FunctionName in _WriteFunctionNames]: GetEstimateFunction<
|
345
345
|
_Narrowable,
|
346
346
|
TWalletClient['chain'],
|
347
347
|
TWalletClient['account'],
|
348
348
|
TAbi,
|
349
|
-
|
349
|
+
_FunctionName
|
350
350
|
>
|
351
351
|
}
|
352
352
|
/**
|
@@ -376,12 +376,12 @@ export type GetContractReturnType<
|
|
376
376
|
* })
|
377
377
|
*/
|
378
378
|
write: {
|
379
|
-
[
|
379
|
+
[_FunctionName in _WriteFunctionNames]: GetWriteFunction<
|
380
380
|
_Narrowable,
|
381
381
|
TWalletClient['chain'],
|
382
382
|
TWalletClient['account'],
|
383
383
|
TAbi,
|
384
|
-
|
384
|
+
_FunctionName
|
385
385
|
>
|
386
386
|
}
|
387
387
|
}
|
@@ -489,6 +489,7 @@ export function getContract<
|
|
489
489
|
return getAction(
|
490
490
|
publicClient,
|
491
491
|
readContract,
|
492
|
+
'readContract',
|
492
493
|
)({
|
493
494
|
abi,
|
494
495
|
address,
|
@@ -519,6 +520,7 @@ export function getContract<
|
|
519
520
|
return getAction(
|
520
521
|
publicClient,
|
521
522
|
simulateContract,
|
523
|
+
'simulateContract',
|
522
524
|
)({
|
523
525
|
abi,
|
524
526
|
address,
|
@@ -555,6 +557,7 @@ export function getContract<
|
|
555
557
|
return getAction(
|
556
558
|
publicClient,
|
557
559
|
createContractEventFilter,
|
560
|
+
'createContractEventFilter',
|
558
561
|
)({
|
559
562
|
abi,
|
560
563
|
address,
|
@@ -589,6 +592,7 @@ export function getContract<
|
|
589
592
|
return getAction(
|
590
593
|
publicClient,
|
591
594
|
getContractEvents,
|
595
|
+
'getContractEvents',
|
592
596
|
)({
|
593
597
|
abi,
|
594
598
|
address,
|
@@ -623,6 +627,7 @@ export function getContract<
|
|
623
627
|
return getAction(
|
624
628
|
publicClient,
|
625
629
|
watchContractEvent,
|
630
|
+
'watchContractEvent',
|
626
631
|
)({
|
627
632
|
abi,
|
628
633
|
address,
|
@@ -656,6 +661,7 @@ export function getContract<
|
|
656
661
|
return getAction(
|
657
662
|
walletClient,
|
658
663
|
writeContract,
|
664
|
+
'writeContract',
|
659
665
|
)({
|
660
666
|
abi,
|
661
667
|
address,
|
@@ -694,6 +700,7 @@ export function getContract<
|
|
694
700
|
return getAction(
|
695
701
|
client,
|
696
702
|
estimateContractGas,
|
703
|
+
'estimateContractGas',
|
697
704
|
)({
|
698
705
|
abi,
|
699
706
|
address,
|
@@ -126,7 +126,9 @@ export async function internal_estimateFeesPerGas<
|
|
126
126
|
(base * BigInt(Math.ceil(baseFeeMultiplier * denominator))) /
|
127
127
|
BigInt(denominator)
|
128
128
|
|
129
|
-
const block = block_
|
129
|
+
const block = block_
|
130
|
+
? block_
|
131
|
+
: await getAction(client, getBlock, 'getBlock')({})
|
130
132
|
|
131
133
|
if (typeof chain?.fees?.estimateFeesPerGas === 'function')
|
132
134
|
return chain.fees.estimateFeesPerGas({
|
@@ -163,7 +165,8 @@ export async function internal_estimateFeesPerGas<
|
|
163
165
|
}
|
164
166
|
|
165
167
|
const gasPrice =
|
166
|
-
request?.gasPrice ??
|
168
|
+
request?.gasPrice ??
|
169
|
+
multiply(await getAction(client, getGasPrice, 'getGasPrice')({}))
|
167
170
|
return {
|
168
171
|
gasPrice,
|
169
172
|
} as EstimateFeesPerGasReturnType<type>
|
@@ -83,7 +83,7 @@ export async function internal_estimateMaxPriorityFeePerGas<
|
|
83
83
|
): Promise<EstimateMaxPriorityFeePerGasReturnType> {
|
84
84
|
const { block: block_, chain = client.chain, request } = args || {}
|
85
85
|
if (typeof chain?.fees?.defaultPriorityFee === 'function') {
|
86
|
-
const block = block_ || (await getAction(client, getBlock)({}))
|
86
|
+
const block = block_ || (await getAction(client, getBlock, 'getBlock')({}))
|
87
87
|
return chain.fees.defaultPriorityFee({
|
88
88
|
block,
|
89
89
|
client,
|
@@ -102,8 +102,10 @@ export async function internal_estimateMaxPriorityFeePerGas<
|
|
102
102
|
// fall back to calculating it manually via `gasPrice - baseFeePerGas`.
|
103
103
|
// See: https://github.com/ethereum/pm/issues/328#:~:text=eth_maxPriorityFeePerGas%20after%20London%20will%20effectively%20return%20eth_gasPrice%20%2D%20baseFee
|
104
104
|
const [block, gasPrice] = await Promise.all([
|
105
|
-
block_
|
106
|
-
|
105
|
+
block_
|
106
|
+
? Promise.resolve(block_)
|
107
|
+
: getAction(client, getBlock, 'getBlock')({}),
|
108
|
+
getAction(client, getGasPrice, 'getGasPrice')({}),
|
107
109
|
])
|
108
110
|
|
109
111
|
if (typeof block.baseFeePerGas !== 'bigint')
|
@@ -67,8 +67,10 @@ export async function getTransactionConfirmations<
|
|
67
67
|
{ hash, transactionReceipt }: GetTransactionConfirmationsParameters<TChain>,
|
68
68
|
): Promise<GetTransactionConfirmationsReturnType> {
|
69
69
|
const [blockNumber, transaction] = await Promise.all([
|
70
|
-
getAction(client, getBlockNumber)({}),
|
71
|
-
hash
|
70
|
+
getAction(client, getBlockNumber, 'getBlockNumber')({}),
|
71
|
+
hash
|
72
|
+
? getAction(client, getTransaction, 'getBlockNumber')({ hash })
|
73
|
+
: undefined,
|
72
74
|
])
|
73
75
|
const transactionBlockNumber =
|
74
76
|
transactionReceipt?.blockNumber || transaction?.blockNumber
|
@@ -144,6 +144,7 @@ export async function waitForTransactionReceipt<
|
|
144
144
|
const _unwatch = getAction(
|
145
145
|
client,
|
146
146
|
watchBlockNumber,
|
147
|
+
'watchBlockNumber',
|
147
148
|
)({
|
148
149
|
emitMissed: true,
|
149
150
|
emitOnBegin: true,
|
@@ -185,6 +186,7 @@ export async function waitForTransactionReceipt<
|
|
185
186
|
transaction = (await getAction(
|
186
187
|
client,
|
187
188
|
getTransaction,
|
189
|
+
'getTransaction',
|
188
190
|
)({ hash })) as GetTransactionReturnType<TChain>
|
189
191
|
if (transaction.blockNumber)
|
190
192
|
blockNumber = transaction.blockNumber
|
@@ -199,7 +201,11 @@ export async function waitForTransactionReceipt<
|
|
199
201
|
}
|
200
202
|
|
201
203
|
// Get the receipt to check if it's been processed.
|
202
|
-
receipt = await getAction(
|
204
|
+
receipt = await getAction(
|
205
|
+
client,
|
206
|
+
getTransactionReceipt,
|
207
|
+
'getTransactionReceipt',
|
208
|
+
)({ hash })
|
203
209
|
|
204
210
|
// Check if we have enough confirmations. If not, continue polling.
|
205
211
|
if (
|
@@ -225,6 +231,7 @@ export async function waitForTransactionReceipt<
|
|
225
231
|
const block = await getAction(
|
226
232
|
client,
|
227
233
|
getBlock,
|
234
|
+
'getBlock',
|
228
235
|
)({
|
229
236
|
blockNumber,
|
230
237
|
includeTransactions: true,
|
@@ -245,6 +252,7 @@ export async function waitForTransactionReceipt<
|
|
245
252
|
receipt = await getAction(
|
246
253
|
client,
|
247
254
|
getTransactionReceipt,
|
255
|
+
'getTransactionReceipt',
|
248
256
|
)({
|
249
257
|
hash: replacementTransaction.hash,
|
250
258
|
})
|
@@ -144,6 +144,7 @@ export function watchBlocks<
|
|
144
144
|
const block = await getAction(
|
145
145
|
client,
|
146
146
|
getBlock,
|
147
|
+
'getBlock',
|
147
148
|
)({
|
148
149
|
blockTag,
|
149
150
|
includeTransactions,
|
@@ -160,6 +161,7 @@ export function watchBlocks<
|
|
160
161
|
const block = (await getAction(
|
161
162
|
client,
|
162
163
|
getBlock,
|
164
|
+
'getBlock',
|
163
165
|
)({
|
164
166
|
blockNumber: i,
|
165
167
|
includeTransactions,
|
@@ -191,6 +191,7 @@ export function watchContractEvent<
|
|
191
191
|
filter = (await getAction(
|
192
192
|
client,
|
193
193
|
createContractEventFilter,
|
194
|
+
'createContractEventFilter',
|
194
195
|
)({
|
195
196
|
abi,
|
196
197
|
address,
|
@@ -210,13 +211,21 @@ export function watchContractEvent<
|
|
210
211
|
try {
|
211
212
|
let logs: Log[]
|
212
213
|
if (filter) {
|
213
|
-
logs = await getAction(
|
214
|
+
logs = await getAction(
|
215
|
+
client,
|
216
|
+
getFilterChanges,
|
217
|
+
'getFilterChanges',
|
218
|
+
)({ filter })
|
214
219
|
} else {
|
215
220
|
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
216
221
|
// The fall back exists because some RPC Providers do not support filters.
|
217
222
|
|
218
223
|
// Fetch the block number to use for `getLogs`.
|
219
|
-
const blockNumber = await getAction(
|
224
|
+
const blockNumber = await getAction(
|
225
|
+
client,
|
226
|
+
getBlockNumber,
|
227
|
+
'getBlockNumber',
|
228
|
+
)({})
|
220
229
|
|
221
230
|
// If the block number has changed, we will need to fetch the logs.
|
222
231
|
// If the block number doesn't exist, we are yet to reach the first poll interval,
|
@@ -225,6 +234,7 @@ export function watchContractEvent<
|
|
225
234
|
logs = await getAction(
|
226
235
|
client,
|
227
236
|
getContractEvents,
|
237
|
+
'getContractEvents',
|
228
238
|
)({
|
229
239
|
abi,
|
230
240
|
address,
|
@@ -242,7 +252,7 @@ export function watchContractEvent<
|
|
242
252
|
|
243
253
|
if (logs.length === 0) return
|
244
254
|
if (batch) emit.onLogs(logs as any)
|
245
|
-
else
|
255
|
+
else for (const log of logs) emit.onLogs([log] as any)
|
246
256
|
} catch (err) {
|
247
257
|
// If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
|
248
258
|
// Reinitalize the filter when this occurs
|
@@ -258,7 +268,12 @@ export function watchContractEvent<
|
|
258
268
|
)
|
259
269
|
|
260
270
|
return async () => {
|
261
|
-
if (filter)
|
271
|
+
if (filter)
|
272
|
+
await getAction(
|
273
|
+
client,
|
274
|
+
uninstallFilter,
|
275
|
+
'uninstallFilter',
|
276
|
+
)({ filter })
|
262
277
|
unwatch()
|
263
278
|
}
|
264
279
|
})
|
@@ -226,6 +226,7 @@ export function watchEvent<
|
|
226
226
|
filter = (await getAction(
|
227
227
|
client,
|
228
228
|
createEventFilter as any,
|
229
|
+
'createEventFilter',
|
229
230
|
)({
|
230
231
|
address,
|
231
232
|
args,
|
@@ -245,13 +246,21 @@ export function watchEvent<
|
|
245
246
|
try {
|
246
247
|
let logs: Log[]
|
247
248
|
if (filter) {
|
248
|
-
logs = await getAction(
|
249
|
+
logs = await getAction(
|
250
|
+
client,
|
251
|
+
getFilterChanges,
|
252
|
+
'getFilterChanges',
|
253
|
+
)({ filter })
|
249
254
|
} else {
|
250
255
|
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
251
256
|
// The fall back exists because some RPC Providers do not support filters.
|
252
257
|
|
253
258
|
// Fetch the block number to use for `getLogs`.
|
254
|
-
const blockNumber = await getAction(
|
259
|
+
const blockNumber = await getAction(
|
260
|
+
client,
|
261
|
+
getBlockNumber,
|
262
|
+
'getBlockNumber',
|
263
|
+
)({})
|
255
264
|
|
256
265
|
// If the block number has changed, we will need to fetch the logs.
|
257
266
|
// If the block number doesn't exist, we are yet to reach the first poll interval,
|
@@ -260,6 +269,7 @@ export function watchEvent<
|
|
260
269
|
logs = await getAction(
|
261
270
|
client,
|
262
271
|
getLogs,
|
272
|
+
'getLogs',
|
263
273
|
)({
|
264
274
|
address,
|
265
275
|
args,
|
@@ -276,7 +286,7 @@ export function watchEvent<
|
|
276
286
|
|
277
287
|
if (logs.length === 0) return
|
278
288
|
if (batch) emit.onLogs(logs as any)
|
279
|
-
else
|
289
|
+
else for (const log of logs) emit.onLogs([log] as any)
|
280
290
|
} catch (err) {
|
281
291
|
// If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
|
282
292
|
// Reinitalize the filter when this occurs
|
@@ -292,7 +302,12 @@ export function watchEvent<
|
|
292
302
|
)
|
293
303
|
|
294
304
|
return async () => {
|
295
|
-
if (filter)
|
305
|
+
if (filter)
|
306
|
+
await getAction(
|
307
|
+
client,
|
308
|
+
uninstallFilter,
|
309
|
+
'uninstallFilter',
|
310
|
+
)({ filter })
|
296
311
|
unwatch()
|
297
312
|
}
|
298
313
|
})
|
@@ -129,6 +129,7 @@ export function watchPendingTransactions<
|
|
129
129
|
filter = await getAction(
|
130
130
|
client,
|
131
131
|
createPendingTransactionFilter,
|
132
|
+
'createPendingTransactionFilter',
|
132
133
|
)({})
|
133
134
|
return
|
134
135
|
} catch (err) {
|
@@ -137,10 +138,14 @@ export function watchPendingTransactions<
|
|
137
138
|
}
|
138
139
|
}
|
139
140
|
|
140
|
-
const hashes = await getAction(
|
141
|
+
const hashes = await getAction(
|
142
|
+
client,
|
143
|
+
getFilterChanges,
|
144
|
+
'getFilterChanges',
|
145
|
+
)({ filter })
|
141
146
|
if (hashes.length === 0) return
|
142
147
|
if (batch) emit.onTransactions(hashes)
|
143
|
-
else
|
148
|
+
else for (const hash of hashes) emit.onTransactions([hash])
|
144
149
|
} catch (err) {
|
145
150
|
emit.onError?.(err as Error)
|
146
151
|
}
|
@@ -152,7 +157,12 @@ export function watchPendingTransactions<
|
|
152
157
|
)
|
153
158
|
|
154
159
|
return async () => {
|
155
|
-
if (filter)
|
160
|
+
if (filter)
|
161
|
+
await getAction(
|
162
|
+
client,
|
163
|
+
uninstallFilter,
|
164
|
+
'uninstallFilter',
|
165
|
+
)({ filter })
|
156
166
|
unwatch()
|
157
167
|
}
|
158
168
|
})
|
@@ -130,7 +130,11 @@ export async function prepareTransactionRequest<
|
|
130
130
|
if (!account_) throw new AccountNotFoundError()
|
131
131
|
const account = parseAccount(account_)
|
132
132
|
|
133
|
-
const block = await getAction(
|
133
|
+
const block = await getAction(
|
134
|
+
client,
|
135
|
+
getBlock,
|
136
|
+
'getBlock',
|
137
|
+
)({ blockTag: 'latest' })
|
134
138
|
|
135
139
|
const request = { ...args, from: account.address }
|
136
140
|
|
@@ -138,6 +142,7 @@ export async function prepareTransactionRequest<
|
|
138
142
|
request.nonce = await getAction(
|
139
143
|
client,
|
140
144
|
getTransactionCount,
|
145
|
+
'getTransactionCount',
|
141
146
|
)({
|
142
147
|
address: account.address,
|
143
148
|
blockTag: 'pending',
|
@@ -196,6 +201,7 @@ export async function prepareTransactionRequest<
|
|
196
201
|
request.gas = await getAction(
|
197
202
|
client,
|
198
203
|
estimateGas,
|
204
|
+
'estimateGas',
|
199
205
|
)({
|
200
206
|
...request,
|
201
207
|
account: { address: account.address, type: 'json-rpc' },
|
@@ -155,7 +155,7 @@ export async function sendTransaction<
|
|
155
155
|
|
156
156
|
let chainId
|
157
157
|
if (chain !== null) {
|
158
|
-
chainId = await getAction(client, getChainId)({})
|
158
|
+
chainId = await getAction(client, getChainId, 'getChainId')({})
|
159
159
|
assertCurrentChain({
|
160
160
|
currentChainId: chainId,
|
161
161
|
chain,
|
@@ -167,6 +167,7 @@ export async function sendTransaction<
|
|
167
167
|
const request = await getAction(
|
168
168
|
client,
|
169
169
|
prepareTransactionRequest,
|
170
|
+
'prepareTransactionRequest',
|
170
171
|
)({
|
171
172
|
account,
|
172
173
|
accessList,
|
@@ -182,7 +183,8 @@ export async function sendTransaction<
|
|
182
183
|
...rest,
|
183
184
|
} as any)
|
184
185
|
|
185
|
-
if (!chainId)
|
186
|
+
if (!chainId)
|
187
|
+
chainId = await getAction(client, getChainId, 'getChainId')({})
|
186
188
|
|
187
189
|
const serializer = chain?.serializers?.transaction
|
188
190
|
const serializedTransaction = (await account.signTransaction(
|
@@ -195,6 +197,7 @@ export async function sendTransaction<
|
|
195
197
|
return await getAction(
|
196
198
|
client,
|
197
199
|
sendRawTransaction,
|
200
|
+
'sendRawTransaction',
|
198
201
|
)({
|
199
202
|
serializedTransaction,
|
200
203
|
})
|
@@ -128,7 +128,7 @@ export async function signTransaction<
|
|
128
128
|
...args,
|
129
129
|
})
|
130
130
|
|
131
|
-
const chainId = await getAction(client, getChainId)({})
|
131
|
+
const chainId = await getAction(client, getChainId, 'getChainId')({})
|
132
132
|
if (chain !== null)
|
133
133
|
assertCurrentChain({
|
134
134
|
currentChainId: chainId,
|
package/clients/createClient.ts
CHANGED
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '1.19.
|
1
|
+
export const version = '1.19.2'
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "viem",
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
4
|
-
"version": "1.19.
|
4
|
+
"version": "1.19.3",
|
5
5
|
"main": "./_cjs/index.js",
|
6
6
|
"module": "./_esm/index.js",
|
7
7
|
"types": "./_types/index.d.ts",
|
@@ -133,7 +133,7 @@
|
|
133
133
|
}
|
134
134
|
},
|
135
135
|
"dependencies": {
|
136
|
-
"@adraffy/ens-normalize": "1.
|
136
|
+
"@adraffy/ens-normalize": "1.10.0",
|
137
137
|
"@noble/curves": "1.2.0",
|
138
138
|
"@noble/hashes": "1.3.2",
|
139
139
|
"@scure/bip32": "1.3.2",
|
package/types/ens.ts
CHANGED
package/utils/encoding/toRlp.ts
CHANGED
@@ -88,7 +88,9 @@ function getEncodableList(list: Encodable[]): Encodable {
|
|
88
88
|
else if (sizeOfBodyLength === 3) cursor.pushUint24(bodyLength)
|
89
89
|
else cursor.pushUint32(bodyLength)
|
90
90
|
}
|
91
|
-
|
91
|
+
for (const { encode } of list) {
|
92
|
+
encode(cursor)
|
93
|
+
}
|
92
94
|
},
|
93
95
|
}
|
94
96
|
}
|
@@ -28,7 +28,7 @@ export type FormattedBlock<
|
|
28
28
|
_ExcludedPendingDependencies extends string = BlockPendingDependencies &
|
29
29
|
ExtractChainFormatterExclude<TChain, 'block'>,
|
30
30
|
_Formatted = Omit<_FormatterReturnType, BlockPendingDependencies> & {
|
31
|
-
[
|
31
|
+
[_key in _ExcludedPendingDependencies]: never
|
32
32
|
} & Pick<
|
33
33
|
Block<bigint, TIncludeTransactions, TBlockTag>,
|
34
34
|
BlockPendingDependencies
|
@@ -31,7 +31,7 @@ export function defineFormatter<TType extends string, TParameters, TReturnType>(
|
|
31
31
|
...formatted,
|
32
32
|
...overrides(args),
|
33
33
|
} as Prettify<Assign<TReturnType, TOverrideReturnType>> & {
|
34
|
-
[
|
34
|
+
[_key in TExclude[number]]: never
|
35
35
|
}
|
36
36
|
},
|
37
37
|
type,
|