viem 2.57.17 → 2.57.18
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 +80 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
- package/_cjs/actions/ens/getEnsAddress.js +11 -1
- package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/_cjs/actions/index.js +5 -3
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/call.js +13 -2
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/getLogs.js +18 -1
- package/_cjs/actions/public/getLogs.js.map +1 -1
- package/_cjs/actions/public/internal/isRangeError.js +18 -0
- package/_cjs/actions/public/internal/isRangeError.js.map +1 -0
- package/_cjs/actions/public/internal/watchTransport.js +24 -0
- package/_cjs/actions/public/internal/watchTransport.js.map +1 -0
- package/_cjs/actions/public/iterateLogs.js +48 -0
- package/_cjs/actions/public/iterateLogs.js.map +1 -0
- package/_cjs/actions/public/simulateContract.js +4 -4
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/public/verifyHash.js +72 -39
- package/_cjs/actions/public/verifyHash.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +18 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/actions/public/watchBlockHeaders.js +2 -10
- package/_cjs/actions/public/watchBlockHeaders.js.map +1 -1
- package/_cjs/actions/public/watchBlockNumber.js +3 -18
- package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/_cjs/actions/public/watchBlocks.js +3 -18
- package/_cjs/actions/public/watchBlocks.js.map +1 -1
- package/_cjs/actions/public/watchContractEvent.js +5 -33
- package/_cjs/actions/public/watchContractEvent.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +5 -33
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +16 -3
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/celo/serializers.js +1 -1
- package/_cjs/celo/serializers.js.map +1 -1
- package/_cjs/clients/decorators/public.js +2 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/constants/contracts.js +1 -1
- package/_cjs/constants/contracts.js.map +1 -1
- package/_cjs/errors/chain.js +2 -2
- package/_cjs/errors/chain.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +5 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/actions/buildProveWithdrawal.js +5 -5
- package/_cjs/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_cjs/op-stack/actions/getL2Output.js +13 -9
- package/_cjs/op-stack/actions/getL2Output.js.map +1 -1
- package/_cjs/op-stack/actions/waitToProve.js +1 -0
- package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
- package/_cjs/tempo/Account.js +30 -0
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +1 -1
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js +5 -5
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +1 -1
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +3 -3
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +1 -1
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/token.js +10 -2
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +14 -0
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/preAuthorized.js +214 -0
- package/_cjs/tempo/internal/preAuthorized.js.map +1 -0
- package/_cjs/tempo/internal/relay/feePayer.js +25 -7
- package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
- package/_cjs/utils/abi/decodeAbiParameters.js +33 -9
- package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_cjs/utils/abi/encodeAbiParameters.js +5 -4
- package/_cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_cjs/utils/abi/encodePacked.js +4 -2
- package/_cjs/utils/abi/encodePacked.js.map +1 -1
- package/_cjs/utils/ccip.js +5 -1
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/chain/getChainContractAddress.js +2 -2
- package/_cjs/utils/chain/getChainContractAddress.js.map +1 -1
- package/_cjs/utils/encoding/toBytes.js +5 -6
- package/_cjs/utils/encoding/toBytes.js.map +1 -1
- package/_cjs/utils/ens/avatar/utils.js +25 -5
- package/_cjs/utils/ens/avatar/utils.js.map +1 -1
- package/_cjs/utils/ens/localBatchGatewayRequest.js +13 -1
- package/_cjs/utils/ens/localBatchGatewayRequest.js.map +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/_cjs/utils/siwe/validateSiweMessage.js +5 -0
- package/_cjs/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_cjs/zksync/actions/estimateFee.js +1 -1
- package/_cjs/zksync/actions/estimateFee.js.map +1 -1
- package/_cjs/zksync/actions/estimateGasL1ToL2.js +1 -1
- package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -1
- package/_cjs/zksync/actions/finalizeWithdrawal.js +3 -3
- package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_cjs/zksync/actions/sendEip712Transaction.js +10 -2
- package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_cjs/zksync/actions/signEip712Transaction.js +2 -2
- package/_cjs/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +4 -2
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +6 -2
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -1
- package/_esm/actions/ens/getEnsAddress.js +12 -1
- package/_esm/actions/ens/getEnsAddress.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/call.js +13 -2
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/getLogs.js +18 -1
- package/_esm/actions/public/getLogs.js.map +1 -1
- package/_esm/actions/public/internal/isRangeError.js +19 -0
- package/_esm/actions/public/internal/isRangeError.js.map +1 -0
- package/_esm/actions/public/internal/watchTransport.js +22 -0
- package/_esm/actions/public/internal/watchTransport.js.map +1 -0
- package/_esm/actions/public/iterateLogs.js +84 -0
- package/_esm/actions/public/iterateLogs.js.map +1 -0
- package/_esm/actions/public/simulateContract.js +5 -4
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/public/verifyHash.js +77 -40
- package/_esm/actions/public/verifyHash.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +20 -1
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchBlockHeaders.js +2 -10
- package/_esm/actions/public/watchBlockHeaders.js.map +1 -1
- package/_esm/actions/public/watchBlockNumber.js +3 -18
- package/_esm/actions/public/watchBlockNumber.js.map +1 -1
- package/_esm/actions/public/watchBlocks.js +3 -18
- package/_esm/actions/public/watchBlocks.js.map +1 -1
- package/_esm/actions/public/watchContractEvent.js +4 -36
- package/_esm/actions/public/watchContractEvent.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +4 -36
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +17 -3
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/celo/serializers.js +1 -1
- package/_esm/celo/serializers.js.map +1 -1
- package/_esm/clients/decorators/public.js +2 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/constants/contracts.js +1 -1
- package/_esm/constants/contracts.js.map +1 -1
- package/_esm/errors/chain.js +2 -2
- package/_esm/errors/chain.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/actions/buildProveWithdrawal.js +5 -5
- package/_esm/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_esm/op-stack/actions/getL2Output.js +14 -9
- package/_esm/op-stack/actions/getL2Output.js.map +1 -1
- package/_esm/op-stack/actions/waitToProve.js +1 -0
- package/_esm/op-stack/actions/waitToProve.js.map +1 -1
- package/_esm/tempo/Account.js +33 -1
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +1 -1
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +5 -5
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +1 -1
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +3 -3
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +1 -1
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/token.js +10 -2
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/chainConfig.js +16 -0
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/preAuthorized.js +244 -0
- package/_esm/tempo/internal/preAuthorized.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +26 -7
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/utils/abi/decodeAbiParameters.js +37 -9
- package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/_esm/utils/abi/encodeAbiParameters.js +6 -4
- package/_esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/_esm/utils/abi/encodePacked.js +5 -2
- package/_esm/utils/abi/encodePacked.js.map +1 -1
- package/_esm/utils/ccip.js +8 -3
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/chain/getChainContractAddress.js +2 -2
- package/_esm/utils/chain/getChainContractAddress.js.map +1 -1
- package/_esm/utils/encoding/toBytes.js +5 -6
- package/_esm/utils/encoding/toBytes.js.map +1 -1
- package/_esm/utils/ens/avatar/utils.js +26 -5
- package/_esm/utils/ens/avatar/utils.js.map +1 -1
- package/_esm/utils/ens/localBatchGatewayRequest.js +17 -1
- package/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -1
- package/_esm/utils/promise/createBatchScheduler.js +2 -1
- package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/_esm/utils/siwe/validateSiweMessage.js +6 -0
- package/_esm/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_esm/zksync/actions/estimateFee.js +1 -1
- package/_esm/zksync/actions/estimateFee.js.map +1 -1
- package/_esm/zksync/actions/estimateGasL1ToL2.js +1 -1
- package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -1
- package/_esm/zksync/actions/finalizeWithdrawal.js +3 -3
- package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_esm/zksync/actions/sendEip712Transaction.js +12 -2
- package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
- package/_esm/zksync/actions/signEip712Transaction.js +2 -2
- package/_esm/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
- package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -1
- package/_types/actions/ens/getEnsAddress.d.ts +2 -1
- package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/getLogs.d.ts +20 -2
- package/_types/actions/public/getLogs.d.ts.map +1 -1
- package/_types/actions/public/internal/isRangeError.d.ts +3 -0
- package/_types/actions/public/internal/isRangeError.d.ts.map +1 -0
- package/_types/actions/public/internal/watchTransport.d.ts +6 -0
- package/_types/actions/public/internal/watchTransport.d.ts.map +1 -0
- package/_types/actions/public/iterateLogs.d.ts +94 -0
- package/_types/actions/public/iterateLogs.d.ts.map +1 -0
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/public/verifyHash.d.ts +2 -1
- package/_types/actions/public/verifyHash.d.ts.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts +7 -2
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchBlockHeaders.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/wallet/prepareTransactionRequest.d.ts +2 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/celo/serializers.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +33 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/constants/contracts.d.ts +1 -1
- package/_types/constants/contracts.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/actions/getL2Output.d.ts +6 -0
- package/_types/op-stack/actions/getL2Output.d.ts.map +1 -1
- package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +5 -1
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/propAmm.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/preAuthorized.d.ts +41 -0
- package/_types/tempo/internal/preAuthorized.d.ts.map +1 -0
- package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -1
- package/_types/utils/abi/decodeAbiParameters.d.ts +15 -1
- package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/_types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts +4 -3
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/encoding/toBytes.d.ts +1 -1
- package/_types/utils/encoding/toBytes.d.ts.map +1 -1
- package/_types/utils/ens/avatar/utils.d.ts +6 -2
- package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
- package/_types/utils/ens/localBatchGatewayRequest.d.ts +6 -1
- package/_types/utils/ens/localBatchGatewayRequest.d.ts.map +1 -1
- package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/_types/utils/siwe/validateSiweMessage.d.ts.map +1 -1
- package/_types/zksync/actions/estimateFee.d.ts.map +1 -1
- package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -1
- package/_types/zksync/actions/finalizeWithdrawal.d.ts.map +1 -1
- package/_types/zksync/actions/sendEip712Transaction.d.ts +1 -1
- package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
- package/account-abstraction/actions/paymaster/getPaymasterData.ts +23 -16
- package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +27 -16
- package/actions/ens/getEnsAddress.ts +15 -1
- package/actions/index.ts +6 -0
- package/actions/public/call.ts +15 -2
- package/actions/public/getLogs.ts +44 -0
- package/actions/public/internal/isRangeError.ts +18 -0
- package/actions/public/internal/watchTransport.ts +29 -0
- package/actions/public/iterateLogs.ts +209 -0
- package/actions/public/simulateContract.ts +6 -4
- package/actions/public/verifyHash.ts +87 -60
- package/actions/public/waitForTransactionReceipt.ts +31 -1
- package/actions/public/watchBlockHeaders.ts +2 -12
- package/actions/public/watchBlockNumber.ts +6 -24
- package/actions/public/watchBlocks.ts +6 -24
- package/actions/public/watchContractEvent.ts +7 -42
- package/actions/public/watchEvent.ts +7 -42
- package/actions/wallet/prepareTransactionRequest.ts +23 -3
- package/celo/serializers.ts +5 -2
- package/clients/decorators/public.ts +47 -0
- package/constants/contracts.ts +1 -1
- package/errors/chain.ts +2 -2
- package/errors/version.ts +1 -1
- package/index.ts +7 -0
- package/op-stack/actions/buildProveWithdrawal.ts +5 -5
- package/op-stack/actions/getL2Output.ts +24 -11
- package/op-stack/actions/waitToProve.ts +1 -0
- package/package.json +2 -2
- package/tempo/Account.ts +38 -1
- package/tempo/actions/accessKey.ts +1 -1
- package/tempo/actions/accounts.ts +5 -5
- package/tempo/actions/earn/deployment.ts +2 -1
- package/tempo/actions/earn.ts +2 -2
- package/tempo/actions/propAmm.ts +2 -1
- package/tempo/actions/token.ts +10 -2
- package/tempo/chainConfig.ts +20 -0
- package/tempo/internal/preAuthorized.ts +309 -0
- package/tempo/internal/relay/feePayer.ts +33 -11
- package/utils/abi/decodeAbiParameters.ts +60 -9
- package/utils/abi/encodeAbiParameters.ts +6 -4
- package/utils/abi/encodePacked.ts +5 -1
- package/utils/ccip.ts +17 -3
- package/utils/chain/getChainContractAddress.ts +2 -2
- package/utils/encoding/toBytes.ts +4 -6
- package/utils/ens/avatar/utils.ts +38 -4
- package/utils/ens/localBatchGatewayRequest.ts +21 -2
- package/utils/promise/createBatchScheduler.ts +2 -1
- package/utils/siwe/validateSiweMessage.ts +7 -0
- package/zksync/actions/estimateFee.ts +2 -1
- package/zksync/actions/estimateGasL1ToL2.ts +2 -1
- package/zksync/actions/finalizeWithdrawal.ts +4 -3
- package/zksync/actions/sendEip712Transaction.ts +21 -8
- package/zksync/actions/signEip712Transaction.ts +3 -3
|
@@ -10,6 +10,10 @@ import { type PollErrorType, poll } from '../../utils/poll.js'
|
|
|
10
10
|
import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
|
|
11
11
|
|
|
12
12
|
import { type GetBlockReturnType, getBlock } from './getBlock.js'
|
|
13
|
+
import {
|
|
14
|
+
getSubscriptionTransport,
|
|
15
|
+
shouldPoll,
|
|
16
|
+
} from './internal/watchTransport.js'
|
|
13
17
|
|
|
14
18
|
export type OnBlockParameter<
|
|
15
19
|
chain extends Chain | undefined = Chain,
|
|
@@ -120,18 +124,7 @@ export function watchBlocks<
|
|
|
120
124
|
): WatchBlocksReturnType {
|
|
121
125
|
const enablePolling = (() => {
|
|
122
126
|
if (typeof poll_ !== 'undefined') return poll_
|
|
123
|
-
|
|
124
|
-
client.transport.type === 'webSocket' ||
|
|
125
|
-
client.transport.type === 'ipc'
|
|
126
|
-
)
|
|
127
|
-
return false
|
|
128
|
-
if (
|
|
129
|
-
client.transport.type === 'fallback' &&
|
|
130
|
-
(client.transport.transports[0].config.type === 'webSocket' ||
|
|
131
|
-
client.transport.transports[0].config.type === 'ipc')
|
|
132
|
-
)
|
|
133
|
-
return false
|
|
134
|
-
return true
|
|
127
|
+
return shouldPoll(client)
|
|
135
128
|
})()
|
|
136
129
|
const includeTransactions = includeTransactions_ ?? false
|
|
137
130
|
// Polling less than twice per block skips blocks, so emit the missed
|
|
@@ -260,18 +253,7 @@ export function watchBlocks<
|
|
|
260
253
|
.catch(onError)
|
|
261
254
|
}
|
|
262
255
|
|
|
263
|
-
const transport = (
|
|
264
|
-
if (client.transport.type === 'fallback') {
|
|
265
|
-
const transport = client.transport.transports.find(
|
|
266
|
-
(transport: ReturnType<Transport>) =>
|
|
267
|
-
transport.config.type === 'webSocket' ||
|
|
268
|
-
transport.config.type === 'ipc',
|
|
269
|
-
)
|
|
270
|
-
if (!transport) return client.transport
|
|
271
|
-
return transport.value
|
|
272
|
-
}
|
|
273
|
-
return client.transport
|
|
274
|
-
})()
|
|
256
|
+
const transport = getSubscriptionTransport(client)
|
|
275
257
|
|
|
276
258
|
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
277
259
|
params: ['newHeads'],
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
DecodeLogDataMismatch,
|
|
9
9
|
DecodeLogTopicsMismatch,
|
|
10
10
|
} from '../../errors/abi.js'
|
|
11
|
-
import { BaseError } from '../../errors/base.js'
|
|
12
|
-
import { HttpRequestError, RpcRequestError } from '../../errors/request.js'
|
|
13
11
|
import { InvalidInputRpcError } from '../../errors/rpc.js'
|
|
14
12
|
import type { ErrorType } from '../../errors/utils.js'
|
|
15
13
|
import type { BlockNumber } from '../../types/block.js'
|
|
@@ -42,6 +40,11 @@ import {
|
|
|
42
40
|
getContractEvents,
|
|
43
41
|
} from './getContractEvents.js'
|
|
44
42
|
import { getFilterChanges } from './getFilterChanges.js'
|
|
43
|
+
import { isRangeError } from './internal/isRangeError.js'
|
|
44
|
+
import {
|
|
45
|
+
getSubscriptionTransport,
|
|
46
|
+
shouldPoll,
|
|
47
|
+
} from './internal/watchTransport.js'
|
|
45
48
|
import { uninstallFilter } from './uninstallFilter.js'
|
|
46
49
|
|
|
47
50
|
export type WatchContractEventOnLogsParameter<
|
|
@@ -163,18 +166,7 @@ export function watchContractEvent<
|
|
|
163
166
|
const enablePolling = (() => {
|
|
164
167
|
if (typeof poll_ !== 'undefined') return poll_
|
|
165
168
|
if (typeof fromBlock === 'bigint') return true
|
|
166
|
-
|
|
167
|
-
client.transport.type === 'webSocket' ||
|
|
168
|
-
client.transport.type === 'ipc'
|
|
169
|
-
)
|
|
170
|
-
return false
|
|
171
|
-
if (
|
|
172
|
-
client.transport.type === 'fallback' &&
|
|
173
|
-
(client.transport.transports[0].config.type === 'webSocket' ||
|
|
174
|
-
client.transport.transports[0].config.type === 'ipc')
|
|
175
|
-
)
|
|
176
|
-
return false
|
|
177
|
-
return true
|
|
169
|
+
return shouldPoll(client)
|
|
178
170
|
})()
|
|
179
171
|
|
|
180
172
|
const pollContractEvent = () => {
|
|
@@ -332,18 +324,7 @@ export function watchContractEvent<
|
|
|
332
324
|
return observe(observerId, { onLogs, onError }, (emit) => {
|
|
333
325
|
;(async () => {
|
|
334
326
|
try {
|
|
335
|
-
const transport = (
|
|
336
|
-
if (client.transport.type === 'fallback') {
|
|
337
|
-
const transport = client.transport.transports.find(
|
|
338
|
-
(transport: ReturnType<Transport>) =>
|
|
339
|
-
transport.config.type === 'webSocket' ||
|
|
340
|
-
transport.config.type === 'ipc',
|
|
341
|
-
)
|
|
342
|
-
if (!transport) return client.transport
|
|
343
|
-
return transport.value
|
|
344
|
-
}
|
|
345
|
-
return client.transport
|
|
346
|
-
})()
|
|
327
|
+
const transport = getSubscriptionTransport(client)
|
|
347
328
|
|
|
348
329
|
// A topic filter cannot select an anonymous event, so the
|
|
349
330
|
// subscription can deliver logs that match no requested event. Skip
|
|
@@ -422,19 +403,3 @@ export function watchContractEvent<
|
|
|
422
403
|
|
|
423
404
|
return enablePolling ? pollContractEvent() : subscribeContractEvent()
|
|
424
405
|
}
|
|
425
|
-
|
|
426
|
-
/** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
|
|
427
|
-
function isRangeError(error: unknown) {
|
|
428
|
-
if (!(error instanceof BaseError)) return true
|
|
429
|
-
const cause = error.walk(
|
|
430
|
-
(err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
|
|
431
|
-
) as HttpRequestError | RpcRequestError | null
|
|
432
|
-
if (!cause) return true
|
|
433
|
-
// Rate limited.
|
|
434
|
-
if (cause instanceof RpcRequestError && cause.code === 429) return false
|
|
435
|
-
// Unreachable.
|
|
436
|
-
if (cause instanceof HttpRequestError && cause.status === undefined)
|
|
437
|
-
return false
|
|
438
|
-
// Unauthorized, forbidden or rate limited.
|
|
439
|
-
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
|
|
440
|
-
}
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
DecodeLogDataMismatch,
|
|
9
9
|
DecodeLogTopicsMismatch,
|
|
10
10
|
} from '../../errors/abi.js'
|
|
11
|
-
import { BaseError } from '../../errors/base.js'
|
|
12
|
-
import { HttpRequestError, RpcRequestError } from '../../errors/request.js'
|
|
13
11
|
import { InvalidInputRpcError } from '../../errors/rpc.js'
|
|
14
12
|
import type { ErrorType } from '../../errors/utils.js'
|
|
15
13
|
import type { BlockNumber } from '../../types/block.js'
|
|
@@ -42,6 +40,11 @@ import {
|
|
|
42
40
|
import { getBlockNumber } from './getBlockNumber.js'
|
|
43
41
|
import { getFilterChanges } from './getFilterChanges.js'
|
|
44
42
|
import { type GetLogsParameters, getLogs } from './getLogs.js'
|
|
43
|
+
import { isRangeError } from './internal/isRangeError.js'
|
|
44
|
+
import {
|
|
45
|
+
getSubscriptionTransport,
|
|
46
|
+
shouldPoll,
|
|
47
|
+
} from './internal/watchTransport.js'
|
|
45
48
|
import { uninstallFilter } from './uninstallFilter.js'
|
|
46
49
|
|
|
47
50
|
export type WatchEventOnLogsParameter<
|
|
@@ -183,18 +186,7 @@ export function watchEvent<
|
|
|
183
186
|
const enablePolling = (() => {
|
|
184
187
|
if (typeof poll_ !== 'undefined') return poll_
|
|
185
188
|
if (typeof fromBlock === 'bigint') return true
|
|
186
|
-
|
|
187
|
-
client.transport.type === 'webSocket' ||
|
|
188
|
-
client.transport.type === 'ipc'
|
|
189
|
-
)
|
|
190
|
-
return false
|
|
191
|
-
if (
|
|
192
|
-
client.transport.type === 'fallback' &&
|
|
193
|
-
(client.transport.transports[0].config.type === 'webSocket' ||
|
|
194
|
-
client.transport.transports[0].config.type === 'ipc')
|
|
195
|
-
)
|
|
196
|
-
return false
|
|
197
|
-
return true
|
|
189
|
+
return shouldPoll(client)
|
|
198
190
|
})()
|
|
199
191
|
const strict = strict_ ?? false
|
|
200
192
|
|
|
@@ -344,18 +336,7 @@ export function watchEvent<
|
|
|
344
336
|
let unsubscribe = () => (active = false)
|
|
345
337
|
;(async () => {
|
|
346
338
|
try {
|
|
347
|
-
const transport = (
|
|
348
|
-
if (client.transport.type === 'fallback') {
|
|
349
|
-
const transport = client.transport.transports.find(
|
|
350
|
-
(transport: ReturnType<Transport>) =>
|
|
351
|
-
transport.config.type === 'webSocket' ||
|
|
352
|
-
transport.config.type === 'ipc',
|
|
353
|
-
)
|
|
354
|
-
if (!transport) return client.transport
|
|
355
|
-
return transport.value
|
|
356
|
-
}
|
|
357
|
-
return client.transport
|
|
358
|
-
})()
|
|
339
|
+
const transport = getSubscriptionTransport(client)
|
|
359
340
|
|
|
360
341
|
const events_ = events ?? (event ? [event] : undefined)
|
|
361
342
|
let topics: LogTopic[] = []
|
|
@@ -435,19 +416,3 @@ export function watchEvent<
|
|
|
435
416
|
|
|
436
417
|
return enablePolling ? pollEvent() : subscribeEvent()
|
|
437
418
|
}
|
|
438
|
-
|
|
439
|
-
/** Returns whether a failed `eth_getLogs` request may succeed with a smaller block range. */
|
|
440
|
-
function isRangeError(error: unknown) {
|
|
441
|
-
if (!(error instanceof BaseError)) return true
|
|
442
|
-
const cause = error.walk(
|
|
443
|
-
(err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
|
|
444
|
-
) as HttpRequestError | RpcRequestError | null
|
|
445
|
-
if (!cause) return true
|
|
446
|
-
// Rate limited.
|
|
447
|
-
if (cause instanceof RpcRequestError && cause.code === 429) return false
|
|
448
|
-
// Unreachable.
|
|
449
|
-
if (cause instanceof HttpRequestError && cause.status === undefined)
|
|
450
|
-
return false
|
|
451
|
-
// Unauthorized, forbidden or rate limited.
|
|
452
|
-
return cause.status !== 401 && cause.status !== 403 && cause.status !== 429
|
|
453
|
-
}
|
|
@@ -25,6 +25,10 @@ import type { Client } from '../../clients/createClient.js'
|
|
|
25
25
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
26
26
|
import type { AccountNotFoundErrorType } from '../../errors/account.js'
|
|
27
27
|
import type { BaseError } from '../../errors/base.js'
|
|
28
|
+
import {
|
|
29
|
+
ChainMismatchError,
|
|
30
|
+
type ChainMismatchErrorType,
|
|
31
|
+
} from '../../errors/chain.js'
|
|
28
32
|
import {
|
|
29
33
|
Eip1559FeesNotSupportedError,
|
|
30
34
|
MaxFeePerGasTooLowError,
|
|
@@ -232,6 +236,7 @@ export type PrepareTransactionRequestReturnType<
|
|
|
232
236
|
export type PrepareTransactionRequestErrorType =
|
|
233
237
|
| AccountNotFoundErrorType
|
|
234
238
|
| AssertRequestErrorType
|
|
239
|
+
| ChainMismatchErrorType
|
|
235
240
|
| ParseAccountErrorType
|
|
236
241
|
| GetBlockErrorType
|
|
237
242
|
| GetTransactionCountErrorType
|
|
@@ -302,9 +307,9 @@ export async function prepareTransactionRequest<
|
|
|
302
307
|
request
|
|
303
308
|
>
|
|
304
309
|
> {
|
|
305
|
-
let request = args as PrepareTransactionRequestParameters
|
|
310
|
+
let request = { ...args } as PrepareTransactionRequestParameters
|
|
306
311
|
|
|
307
|
-
request.account
|
|
312
|
+
if (typeof request.account === 'undefined') request.account = client.account
|
|
308
313
|
request.parameters ??= defaultParameters
|
|
309
314
|
|
|
310
315
|
const {
|
|
@@ -434,6 +439,7 @@ export async function prepareTransactionRequest<
|
|
|
434
439
|
return false
|
|
435
440
|
})()
|
|
436
441
|
|
|
442
|
+
let filledChainId: number | undefined
|
|
437
443
|
const fill = (request: PrepareTransactionRequestParameters) =>
|
|
438
444
|
getAction(
|
|
439
445
|
client,
|
|
@@ -462,6 +468,7 @@ export async function prepareTransactionRequest<
|
|
|
462
468
|
feeToken !== null &&
|
|
463
469
|
(!('feeToken' in request) || hasFilledFeePayerSignature)
|
|
464
470
|
supportsFillTransaction.set(client.uid, true)
|
|
471
|
+
filledChainId = chainId
|
|
465
472
|
// The fee payer signs over the filled fee token, so a requested one must not replace or outlive it.
|
|
466
473
|
type WithFeeToken = { feeToken?: unknown }
|
|
467
474
|
const { feeToken: _feeToken, ...unsponsored } = request as WithFeeToken
|
|
@@ -469,7 +476,6 @@ export async function prepareTransactionRequest<
|
|
|
469
476
|
...(hasFilledFeePayerSignature ? unsponsored : request),
|
|
470
477
|
...(from ? { from } : {}),
|
|
471
478
|
...(type && !request.type ? { type } : {}),
|
|
472
|
-
...(typeof chainId !== 'undefined' ? { chainId } : {}),
|
|
473
479
|
...(typeof gas !== 'undefined' ? { gas } : {}),
|
|
474
480
|
...(typeof gasPrice !== 'undefined' ? { gasPrice } : {}),
|
|
475
481
|
...(typeof nonce !== 'undefined' ? { nonce } : {}),
|
|
@@ -572,6 +578,20 @@ export async function prepareTransactionRequest<
|
|
|
572
578
|
...(account ? { from: account?.address } : {}),
|
|
573
579
|
...(typeof nonce !== 'undefined' ? { nonce } : {}),
|
|
574
580
|
}
|
|
581
|
+
|
|
582
|
+
// The filled chain id only applies when neither the request nor the chain provides one.
|
|
583
|
+
if (typeof filledChainId !== 'undefined') {
|
|
584
|
+
request.chainId ??= chain?.id ?? filledChainId
|
|
585
|
+
if (request.chainId !== filledChainId)
|
|
586
|
+
throw new ChainMismatchError({
|
|
587
|
+
chain:
|
|
588
|
+
chain?.id === request.chainId
|
|
589
|
+
? chain
|
|
590
|
+
: ({ id: request.chainId, name: 'Unknown' } as Chain),
|
|
591
|
+
currentChainId: filledChainId,
|
|
592
|
+
})
|
|
593
|
+
}
|
|
594
|
+
|
|
575
595
|
const { blobs, gas, kzg, type } = request
|
|
576
596
|
|
|
577
597
|
if (
|
package/celo/serializers.ts
CHANGED
|
@@ -24,8 +24,11 @@ export function serializeTransaction(
|
|
|
24
24
|
transaction: CeloTransactionSerializable,
|
|
25
25
|
signature?: Signature | undefined,
|
|
26
26
|
) {
|
|
27
|
-
if (isCIP64(transaction))
|
|
28
|
-
return serializeTransactionCIP64(
|
|
27
|
+
if (isCIP64(transaction) || isPresent(transaction.feeCurrency))
|
|
28
|
+
return serializeTransactionCIP64(
|
|
29
|
+
transaction as TransactionSerializableCIP64,
|
|
30
|
+
signature,
|
|
31
|
+
)
|
|
29
32
|
return serializeTransaction_op(transaction, signature)
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -195,6 +195,11 @@ import {
|
|
|
195
195
|
type GetTransactionReceiptReturnType,
|
|
196
196
|
getTransactionReceipt,
|
|
197
197
|
} from '../../actions/public/getTransactionReceipt.js'
|
|
198
|
+
import {
|
|
199
|
+
type IterateLogsParameters,
|
|
200
|
+
type IterateLogsReturnType,
|
|
201
|
+
iterateLogs,
|
|
202
|
+
} from '../../actions/public/iterateLogs.js'
|
|
198
203
|
import {
|
|
199
204
|
type MulticallParameters,
|
|
200
205
|
type MulticallReturnType,
|
|
@@ -1529,6 +1534,47 @@ export type PublicActions<
|
|
|
1529
1534
|
getTransactionReceipt: (
|
|
1530
1535
|
args: GetTransactionReceiptParameters,
|
|
1531
1536
|
) => Promise<GetTransactionReceiptReturnType<chain>>
|
|
1537
|
+
/**
|
|
1538
|
+
* Iterates over the event logs in a block range, one page of blocks at a time.
|
|
1539
|
+
*
|
|
1540
|
+
* - Docs: https://viem.sh/docs/actions/public/iterateLogs
|
|
1541
|
+
* - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
|
1542
|
+
*
|
|
1543
|
+
* Pages are contiguous and are yielded even when they contain no logs, so a consumer that
|
|
1544
|
+
* stores each page's `toBlock` can resume from `toBlock + 1n`. A page is only requested
|
|
1545
|
+
* once the consumer asks for it. If a request fails with an error that a smaller block
|
|
1546
|
+
* range may avoid (such as an RPC Provider's block range or response size limit), the page
|
|
1547
|
+
* is halved and requested again.
|
|
1548
|
+
*
|
|
1549
|
+
* @param args - {@link IterateLogsParameters}
|
|
1550
|
+
* @returns An async iterator of log pages. {@link IterateLogsReturnType}
|
|
1551
|
+
*
|
|
1552
|
+
* @example
|
|
1553
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
1554
|
+
* import { mainnet } from 'viem/chains'
|
|
1555
|
+
*
|
|
1556
|
+
* const client = createPublicClient({
|
|
1557
|
+
* chain: mainnet,
|
|
1558
|
+
* transport: http(),
|
|
1559
|
+
* })
|
|
1560
|
+
* for await (const page of client.iterateLogs({
|
|
1561
|
+
* event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
|
1562
|
+
* fromBlock: 16330000n,
|
|
1563
|
+
* toBlock: 16340000n,
|
|
1564
|
+
* })) {
|
|
1565
|
+
* console.log(page.toBlock, page.logs)
|
|
1566
|
+
* }
|
|
1567
|
+
*/
|
|
1568
|
+
iterateLogs: <
|
|
1569
|
+
const abiEvent extends AbiEvent | undefined = undefined,
|
|
1570
|
+
const abiEvents extends
|
|
1571
|
+
| readonly AbiEvent[]
|
|
1572
|
+
| readonly unknown[]
|
|
1573
|
+
| undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,
|
|
1574
|
+
strict extends boolean | undefined = undefined,
|
|
1575
|
+
>(
|
|
1576
|
+
args: IterateLogsParameters<abiEvent, abiEvents, strict>,
|
|
1577
|
+
) => IterateLogsReturnType<abiEvent, abiEvents, strict>
|
|
1532
1578
|
/**
|
|
1533
1579
|
* Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).
|
|
1534
1580
|
*
|
|
@@ -2373,6 +2419,7 @@ export function publicActions<
|
|
|
2373
2419
|
getTransactionConfirmations(client, args),
|
|
2374
2420
|
getTransactionCount: (args) => getTransactionCount(client, args),
|
|
2375
2421
|
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
|
|
2422
|
+
iterateLogs: (args) => iterateLogs(client, args as any),
|
|
2376
2423
|
multicall: (args) => multicall(client, args),
|
|
2377
2424
|
prepareTransactionRequest: (args) =>
|
|
2378
2425
|
prepareTransactionRequest(client as any, args as any) as any,
|
package/constants/contracts.ts
CHANGED
|
@@ -5,7 +5,7 @@ export const deploylessCallViaFactoryBytecode =
|
|
|
5
5
|
'0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe'
|
|
6
6
|
|
|
7
7
|
export const erc6492SignatureValidatorByteCode =
|
|
8
|
-
'
|
|
8
|
+
'0x608060405234801561001057600080fd5b506040516106ad3803806106ad83398101604081905261002f91610537565b600061003c848484610048565b9050806000526001601ff35b60007f649264926492649264926492649264926492649264926492649264926492649261007483610425565b036101e7576000606080848060200190518101906100929190610590565b60405192955090935091506000906001600160a01b038516906100b69085906105f6565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b908790600401610612565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d1919061064c565b6001600160e01b0319161494505050505061041e565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e906102279087908790600401610612565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610268919061064c565b6001600160e01b03191614905061041e565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061068d83398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e761043e565b5060208201516040808401518451859392600091859190811061030c5761030c610676565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061068d83398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b604080516000808252602082018084528a905260ff841692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa1580156103e0573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906104165750886001600160a01b0316816001600160a01b0316145b955050505050505b9392505050565b600060208251101561043657600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461047157600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b838110156104a557818101518382015260200161048d565b50506000910152565b600082601f8301126104bf57600080fd5b81516001600160401b038111156104d8576104d8610474565b604051601f8201601f19908116603f011681016001600160401b038111828210171561050657610506610474565b60405281815283820160200185101561051e57600080fd5b61052f82602083016020870161048a565b949350505050565b60008060006060848603121561054c57600080fd5b83516105578161045c565b6020850151604086015191945092506001600160401b0381111561057a57600080fd5b610586868287016104ae565b9150509250925092565b6000806000606084860312156105a557600080fd5b83516105b08161045c565b60208501519093506001600160401b038111156105cc57600080fd5b6105d8868287016104ae565b604086015190935090506001600160401b0381111561057a57600080fd5b6000825161060881846020870161048a565b9190910192915050565b828152604060208201526000825180604084015261063781606085016020870161048a565b601f01601f1916919091016060019392505050565b60006020828403121561065e57600080fd5b81516001600160e01b03198116811461041e57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572'
|
|
9
9
|
|
|
10
10
|
export const multicall3Bytecode =
|
|
11
11
|
'0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033'
|
package/errors/chain.ts
CHANGED
|
@@ -21,8 +21,8 @@ export class ChainDoesNotSupportContract extends BaseError {
|
|
|
21
21
|
{
|
|
22
22
|
metaMessages: [
|
|
23
23
|
'This could be due to any of the following:',
|
|
24
|
-
...(blockNumber &&
|
|
25
|
-
contract.blockCreated &&
|
|
24
|
+
...(blockNumber !== undefined &&
|
|
25
|
+
contract.blockCreated !== undefined &&
|
|
26
26
|
contract.blockCreated > blockNumber
|
|
27
27
|
? [
|
|
28
28
|
`- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`,
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.57.
|
|
1
|
+
export const version = '2.57.18'
|
package/index.ts
CHANGED
|
@@ -272,6 +272,11 @@ export type {
|
|
|
272
272
|
GetTransactionReceiptParameters,
|
|
273
273
|
GetTransactionReceiptReturnType,
|
|
274
274
|
} from './actions/public/getTransactionReceipt.js'
|
|
275
|
+
export type {
|
|
276
|
+
IterateLogsErrorType,
|
|
277
|
+
IterateLogsParameters,
|
|
278
|
+
IterateLogsReturnType,
|
|
279
|
+
} from './actions/public/iterateLogs.js'
|
|
275
280
|
export type {
|
|
276
281
|
MulticallErrorType,
|
|
277
282
|
MulticallParameters,
|
|
@@ -1333,6 +1338,8 @@ export type {
|
|
|
1333
1338
|
} from './types/utils.js'
|
|
1334
1339
|
export type { Withdrawal } from './types/withdrawal.js'
|
|
1335
1340
|
export {
|
|
1341
|
+
AbiDecodingSizeLimitExceededError,
|
|
1342
|
+
type AbiDecodingSizeLimitExceededErrorType,
|
|
1336
1343
|
type DecodeAbiParametersErrorType,
|
|
1337
1344
|
type DecodeAbiParametersReturnType,
|
|
1338
1345
|
decodeAbiParameters,
|
|
@@ -124,10 +124,10 @@ export async function buildProveWithdrawal<
|
|
|
124
124
|
const { account, chain = client.chain, game, output, withdrawal } = args
|
|
125
125
|
|
|
126
126
|
const { withdrawalHash } = withdrawal
|
|
127
|
-
const { l2BlockNumber } = game ?? output
|
|
128
|
-
const blockNumber =
|
|
127
|
+
const { l2BlockNumber, usesSuperRoots } = game ?? output
|
|
128
|
+
const blockNumber = usesSuperRoots
|
|
129
129
|
? await getL2BlockNumberAtTimestamp(client, {
|
|
130
|
-
timestamp:
|
|
130
|
+
timestamp: l2BlockNumber,
|
|
131
131
|
})
|
|
132
132
|
: l2BlockNumber
|
|
133
133
|
|
|
@@ -143,9 +143,9 @@ export async function buildProveWithdrawal<
|
|
|
143
143
|
}),
|
|
144
144
|
])
|
|
145
145
|
|
|
146
|
-
if (
|
|
146
|
+
if (usesSuperRoots && block.timestamp !== l2BlockNumber)
|
|
147
147
|
throw new Error(
|
|
148
|
-
`L2 block timestamp ${block.timestamp} does not match dispute game timestamp ${
|
|
148
|
+
`L2 block timestamp ${block.timestamp} does not match dispute game timestamp ${l2BlockNumber}.`,
|
|
149
149
|
)
|
|
150
150
|
|
|
151
151
|
return {
|
|
@@ -46,7 +46,13 @@ export type GetL2OutputReturnType = {
|
|
|
46
46
|
outputIndex: bigint
|
|
47
47
|
outputRoot: Hex
|
|
48
48
|
timestamp: bigint
|
|
49
|
+
/**
|
|
50
|
+
* L2 block number of the output. For super-root dispute games, this value is
|
|
51
|
+
* the L2 timestamp instead. Check `usesSuperRoots` to distinguish the unit.
|
|
52
|
+
*/
|
|
49
53
|
l2BlockNumber: bigint
|
|
54
|
+
/** Whether the output comes from a super-root dispute game. */
|
|
55
|
+
usesSuperRoots?: boolean | undefined
|
|
50
56
|
}
|
|
51
57
|
export type GetL2OutputErrorType = ReadContractErrorType | ErrorType
|
|
52
58
|
|
|
@@ -84,18 +90,25 @@ export async function getL2Output<
|
|
|
84
90
|
): Promise<GetL2OutputReturnType> {
|
|
85
91
|
const { chain = client.chain, l2BlockNumber, targetChain } = parameters
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
parameters
|
|
90
|
-
|
|
93
|
+
// Without a portal, read the L2OutputOracle directly.
|
|
94
|
+
if (
|
|
95
|
+
parameters.portalAddress ||
|
|
96
|
+
(targetChain as unknown as TargetChain | undefined)?.contracts.portal
|
|
97
|
+
) {
|
|
98
|
+
const version = await getPortalVersion(
|
|
99
|
+
client,
|
|
100
|
+
parameters as GetPortalVersionParameters,
|
|
101
|
+
)
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
if (version.major >= 3) {
|
|
104
|
+
const game = await getGame(client, parameters as GetGameParameters)
|
|
105
|
+
return {
|
|
106
|
+
l2BlockNumber: game.l2BlockNumber,
|
|
107
|
+
outputIndex: game.index,
|
|
108
|
+
outputRoot: game.rootClaim,
|
|
109
|
+
timestamp: game.timestamp,
|
|
110
|
+
usesSuperRoots: game.usesSuperRoots,
|
|
111
|
+
}
|
|
99
112
|
}
|
|
100
113
|
}
|
|
101
114
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.57.
|
|
4
|
+
"version": "2.57.18",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"@scure/bip39": "1.6.0",
|
|
234
234
|
"abitype": "1.2.3",
|
|
235
235
|
"isows": "1.0.7",
|
|
236
|
-
"ox": "0.14.
|
|
236
|
+
"ox": "0.14.65",
|
|
237
237
|
"ws": "8.21.0"
|
|
238
238
|
},
|
|
239
239
|
"license": "MIT",
|
package/tempo/Account.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Channel,
|
|
10
10
|
KeyAuthorization,
|
|
11
11
|
SignatureEnvelope,
|
|
12
|
+
SignaturePreAuthorized,
|
|
12
13
|
} from 'ox/tempo'
|
|
13
14
|
import * as WebAuthnP256 from 'ox/WebAuthnP256'
|
|
14
15
|
import * as WebCryptoP256 from 'ox/WebCryptoP256'
|
|
@@ -80,7 +81,11 @@ export type AccessKeyAccount = Omit<Account_base<'accessKey'>, 'keyType'> & {
|
|
|
80
81
|
* Signs a hash.
|
|
81
82
|
*
|
|
82
83
|
* By default, access key accounts sign through a keychain envelope so the
|
|
83
|
-
* signature authorizes the parent account.
|
|
84
|
+
* signature authorizes the parent account. While the account's key
|
|
85
|
+
* authorization manager holds the key authorization the account was created
|
|
86
|
+
* with, `sign`, `signMessage`, and `signTypedData` return a pre-authorized
|
|
87
|
+
* signature (TIP-1165) that bundles it, so `verifyHash` accepts the signature
|
|
88
|
+
* before the chain registers the access key.
|
|
84
89
|
*
|
|
85
90
|
* Set `raw` to `true` to sign directly with the access key, without keychain
|
|
86
91
|
* hashing or keychain enveloping.
|
|
@@ -1408,10 +1413,42 @@ function fromAccessKey(parameters: fromAccessKey.Parameters): AccessKeyAccount {
|
|
|
1408
1413
|
keyAuthorizationManager,
|
|
1409
1414
|
parentAddress,
|
|
1410
1415
|
})
|
|
1416
|
+
|
|
1417
|
+
// While the manager holds the access key's unregistered authorization, signatures
|
|
1418
|
+
// carry it (TIP-1165) so verifiers accept them before the chain registers the key.
|
|
1419
|
+
async function preAuthorize(signature: Hex.Hex) {
|
|
1420
|
+
const { internal_version = 'v2' } = parameters
|
|
1421
|
+
if (!keyAuthorization || !keyAuthorizationManager) return signature
|
|
1422
|
+
if (internal_version !== 'v2') return signature
|
|
1423
|
+
const pending = await keyAuthorizationManager.get({
|
|
1424
|
+
address: account.address,
|
|
1425
|
+
accessKey: accessKeyAddress,
|
|
1426
|
+
chainId: Number(keyAuthorization.chainId),
|
|
1427
|
+
})
|
|
1428
|
+
if (!pending) return signature
|
|
1429
|
+
return SignaturePreAuthorized.wrap({
|
|
1430
|
+
keyAuthorization: pending,
|
|
1431
|
+
signature: SignatureEnvelope.from(
|
|
1432
|
+
signature,
|
|
1433
|
+
) as SignatureEnvelope.Keychain,
|
|
1434
|
+
})
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1411
1437
|
return {
|
|
1412
1438
|
...account,
|
|
1413
1439
|
accessKeyAddress,
|
|
1414
1440
|
keyAuthorizationManager,
|
|
1441
|
+
async sign(parameters: { hash: Hex.Hex; raw?: boolean | undefined }) {
|
|
1442
|
+
const signature = await account.sign(parameters)
|
|
1443
|
+
if (parameters.raw) return signature
|
|
1444
|
+
return await preAuthorize(signature)
|
|
1445
|
+
},
|
|
1446
|
+
async signMessage(parameters) {
|
|
1447
|
+
return await preAuthorize(await account.signMessage(parameters))
|
|
1448
|
+
},
|
|
1449
|
+
async signTypedData(typedData) {
|
|
1450
|
+
return await preAuthorize(await account.signTypedData(typedData))
|
|
1451
|
+
},
|
|
1415
1452
|
source: 'accessKey',
|
|
1416
1453
|
}
|
|
1417
1454
|
}
|
|
@@ -178,7 +178,7 @@ export namespace authorize {
|
|
|
178
178
|
witness,
|
|
179
179
|
...rest
|
|
180
180
|
} = parameters
|
|
181
|
-
const account_ =
|
|
181
|
+
const { account: account_ = client.account } = rest
|
|
182
182
|
if (!account_) throw new Error('account is required.')
|
|
183
183
|
if (!chainId) throw new Error('chainId is required.')
|
|
184
184
|
const keyAuthorization = await signLocal(client, {
|