viem 0.0.0-main.20231114T205321 → 0.0.0-main.20231115T212800
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 +6 -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 +5 -5
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +5 -5
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/actions/public/watchPendingTransactions.js +3 -3
- 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/version.js +1 -1
- package/_cjs/utils/getAction.js +2 -2
- package/_cjs/utils/getAction.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 +5 -5
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +5 -5
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/actions/public/watchPendingTransactions.js +3 -3
- 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/version.js +1 -1
- package/_esm/utils/getAction.js +12 -2
- package/_esm/utils/getAction.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.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/errors/version.d.ts +1 -1
- package/_types/utils/getAction.d.ts +8 -1
- package/_types/utils/getAction.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 +7 -0
- 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 +18 -3
- package/actions/public/watchEvent.ts +18 -3
- package/actions/public/watchPendingTransactions.ts +12 -2
- 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/errors/version.ts +1 -1
- package/package.json +1 -1
- package/utils/getAction.ts +11 -1
@@ -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,
|
@@ -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,
|
@@ -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,7 +138,11 @@ 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
148
|
else for (const hash of hashes) emit.onTransactions([hash])
|
@@ -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/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20231115T212800'
|
package/package.json
CHANGED
package/utils/getAction.ts
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
import type { Client } from '../clients/createClient.js'
|
2
2
|
|
3
|
+
/**
|
4
|
+
* Retrieves and returns an action from the client (if exists), and falls
|
5
|
+
* back to the tree-shakable action.
|
6
|
+
*
|
7
|
+
* Useful for extracting overridden actions from a client (ie. if a consumer
|
8
|
+
* wants to override the `sendTransaction` implementation).
|
9
|
+
*/
|
3
10
|
export function getAction<params extends {}, returnType extends {}>(
|
4
11
|
client: Client,
|
5
12
|
action: (_: any, params: params) => returnType,
|
13
|
+
// Some minifiers drop `Function.prototype.name`, meaning that `action.name`
|
14
|
+
// will not work. For that case, the consumer needs to pass the name explicitly.
|
15
|
+
name: string,
|
6
16
|
) {
|
7
17
|
return (params: params): returnType =>
|
8
18
|
(
|
9
19
|
client as Client & {
|
10
20
|
[key: string]: (params: params) => returnType
|
11
21
|
}
|
12
|
-
)[action.name]?.(params) ?? action(client, params)
|
22
|
+
)[action.name || name]?.(params) ?? action(client, params)
|
13
23
|
}
|