viem 2.57.12 → 2.57.13
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 +18 -0
- package/_cjs/actions/public/fillTransaction.js +6 -3
- package/_cjs/actions/public/fillTransaction.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +58 -29
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +58 -29
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/chains/definitions/molibra.js +21 -0
- package/_cjs/chains/definitions/molibra.js.map +1 -0
- package/_cjs/chains/index.js +9 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Account.js +4 -4
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Formatters.js +13 -2
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Relay.js.map +1 -1
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/accounts/Config.js +21 -8
- package/_cjs/tempo/accounts/Config.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +11 -4
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/relay/accounts.js +41 -4
- package/_cjs/tempo/internal/relay/accounts.js.map +1 -1
- package/_cjs/tempo/internal/relay/feePayer.js +4 -1
- package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/actions/public/fillTransaction.js +8 -3
- package/_esm/actions/public/fillTransaction.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +73 -36
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +73 -36
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/chains/definitions/molibra.js +18 -0
- package/_esm/chains/definitions/molibra.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Account.js +4 -4
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Formatters.js +12 -2
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Relay.js.map +1 -1
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/accounts/Config.js +27 -12
- package/_esm/tempo/accounts/Config.js.map +1 -1
- package/_esm/tempo/chainConfig.js +13 -4
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/relay/accounts.js +43 -4
- package/_esm/tempo/internal/relay/accounts.js.map +1 -1
- package/_esm/tempo/internal/relay/feePayer.js +4 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_types/actions/getContract.d.ts +1 -1
- package/_types/actions/public/fillTransaction.d.ts.map +1 -1
- package/_types/actions/public/watchContractEvent.d.ts +1 -1
- package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.d.ts +1 -1
- package/_types/actions/public/watchEvent.d.ts.map +1 -1
- package/_types/chains/definitions/molibra.d.ts +52 -0
- package/_types/chains/definitions/molibra.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +14 -6
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +14 -6
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +14 -6
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +14 -6
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +2 -2
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Account.d.ts +14 -0
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts +3 -0
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Relay.d.ts +20 -0
- package/_types/tempo/Relay.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +7 -2
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/accounts/Config.d.ts +24 -2
- package/_types/tempo/accounts/Config.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +8 -3
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/relay/accounts.d.ts.map +1 -1
- package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
- package/actions/getContract.ts +1 -1
- package/actions/public/fillTransaction.ts +12 -3
- package/actions/public/watchContractEvent.ts +82 -39
- package/actions/public/watchEvent.ts +82 -39
- package/chains/definitions/molibra.ts +18 -0
- package/chains/index.ts +1 -0
- package/clients/decorators/public.ts +2 -2
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Account.ts +18 -8
- package/tempo/Formatters.ts +19 -7
- package/tempo/Relay.ts +26 -0
- package/tempo/Transaction.ts +10 -2
- package/tempo/accounts/Config.ts +39 -16
- package/tempo/chainConfig.ts +15 -4
- package/tempo/internal/relay/accounts.ts +44 -6
- package/tempo/internal/relay/feePayer.ts +6 -1
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
DecodeLogDataMismatch,
|
|
7
7
|
DecodeLogTopicsMismatch,
|
|
8
8
|
} from '../../errors/abi.js'
|
|
9
|
+
import { BaseError } from '../../errors/base.js'
|
|
10
|
+
import { HttpRequestError, RpcRequestError } from '../../errors/request.js'
|
|
9
11
|
import { InvalidInputRpcError } from '../../errors/rpc.js'
|
|
10
12
|
import type { ErrorType } from '../../errors/utils.js'
|
|
11
13
|
import type { BlockNumber } from '../../types/block.js'
|
|
@@ -106,7 +108,7 @@ export type WatchContractEventErrorType =
|
|
|
106
108
|
*
|
|
107
109
|
* This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
|
|
108
110
|
*
|
|
109
|
-
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
|
111
|
+
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchContractEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
|
|
110
112
|
*
|
|
111
113
|
* @param client - Client to use
|
|
112
114
|
* @param parameters - {@link WatchContractEventParameters}
|
|
@@ -185,11 +187,34 @@ export function watchContractEvent<
|
|
|
185
187
|
])
|
|
186
188
|
|
|
187
189
|
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
+
let active = true
|
|
191
|
+
let previousBlockNumber =
|
|
192
|
+
fromBlock === undefined ? undefined : fromBlock - 1n
|
|
190
193
|
let filter: Filter<'event', abi, eventName> | undefined
|
|
191
194
|
let initialized = false
|
|
192
195
|
|
|
196
|
+
const emitLogs = (logs: Log[]) => {
|
|
197
|
+
if (logs.length === 0) return
|
|
198
|
+
if (batch) emit.onLogs(logs as any)
|
|
199
|
+
else for (const log of logs) emit.onLogs([log] as any)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Fetches the logs of the blocks from `from` to `to`, inclusive.
|
|
203
|
+
const getLogsInRange = (from: bigint, to: bigint) =>
|
|
204
|
+
getAction(
|
|
205
|
+
client,
|
|
206
|
+
getContractEvents,
|
|
207
|
+
'getContractEvents',
|
|
208
|
+
)({
|
|
209
|
+
abi,
|
|
210
|
+
address,
|
|
211
|
+
args,
|
|
212
|
+
eventName,
|
|
213
|
+
fromBlock: from,
|
|
214
|
+
toBlock: to,
|
|
215
|
+
strict,
|
|
216
|
+
} as {} as GetContractEventsParameters)
|
|
217
|
+
|
|
193
218
|
const unwatch = poll(
|
|
194
219
|
async () => {
|
|
195
220
|
if (!initialized) {
|
|
@@ -208,54 +233,55 @@ export function watchContractEvent<
|
|
|
208
233
|
})) as Filter<'event', abi, eventName>
|
|
209
234
|
} catch {}
|
|
210
235
|
initialized = true
|
|
211
|
-
return
|
|
236
|
+
if (filter) return
|
|
212
237
|
}
|
|
213
238
|
|
|
214
239
|
try {
|
|
215
|
-
let logs: Log[]
|
|
216
240
|
if (filter) {
|
|
217
|
-
logs = await getAction(
|
|
241
|
+
const logs = await getAction(
|
|
218
242
|
client,
|
|
219
243
|
getFilterChanges,
|
|
220
244
|
'getFilterChanges',
|
|
221
245
|
)({ filter })
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
246
|
+
emitLogs(logs)
|
|
247
|
+
return
|
|
248
|
+
}
|
|
225
249
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
250
|
+
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
|
251
|
+
// The fall back exists because some RPC Providers do not support filters.
|
|
252
|
+
const blockNumber = await getAction(
|
|
253
|
+
client,
|
|
254
|
+
getBlockNumber,
|
|
255
|
+
'getBlockNumber',
|
|
256
|
+
)({})
|
|
232
257
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
258
|
+
// Without `fromBlock`, start watching from the current block.
|
|
259
|
+
previousBlockNumber ??= blockNumber
|
|
260
|
+
|
|
261
|
+
// RPC Providers limit `eth_getLogs` by block range, log count or response
|
|
262
|
+
// size. `size` is the most blocks to request at once: it starts with all
|
|
263
|
+
// new blocks and halves whenever a request fails.
|
|
264
|
+
let size = blockNumber - previousBlockNumber
|
|
265
|
+
while (previousBlockNumber < blockNumber) {
|
|
266
|
+
const from = previousBlockNumber + 1n
|
|
267
|
+
const end: bigint = previousBlockNumber + size
|
|
268
|
+
const to = end < blockNumber ? end : blockNumber
|
|
269
|
+
|
|
270
|
+
const logs = await getLogsInRange(from, to).catch((error) => {
|
|
271
|
+
// A single block cannot be split, and a smaller range does not
|
|
272
|
+
// help when the RPC Provider is unreachable or rejects the client.
|
|
273
|
+
if (from === to || !isRangeError(error)) throw error
|
|
274
|
+
})
|
|
275
|
+
if (!active) return
|
|
276
|
+
if (!logs) {
|
|
277
|
+
size = (to - from + 1n) / 2n
|
|
278
|
+
continue
|
|
252
279
|
}
|
|
253
|
-
previousBlockNumber = blockNumber
|
|
254
|
-
}
|
|
255
280
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
281
|
+
// Only move past blocks whose logs were fetched, so none are skipped.
|
|
282
|
+
previousBlockNumber = to
|
|
283
|
+
emitLogs(logs)
|
|
284
|
+
}
|
|
259
285
|
} catch (err) {
|
|
260
286
|
// If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
|
|
261
287
|
// Reinitialize the filter when this occurs
|
|
@@ -271,6 +297,7 @@ export function watchContractEvent<
|
|
|
271
297
|
)
|
|
272
298
|
|
|
273
299
|
return async () => {
|
|
300
|
+
active = false
|
|
274
301
|
if (filter)
|
|
275
302
|
await getAction(
|
|
276
303
|
client,
|
|
@@ -377,3 +404,19 @@ export function watchContractEvent<
|
|
|
377
404
|
|
|
378
405
|
return enablePolling ? pollContractEvent() : subscribeContractEvent()
|
|
379
406
|
}
|
|
407
|
+
|
|
408
|
+
/** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
|
|
409
|
+
function isRangeError(error: unknown) {
|
|
410
|
+
if (!(error instanceof BaseError)) return true
|
|
411
|
+
const cause = error.walk(
|
|
412
|
+
(err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
|
|
413
|
+
) as HttpRequestError | RpcRequestError | null
|
|
414
|
+
if (!cause) return true
|
|
415
|
+
// Rate limited.
|
|
416
|
+
if (cause instanceof RpcRequestError && cause.code === 429) return false
|
|
417
|
+
// Unreachable.
|
|
418
|
+
if (cause instanceof HttpRequestError && cause.status === undefined)
|
|
419
|
+
return false
|
|
420
|
+
// Unauthorized, forbidden or rate limited.
|
|
421
|
+
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
|
|
422
|
+
}
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
DecodeLogDataMismatch,
|
|
7
7
|
DecodeLogTopicsMismatch,
|
|
8
8
|
} from '../../errors/abi.js'
|
|
9
|
+
import { BaseError } from '../../errors/base.js'
|
|
10
|
+
import { HttpRequestError, RpcRequestError } from '../../errors/request.js'
|
|
9
11
|
import { InvalidInputRpcError } from '../../errors/rpc.js'
|
|
10
12
|
import type { ErrorType } from '../../errors/utils.js'
|
|
11
13
|
import type { BlockNumber } from '../../types/block.js'
|
|
@@ -128,7 +130,7 @@ export type WatchEventErrorType =
|
|
|
128
130
|
*
|
|
129
131
|
* This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent#onLogs).
|
|
130
132
|
*
|
|
131
|
-
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
|
133
|
+
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
|
|
132
134
|
*
|
|
133
135
|
* @param client - Client to use
|
|
134
136
|
* @param parameters - {@link WatchEventParameters}
|
|
@@ -206,11 +208,34 @@ export function watchEvent<
|
|
|
206
208
|
])
|
|
207
209
|
|
|
208
210
|
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
209
|
-
let
|
|
210
|
-
|
|
211
|
+
let active = true
|
|
212
|
+
let previousBlockNumber =
|
|
213
|
+
fromBlock === undefined ? undefined : fromBlock - 1n
|
|
211
214
|
let filter: Filter<'event', abiEvents, _eventName, any>
|
|
212
215
|
let initialized = false
|
|
213
216
|
|
|
217
|
+
const emitLogs = (logs: Log[]) => {
|
|
218
|
+
if (logs.length === 0) return
|
|
219
|
+
if (batch) emit.onLogs(logs as any)
|
|
220
|
+
else for (const log of logs) emit.onLogs([log] as any)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Fetches the logs of the blocks from `from` to `to`, inclusive.
|
|
224
|
+
const getLogsInRange = (from: bigint, to: bigint) =>
|
|
225
|
+
getAction(
|
|
226
|
+
client,
|
|
227
|
+
getLogs,
|
|
228
|
+
'getLogs',
|
|
229
|
+
)({
|
|
230
|
+
address,
|
|
231
|
+
args,
|
|
232
|
+
event: event!,
|
|
233
|
+
events,
|
|
234
|
+
fromBlock: from,
|
|
235
|
+
strict,
|
|
236
|
+
toBlock: to,
|
|
237
|
+
} as unknown as GetLogsParameters)
|
|
238
|
+
|
|
214
239
|
const unwatch = poll(
|
|
215
240
|
async () => {
|
|
216
241
|
if (!initialized) {
|
|
@@ -233,54 +258,55 @@ export function watchEvent<
|
|
|
233
258
|
>
|
|
234
259
|
} catch {}
|
|
235
260
|
initialized = true
|
|
236
|
-
return
|
|
261
|
+
if (filter) return
|
|
237
262
|
}
|
|
238
263
|
|
|
239
264
|
try {
|
|
240
|
-
let logs: Log[]
|
|
241
265
|
if (filter) {
|
|
242
|
-
logs = await getAction(
|
|
266
|
+
const logs = await getAction(
|
|
243
267
|
client,
|
|
244
268
|
getFilterChanges,
|
|
245
269
|
'getFilterChanges',
|
|
246
270
|
)({ filter })
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
271
|
+
emitLogs(logs)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
250
274
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
275
|
+
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
|
276
|
+
// The fall back exists because some RPC Providers do not support filters.
|
|
277
|
+
const blockNumber = await getAction(
|
|
278
|
+
client,
|
|
279
|
+
getBlockNumber,
|
|
280
|
+
'getBlockNumber',
|
|
281
|
+
)({})
|
|
282
|
+
|
|
283
|
+
// Without `fromBlock`, start watching from the current block.
|
|
284
|
+
previousBlockNumber ??= blockNumber
|
|
257
285
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
logs = []
|
|
286
|
+
// RPC Providers limit `eth_getLogs` by block range, log count or response
|
|
287
|
+
// size. `size` is the most blocks to request at once: it starts with all
|
|
288
|
+
// new blocks and halves whenever a request fails.
|
|
289
|
+
let size = blockNumber - previousBlockNumber
|
|
290
|
+
while (previousBlockNumber < blockNumber) {
|
|
291
|
+
const from = previousBlockNumber + 1n
|
|
292
|
+
const end: bigint = previousBlockNumber + size
|
|
293
|
+
const to = end < blockNumber ? end : blockNumber
|
|
294
|
+
|
|
295
|
+
const logs = await getLogsInRange(from, to).catch((error) => {
|
|
296
|
+
// A single block cannot be split, and a smaller range does not
|
|
297
|
+
// help when the RPC Provider is unreachable or rejects the client.
|
|
298
|
+
if (from === to || !isRangeError(error)) throw error
|
|
299
|
+
})
|
|
300
|
+
if (!active) return
|
|
301
|
+
if (!logs) {
|
|
302
|
+
size = (to - from + 1n) / 2n
|
|
303
|
+
continue
|
|
277
304
|
}
|
|
278
|
-
previousBlockNumber = blockNumber
|
|
279
|
-
}
|
|
280
305
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
306
|
+
// Only move past blocks whose logs were fetched, so none are skipped.
|
|
307
|
+
previousBlockNumber = to
|
|
308
|
+
emitLogs(logs)
|
|
309
|
+
}
|
|
284
310
|
} catch (err) {
|
|
285
311
|
// If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
|
|
286
312
|
// Reinitialize the filter when this occurs
|
|
@@ -296,6 +322,7 @@ export function watchEvent<
|
|
|
296
322
|
)
|
|
297
323
|
|
|
298
324
|
return async () => {
|
|
325
|
+
active = false
|
|
299
326
|
if (filter)
|
|
300
327
|
await getAction(
|
|
301
328
|
client,
|
|
@@ -392,3 +419,19 @@ export function watchEvent<
|
|
|
392
419
|
|
|
393
420
|
return enablePolling ? pollEvent() : subscribeEvent()
|
|
394
421
|
}
|
|
422
|
+
|
|
423
|
+
/** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
|
|
424
|
+
function isRangeError(error: unknown) {
|
|
425
|
+
if (!(error instanceof BaseError)) return true
|
|
426
|
+
const cause = error.walk(
|
|
427
|
+
(err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
|
|
428
|
+
) as HttpRequestError | RpcRequestError | null
|
|
429
|
+
if (!cause) return true
|
|
430
|
+
// Rate limited.
|
|
431
|
+
if (cause instanceof RpcRequestError && cause.code === 429) return false
|
|
432
|
+
// Unreachable.
|
|
433
|
+
if (cause instanceof HttpRequestError && cause.status === undefined)
|
|
434
|
+
return false
|
|
435
|
+
// Unauthorized, forbidden or rate limited.
|
|
436
|
+
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
|
|
437
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const molibra = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 20226,
|
|
5
|
+
name: 'Molibra',
|
|
6
|
+
nativeCurrency: { name: 'Molibra', symbol: 'MOLI', decimals: 18 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: {
|
|
9
|
+
http: ['https://molibra.org'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
blockExplorers: {
|
|
13
|
+
default: {
|
|
14
|
+
name: 'Moliscan',
|
|
15
|
+
url: 'https://molibra.org/molibra/moliscan',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})
|
package/chains/index.ts
CHANGED
|
@@ -434,6 +434,7 @@ export { mitosisTestnet } from './definitions/mitosisTestnet.js'
|
|
|
434
434
|
export { mizuhikiTestnetAwaji } from './definitions/mizuhikiTestnetAwaji.js'
|
|
435
435
|
export { mode } from './definitions/mode.js'
|
|
436
436
|
export { modeTestnet } from './definitions/modeTestnet.js'
|
|
437
|
+
export { molibra } from './definitions/molibra.js'
|
|
437
438
|
export { monad } from './definitions/monad.js'
|
|
438
439
|
export { monadTestnet } from './definitions/monadTestnet.js'
|
|
439
440
|
export { moonbaseAlpha } from './definitions/moonbaseAlpha.js'
|
|
@@ -2083,7 +2083,7 @@ export type PublicActions<
|
|
|
2083
2083
|
* @remarks
|
|
2084
2084
|
* This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
|
|
2085
2085
|
*
|
|
2086
|
-
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
|
2086
|
+
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchContractEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
|
|
2087
2087
|
*
|
|
2088
2088
|
* @param args - {@link WatchContractEventParameters}
|
|
2089
2089
|
* @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}
|
|
@@ -2125,7 +2125,7 @@ export type PublicActions<
|
|
|
2125
2125
|
* @remarks
|
|
2126
2126
|
* This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent#onLogs).
|
|
2127
2127
|
*
|
|
2128
|
-
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
|
2128
|
+
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead. If `getLogs` fails for a block range, `watchEvent` will retry with smaller block ranges and may call `onLogs` more than once per polling interval.
|
|
2129
2129
|
*
|
|
2130
2130
|
* @param args - {@link WatchEventParameters}
|
|
2131
2131
|
* @returns A function that can be invoked to stop watching for new Event Logs. {@link WatchEventReturnType}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.57.
|
|
1
|
+
export const version = '2.57.13'
|
package/package.json
CHANGED
package/tempo/Account.ts
CHANGED
|
@@ -294,6 +294,14 @@ export declare namespace fromSecp256k1 {
|
|
|
294
294
|
* Normalizes supplied config fields with `AccountConfig.from`, so callers do
|
|
295
295
|
* not need to normalize owner ordering themselves.
|
|
296
296
|
*
|
|
297
|
+
* `sign`, `signMessage`, and `signTypedData` return a configurable signature
|
|
298
|
+
* envelope with local owner approvals up to the config threshold. Signatures
|
|
299
|
+
* verify against the account's current config, so a config update invalidates
|
|
300
|
+
* earlier signatures. Verify them with `verifyHash`, `verifyMessage`, or
|
|
301
|
+
* `verifyTypedData` on a Tempo client, which use the signature verifier
|
|
302
|
+
* precompile. Configurable accounts have no code and do not implement ERC-1271
|
|
303
|
+
* `isValidSignature`, so ERC-1271 verifiers do not accept their signatures.
|
|
304
|
+
*
|
|
297
305
|
* @example
|
|
298
306
|
* ```ts
|
|
299
307
|
* import { Account } from 'viem/tempo'
|
|
@@ -406,10 +414,8 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
|
|
|
406
414
|
await signConfigurable(account, { payload: hash }),
|
|
407
415
|
)
|
|
408
416
|
},
|
|
409
|
-
async signMessage() {
|
|
410
|
-
|
|
411
|
-
'`signMessage` is not supported for configurable accounts.',
|
|
412
|
-
)
|
|
417
|
+
async signMessage({ message }) {
|
|
418
|
+
return await account.sign({ hash: hashMessage(message) })
|
|
413
419
|
},
|
|
414
420
|
async signTransaction(transaction, options) {
|
|
415
421
|
const { serializer = Transaction.serialize } = options ?? {}
|
|
@@ -456,10 +462,8 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
|
|
|
456
462
|
signature as never,
|
|
457
463
|
)) as Hex.Hex
|
|
458
464
|
},
|
|
459
|
-
async signTypedData() {
|
|
460
|
-
|
|
461
|
-
'`signTypedData` is not supported for configurable accounts.',
|
|
462
|
-
)
|
|
465
|
+
async signTypedData(typedData) {
|
|
466
|
+
return await account.sign({ hash: hashTypedData(typedData) })
|
|
463
467
|
},
|
|
464
468
|
}
|
|
465
469
|
return account
|
|
@@ -528,6 +532,12 @@ export declare namespace fromConfig {
|
|
|
528
532
|
}
|
|
529
533
|
}
|
|
530
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Configurable account (TIP-1107) returned by {@link fromConfig}.
|
|
537
|
+
*
|
|
538
|
+
* Its signatures verify against the account's current config through Tempo's
|
|
539
|
+
* `verifyHash`, not ERC-1271, and a config update invalidates earlier signatures.
|
|
540
|
+
*/
|
|
531
541
|
export type ConfigurableAccount<
|
|
532
542
|
config extends AccountConfig.Config | undefined =
|
|
533
543
|
| AccountConfig.Config
|
package/tempo/Formatters.ts
CHANGED
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
} from 'ox/tempo'
|
|
10
10
|
import type { Account as viem_Account } from '../accounts/types.js'
|
|
11
11
|
import { parseAccount } from '../accounts/utils/parseAccount.js'
|
|
12
|
+
import type { Block } from '../types/block.js'
|
|
13
|
+
import type { RpcBlock } from '../types/rpc.js'
|
|
14
|
+
import { formatBlock as viem_formatBlock } from '../utils/formatters/block.js'
|
|
12
15
|
import { formatTransaction as viem_formatTransaction } from '../utils/formatters/transaction.js'
|
|
13
16
|
import { formatTransactionReceipt as viem_formatTransactionReceipt } from '../utils/formatters/transactionReceipt.js'
|
|
14
17
|
import { formatTransactionRequest as viem_formatTransactionRequest } from '../utils/formatters/transactionRequest.js'
|
|
@@ -23,6 +26,18 @@ import {
|
|
|
23
26
|
type TransactionRpc,
|
|
24
27
|
} from './Transaction.js'
|
|
25
28
|
|
|
29
|
+
export function formatBlock(block: RpcBlock): Block {
|
|
30
|
+
const { transactions = [], ...rest } = block
|
|
31
|
+
return {
|
|
32
|
+
...viem_formatBlock({ ...rest, transactions: [] }),
|
|
33
|
+
transactions: transactions.map((transaction) =>
|
|
34
|
+
typeof transaction === 'string'
|
|
35
|
+
? transaction
|
|
36
|
+
: formatTransaction(transaction as never),
|
|
37
|
+
),
|
|
38
|
+
} as never
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
export function formatTransaction(
|
|
27
42
|
transaction: TransactionRpc,
|
|
28
43
|
): Transaction<bigint, number, boolean> {
|
|
@@ -34,12 +49,9 @@ export function formatTransaction(
|
|
|
34
49
|
? undefined
|
|
35
50
|
: BigInt(transaction.blockTimestamp)
|
|
36
51
|
const operation = transaction.operation
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nonce,
|
|
41
|
-
...tx
|
|
42
|
-
} = ox_Transaction.fromRpc(transaction as never) as ox_Transaction.Tempo
|
|
52
|
+
const { feePayerSignature, nonce, ...tx } = ox_Transaction.fromRpc(
|
|
53
|
+
transaction as never,
|
|
54
|
+
) as ox_Transaction.Tempo
|
|
43
55
|
|
|
44
56
|
return {
|
|
45
57
|
...tx,
|
|
@@ -53,7 +65,7 @@ export function formatTransaction(
|
|
|
53
65
|
yParity: feePayerSignature.yParity,
|
|
54
66
|
}
|
|
55
67
|
: undefined,
|
|
56
|
-
nonce:
|
|
68
|
+
nonce: nonce ?? 0n,
|
|
57
69
|
operation: formatOperation(operation),
|
|
58
70
|
typeHex:
|
|
59
71
|
ox_Transaction.toRpcType[
|
package/tempo/Relay.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Address } from 'abitype'
|
|
2
|
+
import type * as Hex from 'ox/Hex'
|
|
2
3
|
import * as RpcResponse from 'ox/RpcResponse'
|
|
4
|
+
import type { AccountConfig } from 'ox/tempo'
|
|
3
5
|
import type { LocalAccount } from '../accounts/types.js'
|
|
4
6
|
import type { Client as Client_ } from '../clients/createClient.js'
|
|
5
7
|
import { ChainNotConfiguredError } from '../clients/createClientResolver.js'
|
|
6
8
|
import type { EIP1193RequestOptions } from '../types/eip1193.js'
|
|
9
|
+
import type { MaybePromise } from '../types/utils.js'
|
|
7
10
|
import * as Accounts from './internal/relay/accounts.js'
|
|
8
11
|
import * as Sponsorship from './internal/relay/feePayer.js'
|
|
9
12
|
import * as FeeToken from './internal/relay/feeToken.js'
|
|
@@ -342,9 +345,32 @@ export function accounts(options: accounts.Options): accounts.ReturnType {
|
|
|
342
345
|
export declare namespace accounts {
|
|
343
346
|
/** Configurable account options. */
|
|
344
347
|
export type Options = {
|
|
348
|
+
/**
|
|
349
|
+
* Resolves a config that `store` does not hold, such as from an indexer of
|
|
350
|
+
* `ConfigurableAccountConfigUpdated` events. The plugin stores and returns
|
|
351
|
+
* a resolved config only when it matches the account and commitment.
|
|
352
|
+
*/
|
|
353
|
+
resolveConfig?:
|
|
354
|
+
| ((
|
|
355
|
+
options: resolveConfig.Options,
|
|
356
|
+
) => MaybePromise<AccountConfig.Config | null | undefined>)
|
|
357
|
+
| undefined
|
|
345
358
|
/** Store shared by relays, with atomic compare-and-set support. */
|
|
346
359
|
store: Store.Atomic
|
|
347
360
|
}
|
|
361
|
+
|
|
362
|
+
export namespace resolveConfig {
|
|
363
|
+
/** Lookup that `resolveConfig` receives. */
|
|
364
|
+
export type Options = {
|
|
365
|
+
/** Configurable account address. */
|
|
366
|
+
address: Address
|
|
367
|
+
/** Chain whose commitment the config must match. */
|
|
368
|
+
chainId: number
|
|
369
|
+
/** Config commitment read from the chain. */
|
|
370
|
+
commitment: Hex.Hex
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
348
374
|
/** Middleware advertising configurable account support. */
|
|
349
375
|
export type ReturnType = Plugin & { readonly [accountsBrand]: true }
|
|
350
376
|
}
|
package/tempo/Transaction.ts
CHANGED
|
@@ -72,7 +72,10 @@ export type TransactionTempo<
|
|
|
72
72
|
isPending extends boolean = boolean,
|
|
73
73
|
type = 'tempo',
|
|
74
74
|
> = PartialBy<
|
|
75
|
-
Omit<
|
|
75
|
+
Omit<
|
|
76
|
+
TransactionBase<quantity, index, isPending>,
|
|
77
|
+
'input' | 'nonce' | 'value' | 'to'
|
|
78
|
+
>,
|
|
76
79
|
'r' | 's' | 'v' | 'yParity'
|
|
77
80
|
> & {
|
|
78
81
|
accessList: AccessList
|
|
@@ -83,12 +86,17 @@ export type TransactionTempo<
|
|
|
83
86
|
feePayerSignature?: viem_Signature | undefined
|
|
84
87
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | null | undefined
|
|
85
88
|
operation?: AccountOperation.TransactionOperation | undefined
|
|
89
|
+
/** Sequence number, or for expiring nonce transactions (TIP-1106) an opaque `uint64` discriminator, often above `Number.MAX_SAFE_INTEGER`. */
|
|
90
|
+
nonce: quantity
|
|
86
91
|
nonceKey?: quantity | undefined
|
|
87
92
|
signature: SignatureEnvelope.SignatureEnvelope
|
|
88
93
|
type: type
|
|
89
94
|
validBefore?: index | undefined
|
|
90
95
|
validAfter?: index | undefined
|
|
91
|
-
} & FeeValuesEIP1559<quantity>
|
|
96
|
+
} & Omit<FeeValuesEIP1559<quantity>, 'gasPrice'> & {
|
|
97
|
+
/** Effective gas price the transaction paid, once included. */
|
|
98
|
+
gasPrice?: quantity | undefined
|
|
99
|
+
}
|
|
92
100
|
|
|
93
101
|
export type TransactionRequest<
|
|
94
102
|
bigintType = bigint,
|