viem 0.0.0-portable-types-20230518183529 → 0.0.0-portable-types-20230523145621
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/README.md +1 -1
- package/abi/package.json +5 -0
- package/accounts/package.json +5 -0
- package/chains/package.json +5 -0
- package/contract/package.json +5 -0
- package/dist/cjs/actions/ens/getEnsAddress.js +1 -1
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/public/estimateGas.js +3 -2
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/waitForTransactionReceipt.js +23 -12
- package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js +2 -1
- package/dist/cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js +2 -1
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +2 -1
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +2 -1
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js +2 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/cjs/errors/abi.js +0 -2
- package/dist/cjs/errors/abi.js.map +1 -1
- package/dist/cjs/errors/ccip.js +2 -1
- package/dist/cjs/errors/ccip.js.map +1 -1
- package/dist/cjs/errors/data.js +2 -2
- package/dist/cjs/errors/data.js.map +1 -1
- package/dist/cjs/errors/rpc.js +8 -2
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/eip1193.js +3 -3
- package/dist/cjs/types/eip1193.js.map +1 -1
- package/dist/cjs/utils/abi/decodeAbiParameters.js +22 -14
- package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/decodeEventLog.js +5 -5
- package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/data/isHex.js +2 -2
- package/dist/cjs/utils/data/isHex.js.map +1 -1
- package/dist/cjs/utils/data/size.js +1 -1
- package/dist/cjs/utils/data/size.js.map +1 -1
- package/dist/cjs/utils/data/slice.js +36 -12
- package/dist/cjs/utils/data/slice.js.map +1 -1
- package/dist/cjs/utils/data/trim.js +1 -1
- package/dist/cjs/utils/data/trim.js.map +1 -1
- package/dist/cjs/utils/encoding/fromHex.js +2 -2
- package/dist/cjs/utils/encoding/fromHex.js.map +1 -1
- package/dist/cjs/utils/hash/keccak256.js +1 -1
- package/dist/cjs/utils/hash/keccak256.js.map +1 -1
- package/dist/cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/cjs/utils/rpc.js +49 -40
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/signature/recoverPublicKey.js +3 -1
- package/dist/cjs/utils/signature/recoverPublicKey.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +1 -2
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js +2 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +3 -2
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js +23 -12
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js +2 -1
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +2 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +2 -1
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +2 -1
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/public/watchPendingTransactions.js +2 -1
- package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/esm/errors/abi.js +0 -2
- package/dist/esm/errors/abi.js.map +1 -1
- package/dist/esm/errors/ccip.js +2 -1
- package/dist/esm/errors/ccip.js.map +1 -1
- package/dist/esm/errors/data.js +2 -2
- package/dist/esm/errors/data.js.map +1 -1
- package/dist/esm/errors/rpc.js +8 -2
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/eip1193.js +1 -1
- package/dist/esm/types/eip1193.js.map +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js +23 -15
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeEventLog.js +5 -5
- package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/data/isHex.js +2 -2
- package/dist/esm/utils/data/isHex.js.map +1 -1
- package/dist/esm/utils/data/size.js +1 -1
- package/dist/esm/utils/data/size.js.map +1 -1
- package/dist/esm/utils/data/slice.js +36 -12
- package/dist/esm/utils/data/slice.js.map +1 -1
- package/dist/esm/utils/data/trim.js +1 -1
- package/dist/esm/utils/data/trim.js.map +1 -1
- package/dist/esm/utils/encoding/fromHex.js +2 -2
- package/dist/esm/utils/encoding/fromHex.js.map +1 -1
- package/dist/esm/utils/hash/keccak256.js +1 -1
- package/dist/esm/utils/hash/keccak256.js.map +1 -1
- package/dist/esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/esm/utils/rpc.js +49 -40
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/signature/recoverPublicKey.js +3 -1
- package/dist/esm/utils/signature/recoverPublicKey.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +1 -2
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/utils/transaction/serializeTransaction.js +2 -1
- package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/types/actions/public/createBlockFilter.d.ts +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +1 -1
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +4 -4
- package/dist/types/actions/public/getTransaction.d.ts +1 -1
- package/dist/types/actions/public/getTransactionCount.d.ts +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +2 -2
- package/dist/types/actions/public/multicall.d.ts +1 -1
- package/dist/types/actions/public/readContract.d.ts +2 -2
- package/dist/types/actions/public/readContract.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +2 -2
- package/dist/types/actions/public/uninstallFilter.d.ts +3 -3
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +2 -2
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchPendingTransactions.d.ts.map +1 -1
- package/dist/types/actions/test/setBlockTimestampInterval.d.ts +1 -1
- package/dist/types/actions/test/stopImpersonatingAccount.d.ts +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +1 -1
- package/dist/types/actions/wallet/signMessage.d.ts +2 -2
- package/dist/types/actions/wallet/writeContract.d.ts +3 -3
- package/dist/types/clients/createPublicClient.d.ts +1 -1
- package/dist/types/clients/createTestClient.d.ts +4 -4
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +2 -2
- package/dist/types/clients/decorators/public.d.ts +22 -22
- package/dist/types/clients/decorators/test.d.ts +2 -2
- package/dist/types/clients/decorators/wallet.d.ts +6 -6
- package/dist/types/errors/abi.d.ts.map +1 -1
- package/dist/types/errors/ccip.d.ts.map +1 -1
- package/dist/types/errors/data.d.ts +2 -1
- package/dist/types/errors/data.d.ts.map +1 -1
- package/dist/types/errors/rpc.d.ts +12 -8
- package/dist/types/errors/rpc.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +7 -33
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +7 -8
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/types/log.d.ts +0 -2
- package/dist/types/types/log.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/buildRequest.d.ts.map +1 -1
- package/dist/types/utils/data/isHex.d.ts +3 -1
- package/dist/types/utils/data/isHex.d.ts.map +1 -1
- package/dist/types/utils/data/slice.d.ts +9 -3
- package/dist/types/utils/data/slice.d.ts.map +1 -1
- package/dist/types/utils/data/trim.d.ts.map +1 -1
- package/dist/types/utils/encoding/fromHex.d.ts +1 -1
- package/dist/types/utils/hash/keccak256.d.ts.map +1 -1
- package/dist/types/utils/promise/createBatchScheduler.d.ts +6 -4
- package/dist/types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverPublicKey.d.ts.map +1 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts +1 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
- package/dist/types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/ens/package.json +5 -0
- package/ethers/package.json +5 -0
- package/package.json +13 -2
- package/public/package.json +5 -0
- package/src/actions/ens/getEnsAddress.ts +1 -1
- package/src/actions/public/createBlockFilter.ts +1 -1
- package/src/actions/public/createContractEventFilter.ts +1 -1
- package/src/actions/public/createEventFilter.ts +1 -1
- package/src/actions/public/createPendingTransactionFilter.ts +1 -1
- package/src/actions/public/estimateContractGas.ts +1 -1
- package/src/actions/public/estimateGas.ts +3 -2
- package/src/actions/public/getFilterChanges.ts +4 -4
- package/src/actions/public/getTransaction.ts +1 -1
- package/src/actions/public/getTransactionCount.ts +1 -1
- package/src/actions/public/getTransactionReceipt.ts +2 -2
- package/src/actions/public/multicall.ts +1 -1
- package/src/actions/public/readContract.ts +2 -2
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/public/uninstallFilter.ts +3 -3
- package/src/actions/public/waitForTransactionReceipt.ts +33 -11
- package/src/actions/public/watchBlockNumber.ts +2 -1
- package/src/actions/public/watchBlocks.ts +2 -1
- package/src/actions/public/watchContractEvent.ts +3 -2
- package/src/actions/public/watchEvent.ts +4 -3
- package/src/actions/public/watchPendingTransactions.ts +2 -1
- package/src/actions/test/setBlockTimestampInterval.ts +1 -1
- package/src/actions/test/stopImpersonatingAccount.ts +1 -1
- package/src/actions/wallet/deployContract.ts +1 -1
- package/src/actions/wallet/signMessage.ts +2 -2
- package/src/actions/wallet/writeContract.ts +3 -3
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createTestClient.ts +4 -4
- package/src/clients/createWalletClient.ts +2 -2
- package/src/clients/decorators/public.ts +22 -22
- package/src/clients/decorators/test.ts +2 -2
- package/src/clients/decorators/wallet.ts +6 -6
- package/src/errors/abi.ts +0 -2
- package/src/errors/ccip.ts +2 -1
- package/src/errors/data.ts +8 -2
- package/src/errors/rpc.ts +42 -15
- package/src/errors/version.ts +1 -1
- package/src/index.ts +8 -3
- package/src/types/contract.ts +11 -87
- package/src/types/eip1193.ts +10 -13
- package/src/types/log.ts +2 -2
- package/src/utils/abi/decodeAbiParameters.ts +36 -15
- package/src/utils/abi/decodeEventLog.ts +5 -5
- package/src/utils/buildRequest.ts +5 -1
- package/src/utils/data/isHex.ts +5 -2
- package/src/utils/data/size.ts +1 -1
- package/src/utils/data/slice.ts +43 -11
- package/src/utils/data/trim.ts +3 -1
- package/src/utils/encoding/fromHex.ts +3 -3
- package/src/utils/hash/keccak256.ts +3 -1
- package/src/utils/promise/createBatchScheduler.ts +24 -7
- package/src/utils/rpc.ts +59 -49
- package/src/utils/signature/recoverPublicKey.ts +2 -1
- package/src/utils/transaction/prepareRequest.ts +1 -2
- package/src/utils/transaction/serializeTransaction.ts +3 -2
- package/test/package.json +5 -0
- package/utils/package.json +5 -0
- package/wallet/package.json +5 -0
- package/window/package.json +5 -0
@@ -9,6 +9,8 @@ import type { Chain } from '../../types/chain.js'
|
|
9
9
|
import type { Hash } from '../../types/misc.js'
|
10
10
|
import type { Transaction } from '../../types/transaction.js'
|
11
11
|
import { observe } from '../../utils/observe.js'
|
12
|
+
import { withRetry } from '../../utils/promise/withRetry.js'
|
13
|
+
import { stringify } from '../../utils/stringify.js'
|
12
14
|
|
13
15
|
import { getBlock } from './getBlock.js'
|
14
16
|
import {
|
@@ -106,16 +108,12 @@ export async function waitForTransactionReceipt<
|
|
106
108
|
timeout,
|
107
109
|
}: WaitForTransactionReceiptParameters<TChain>,
|
108
110
|
): Promise<WaitForTransactionReceiptReturnType<TChain>> {
|
109
|
-
const observerId =
|
110
|
-
'waitForTransactionReceipt',
|
111
|
-
client.uid,
|
112
|
-
hash,
|
113
|
-
])
|
111
|
+
const observerId = stringify(['waitForTransactionReceipt', client.uid, hash])
|
114
112
|
|
115
113
|
let transaction: GetTransactionReturnType<TChain> | undefined
|
116
114
|
let replacedTransaction: GetTransactionReturnType<TChain> | undefined
|
117
115
|
let receipt: GetTransactionReceiptReturnType<TChain>
|
118
|
-
let
|
116
|
+
let retrying = false
|
119
117
|
|
120
118
|
return new Promise((resolve, reject) => {
|
121
119
|
if (timeout)
|
@@ -133,7 +131,11 @@ export async function waitForTransactionReceipt<
|
|
133
131
|
emitOnBegin: true,
|
134
132
|
poll: true,
|
135
133
|
pollingInterval,
|
136
|
-
async onBlockNumber(
|
134
|
+
async onBlockNumber(blockNumber_) {
|
135
|
+
if (retrying) return
|
136
|
+
|
137
|
+
let blockNumber = blockNumber_
|
138
|
+
|
137
139
|
const done = async (fn: () => void) => {
|
138
140
|
unwatch()
|
139
141
|
fn()
|
@@ -152,13 +154,34 @@ export async function waitForTransactionReceipt<
|
|
152
154
|
}
|
153
155
|
|
154
156
|
// Get the transaction to check if it's been replaced.
|
155
|
-
|
157
|
+
// We need to retry as some RPC Providers may be slow to sync
|
158
|
+
// up mined transactions.
|
159
|
+
if (!transaction) {
|
160
|
+
retrying = true
|
161
|
+
await withRetry(
|
162
|
+
async () => {
|
163
|
+
transaction = await getTransaction(client, { hash })
|
164
|
+
if (transaction.blockNumber)
|
165
|
+
blockNumber = transaction.blockNumber
|
166
|
+
},
|
167
|
+
{
|
168
|
+
// exponential backoff
|
169
|
+
delay: ({ count }) => ~~(1 << count) * 200,
|
170
|
+
retryCount: 6,
|
171
|
+
},
|
172
|
+
)
|
173
|
+
retrying = false
|
174
|
+
}
|
156
175
|
|
157
176
|
// Get the receipt to check if it's been processed.
|
158
177
|
receipt = await getTransactionReceipt(client, { hash })
|
159
178
|
|
160
179
|
// Check if we have enough confirmations. If not, continue polling.
|
161
|
-
if (
|
180
|
+
if (
|
181
|
+
confirmations > 0 &&
|
182
|
+
blockNumber - receipt.blockNumber + 1n < confirmations
|
183
|
+
)
|
184
|
+
return
|
162
185
|
|
163
186
|
done(() => emit.resolve(receipt))
|
164
187
|
} catch (err) {
|
@@ -220,8 +243,7 @@ export async function waitForTransactionReceipt<
|
|
220
243
|
emit.resolve(receipt)
|
221
244
|
})
|
222
245
|
} else {
|
223
|
-
|
224
|
-
retries++
|
246
|
+
done(() => emit.reject(err))
|
225
247
|
}
|
226
248
|
}
|
227
249
|
},
|
@@ -5,6 +5,7 @@ import type { GetTransportConfig } from '../../types/transport.js'
|
|
5
5
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
6
6
|
import { observe } from '../../utils/observe.js'
|
7
7
|
import { poll } from '../../utils/poll.js'
|
8
|
+
import { stringify } from '../../utils/stringify.js'
|
8
9
|
|
9
10
|
import {
|
10
11
|
type GetBlockNumberReturnType,
|
@@ -92,7 +93,7 @@ export function watchBlockNumber<
|
|
92
93
|
let prevBlockNumber: GetBlockNumberReturnType | undefined
|
93
94
|
|
94
95
|
const pollBlockNumber = () => {
|
95
|
-
const observerId =
|
96
|
+
const observerId = stringify([
|
96
97
|
'watchBlockNumber',
|
97
98
|
client.uid,
|
98
99
|
emitOnBegin,
|
@@ -5,6 +5,7 @@ import type { Chain } from '../../types/chain.js'
|
|
5
5
|
import type { GetTransportConfig } from '../../types/transport.js'
|
6
6
|
import { observe } from '../../utils/observe.js'
|
7
7
|
import { poll } from '../../utils/poll.js'
|
8
|
+
import { stringify } from '../../utils/stringify.js'
|
8
9
|
|
9
10
|
import { type GetBlockReturnType, getBlock } from './getBlock.js'
|
10
11
|
|
@@ -100,7 +101,7 @@ export function watchBlocks<
|
|
100
101
|
let prevBlock: GetBlockReturnType<TChain> | undefined
|
101
102
|
|
102
103
|
const pollBlocks = () => {
|
103
|
-
const observerId =
|
104
|
+
const observerId = stringify([
|
104
105
|
'watchBlocks',
|
105
106
|
client.uid,
|
106
107
|
emitMissed,
|
@@ -12,6 +12,7 @@ import {
|
|
12
12
|
} from '../../utils/abi/getAbiItem.js'
|
13
13
|
import { observe } from '../../utils/observe.js'
|
14
14
|
import { poll } from '../../utils/poll.js'
|
15
|
+
import { stringify } from '../../utils/stringify.js'
|
15
16
|
|
16
17
|
import {
|
17
18
|
type CreateContractEventFilterParameters,
|
@@ -63,7 +64,7 @@ export type WatchContractEventReturnType = () => void
|
|
63
64
|
*
|
64
65
|
* This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent.html#onLogs).
|
65
66
|
*
|
66
|
-
* `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.
|
67
|
+
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter.html) 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.
|
67
68
|
*
|
68
69
|
* @param client - Client to use
|
69
70
|
* @param parameters - {@link WatchContractEventParameters}
|
@@ -103,7 +104,7 @@ export function watchContractEvent<
|
|
103
104
|
pollingInterval = client.pollingInterval,
|
104
105
|
}: WatchContractEventParameters<TAbi, TEventName>,
|
105
106
|
): WatchContractEventReturnType {
|
106
|
-
const observerId =
|
107
|
+
const observerId = stringify([
|
107
108
|
'watchContractEvent',
|
108
109
|
address,
|
109
110
|
args,
|
@@ -11,6 +11,7 @@ import type { Filter } from '../../types/filter.js'
|
|
11
11
|
import type { Log } from '../../types/log.js'
|
12
12
|
import { observe } from '../../utils/observe.js'
|
13
13
|
import { poll } from '../../utils/poll.js'
|
14
|
+
import { stringify } from '../../utils/stringify.js'
|
14
15
|
|
15
16
|
import {
|
16
17
|
type CreateEventFilterParameters,
|
@@ -61,7 +62,7 @@ export type WatchEventParameters<
|
|
61
62
|
export type WatchEventReturnType = () => void
|
62
63
|
|
63
64
|
/**
|
64
|
-
* Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).
|
65
|
+
* Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms.html#event-log).
|
65
66
|
*
|
66
67
|
* - Docs: https://viem.sh/docs/actions/public/watchEvent.html
|
67
68
|
* - JSON-RPC Methods:
|
@@ -73,7 +74,7 @@ export type WatchEventReturnType = () => void
|
|
73
74
|
*
|
74
75
|
* This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent.html#onLogs).
|
75
76
|
*
|
76
|
-
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter.html) 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.
|
77
|
+
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter.html) 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.html) instead.
|
77
78
|
*
|
78
79
|
* @param client - Client to use
|
79
80
|
* @param parameters - {@link WatchEventParameters}
|
@@ -108,7 +109,7 @@ export function watchEvent<
|
|
108
109
|
pollingInterval = client.pollingInterval,
|
109
110
|
}: WatchEventParameters<TAbiEvent>,
|
110
111
|
): WatchEventReturnType {
|
111
|
-
const observerId =
|
112
|
+
const observerId = stringify([
|
112
113
|
'watchEvent',
|
113
114
|
address,
|
114
115
|
args,
|
@@ -6,6 +6,7 @@ import type { Hash } from '../../types/misc.js'
|
|
6
6
|
import type { GetTransportConfig } from '../../types/transport.js'
|
7
7
|
import { observe } from '../../utils/observe.js'
|
8
8
|
import { poll } from '../../utils/poll.js'
|
9
|
+
import { stringify } from '../../utils/stringify.js'
|
9
10
|
|
10
11
|
import { createPendingTransactionFilter } from './createPendingTransactionFilter.js'
|
11
12
|
import { getFilterChanges } from './getFilterChanges.js'
|
@@ -104,7 +105,7 @@ export function watchPendingTransactions<
|
|
104
105
|
typeof poll_ !== 'undefined' ? poll_ : client.transport.type !== 'webSocket'
|
105
106
|
|
106
107
|
const pollPendingTransactions = () => {
|
107
|
-
const observerId =
|
108
|
+
const observerId = stringify([
|
108
109
|
'watchPendingTransactions',
|
109
110
|
client.uid,
|
110
111
|
batch,
|
@@ -11,7 +11,7 @@ export type SetBlockTimestampIntervalParameters = {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
/**
|
14
|
-
* Similar to [`increaseTime`](https://viem.sh/docs/actions/test/increaseTime), but sets a block timestamp `interval`. The timestamp of future blocks will be computed as `lastBlock_timestamp` + `interval`.
|
14
|
+
* Similar to [`increaseTime`](https://viem.sh/docs/actions/test/increaseTime.html), but sets a block timestamp `interval`. The timestamp of future blocks will be computed as `lastBlock_timestamp` + `interval`.
|
15
15
|
*
|
16
16
|
* - Docs: https://viem.sh/docs/actions/test/setBlockTimestampInterval.html
|
17
17
|
*
|
@@ -13,7 +13,7 @@ export type StopImpersonatingAccountParameters = {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
/**
|
16
|
-
* Stop impersonating an account after having previously used [`impersonateAccount`](https://viem.sh/docs/actions/test/impersonateAccount).
|
16
|
+
* Stop impersonating an account after having previously used [`impersonateAccount`](https://viem.sh/docs/actions/test/impersonateAccount.html).
|
17
17
|
*
|
18
18
|
* - Docs: https://viem.sh/docs/actions/test/stopImpersonatingAccount.html
|
19
19
|
*
|
@@ -38,7 +38,7 @@ export type DeployContractReturnType = SendTransactionReturnType
|
|
38
38
|
*
|
39
39
|
* @param client - Client to use
|
40
40
|
* @param parameters - {@link DeployContractParameters}
|
41
|
-
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}
|
41
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link DeployContractReturnType}
|
42
42
|
*
|
43
43
|
* @example
|
44
44
|
* import { createWalletClient, http } from 'viem'
|
@@ -25,8 +25,8 @@ export type SignMessageReturnType = Hex
|
|
25
25
|
* - Local Accounts: Signs locally. No JSON-RPC request.
|
26
26
|
*
|
27
27
|
* With the calculated signature, you can:
|
28
|
-
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,
|
29
|
-
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress) to recover the signing address from a signature.
|
28
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
29
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
30
30
|
*
|
31
31
|
* @param client - Client to use
|
32
32
|
* @param parameters - {@link SignMessageParameters}
|
@@ -42,15 +42,15 @@ export type WriteContractReturnType = SendTransactionReturnType
|
|
42
42
|
* - Docs: https://viem.sh/docs/contract/writeContract.html
|
43
43
|
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
44
44
|
*
|
45
|
-
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.
|
45
|
+
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms.html) is needed to be broadcast in order to change the state.
|
46
46
|
*
|
47
|
-
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
47
|
+
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet.html) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
48
48
|
*
|
49
49
|
* __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract.html#usage) before you execute it.__
|
50
50
|
*
|
51
51
|
* @param client - Client to use
|
52
52
|
* @param parameters - {@link WriteContractParameters}
|
53
|
-
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms#hash). {@link WriteContractReturnType}
|
53
|
+
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms.html#hash). {@link WriteContractReturnType}
|
54
54
|
*
|
55
55
|
* @example
|
56
56
|
* import { createWalletClient, custom, parseAbi } from 'viem'
|
@@ -38,7 +38,7 @@ export type PublicClient<
|
|
38
38
|
>
|
39
39
|
|
40
40
|
/**
|
41
|
-
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
41
|
+
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
42
42
|
*
|
43
43
|
* - Docs: https://viem.sh/docs/clients/public.html
|
44
44
|
*
|
@@ -5,7 +5,7 @@ import { type Client, type ClientConfig, createClient } from './createClient.js'
|
|
5
5
|
import { type TestActions, testActions } from './decorators/test.js'
|
6
6
|
import type { Transport } from './transports/createTransport.js'
|
7
7
|
|
8
|
-
export type TestClientMode = 'anvil' | 'hardhat'
|
8
|
+
export type TestClientMode = 'anvil' | 'hardhat' | 'ganache'
|
9
9
|
|
10
10
|
export type TestClientConfig<
|
11
11
|
TMode extends TestClientMode = TestClientMode,
|
@@ -15,7 +15,7 @@ export type TestClientConfig<
|
|
15
15
|
ClientConfig<TTransport, TChain>,
|
16
16
|
'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
17
17
|
> & {
|
18
|
-
/** Mode of the test client. Available: "anvil" | "hardhat" */
|
18
|
+
/** Mode of the test client. Available: "anvil" | "hardhat" | "ganache" */
|
19
19
|
mode: TMode
|
20
20
|
}
|
21
21
|
|
@@ -33,11 +33,11 @@ export type TestClient<
|
|
33
33
|
* @description Creates a test client with a given transport.
|
34
34
|
*/
|
35
35
|
/**
|
36
|
-
* Creates a Test Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
36
|
+
* Creates a Test Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
37
37
|
*
|
38
38
|
* - Docs: https://viem.sh/docs/clients/test.html
|
39
39
|
*
|
40
|
-
* A Test Client is an interface to "test" JSON-RPC API methods accessible through a local Ethereum test node such as [Anvil](https://book.getfoundry.sh/anvil/) or [Hardhat](https://hardhat.org/) such as mining blocks, impersonating accounts, setting fees, etc through [Test Actions](https://viem.sh/docs/actions/test/introduction).
|
40
|
+
* A Test Client is an interface to "test" JSON-RPC API methods accessible through a local Ethereum test node such as [Anvil](https://book.getfoundry.sh/anvil/) or [Hardhat](https://hardhat.org/) such as mining blocks, impersonating accounts, setting fees, etc through [Test Actions](https://viem.sh/docs/actions/test/introduction.html).
|
41
41
|
*
|
42
42
|
* @param config - {@link TestClientConfig}
|
43
43
|
* @returns A Test Client. {@link TestClient}
|
@@ -41,11 +41,11 @@ export type WalletClient<
|
|
41
41
|
>
|
42
42
|
|
43
43
|
/**
|
44
|
-
* Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
44
|
+
* Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
45
45
|
*
|
46
46
|
* - Docs: https://viem.sh/docs/clients/wallet.html
|
47
47
|
*
|
48
|
-
* A Wallet Client is an interface to interact with [Ethereum Account(s)](https://ethereum.org/en/glossary/#account) and provides the ability to retrieve accounts, execute transactions, sign messages, etc. through [Wallet Actions](https://viem.sh/docs/actions/wallet/introduction).
|
48
|
+
* A Wallet Client is an interface to interact with [Ethereum Account(s)](https://ethereum.org/en/glossary/#account) and provides the ability to retrieve accounts, execute transactions, sign messages, etc. through [Wallet Actions](https://viem.sh/docs/actions/wallet/introduction.html).
|
49
49
|
*
|
50
50
|
* The Wallet Client supports signing over:
|
51
51
|
* - [JSON-RPC Accounts](https://viem.sh/docs/clients/wallet.html#json-rpc-accounts) (e.g. Browser Extension Wallets, WalletConnect, etc).
|
@@ -234,7 +234,7 @@ export type PublicActions<
|
|
234
234
|
*/
|
235
235
|
call: (parameters: CallParameters<TChain>) => Promise<CallReturnType>
|
236
236
|
/**
|
237
|
-
* Creates a Filter to listen for new block hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
237
|
+
* Creates a Filter to listen for new block hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html).
|
238
238
|
*
|
239
239
|
* - Docs: https://viem.sh/docs/actions/public/createBlockFilter.html
|
240
240
|
* - JSON-RPC Methods: [`eth_newBlockFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newBlockFilter)
|
@@ -254,7 +254,7 @@ export type PublicActions<
|
|
254
254
|
*/
|
255
255
|
createBlockFilter: () => Promise<CreateBlockFilterReturnType>
|
256
256
|
/**
|
257
|
-
* Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs).
|
257
|
+
* Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs.html).
|
258
258
|
*
|
259
259
|
* - Docs: https://viem.sh/docs/contract/createContractEventFilter.html
|
260
260
|
*
|
@@ -281,7 +281,7 @@ export type PublicActions<
|
|
281
281
|
args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs>,
|
282
282
|
) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs>>
|
283
283
|
/**
|
284
|
-
* Creates a [`Filter`](https://viem.sh/docs/glossary/types.html#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
284
|
+
* Creates a [`Filter`](https://viem.sh/docs/glossary/types.html#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html).
|
285
285
|
*
|
286
286
|
* - Docs: https://viem.sh/docs/actions/public/createEventFilter.html
|
287
287
|
* - JSON-RPC Methods: [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)
|
@@ -310,7 +310,7 @@ export type PublicActions<
|
|
310
310
|
args?: CreateEventFilterParameters<TAbiEvent, TAbi, TEventName, TArgs>,
|
311
311
|
) => Promise<CreateEventFilterReturnType<TAbiEvent, TAbi, TEventName, TArgs>>
|
312
312
|
/**
|
313
|
-
* Creates a Filter to listen for new pending transaction hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
313
|
+
* Creates a Filter to listen for new pending transaction hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html).
|
314
314
|
*
|
315
315
|
* - Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter.html
|
316
316
|
* - JSON-RPC Methods: [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter)
|
@@ -335,7 +335,7 @@ export type PublicActions<
|
|
335
335
|
* - Docs: https://viem.sh/docs/contract/estimateContractGas.html
|
336
336
|
*
|
337
337
|
* @remarks
|
338
|
-
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`estimateGas` action](https://viem.sh/docs/actions/public/estimateGas) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
338
|
+
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public.html) to call the [`estimateGas` action](https://viem.sh/docs/actions/public/estimateGas.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
339
339
|
*
|
340
340
|
* @param args - {@link EstimateContractGasParameters}
|
341
341
|
* @returns The gas estimate (in wei). {@link EstimateContractGasReturnType}
|
@@ -719,10 +719,10 @@ export type PublicActions<
|
|
719
719
|
* @remarks
|
720
720
|
* A Filter can be created from the following actions:
|
721
721
|
*
|
722
|
-
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
723
|
-
* - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)
|
724
|
-
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
725
|
-
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
722
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter.html)
|
723
|
+
* - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter.html)
|
724
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter.html)
|
725
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter.html)
|
726
726
|
*
|
727
727
|
* Depending on the type of filter, the return value will be different:
|
728
728
|
*
|
@@ -896,7 +896,7 @@ export type PublicActions<
|
|
896
896
|
args: GetStorageAtParameters,
|
897
897
|
) => Promise<GetStorageAtReturnType>
|
898
898
|
/**
|
899
|
-
* Returns information about a [Transaction](https://viem.sh/docs/glossary/terms#transaction) given a hash or block identifier.
|
899
|
+
* Returns information about a [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) given a hash or block identifier.
|
900
900
|
*
|
901
901
|
* - Docs: https://viem.sh/docs/actions/public/getTransaction.html
|
902
902
|
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions
|
@@ -946,7 +946,7 @@ export type PublicActions<
|
|
946
946
|
args: GetTransactionConfirmationsParameters<TChain>,
|
947
947
|
) => Promise<GetTransactionConfirmationsReturnType>
|
948
948
|
/**
|
949
|
-
* Returns the number of [Transactions](https://viem.sh/docs/glossary/terms#transaction) an Account has broadcast / sent.
|
949
|
+
* Returns the number of [Transactions](https://viem.sh/docs/glossary/terms.html#transaction) an Account has broadcast / sent.
|
950
950
|
*
|
951
951
|
* - Docs: https://viem.sh/docs/actions/public/getTransactionCount.html
|
952
952
|
* - JSON-RPC Methods: [`eth_getTransactionCount`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount)
|
@@ -970,7 +970,7 @@ export type PublicActions<
|
|
970
970
|
args: GetTransactionCountParameters,
|
971
971
|
) => Promise<GetTransactionCountReturnType>
|
972
972
|
/**
|
973
|
-
* Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.
|
973
|
+
* Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms.html#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.
|
974
974
|
*
|
975
975
|
* - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt.html
|
976
976
|
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions
|
@@ -995,7 +995,7 @@ export type PublicActions<
|
|
995
995
|
args: GetTransactionReceiptParameters,
|
996
996
|
) => Promise<GetTransactionReceiptReturnType<TChain>>
|
997
997
|
/**
|
998
|
-
* 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).
|
998
|
+
* Similar to [`readContract`](https://viem.sh/docs/contract/readContract.html), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).
|
999
999
|
*
|
1000
1000
|
* - Docs: https://viem.sh/docs/contract/multicall.html
|
1001
1001
|
*
|
@@ -1046,7 +1046,7 @@ export type PublicActions<
|
|
1046
1046
|
* @remarks
|
1047
1047
|
* A "read-only" function (constant function) on a Solidity contract is denoted by a `view` or `pure` keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.
|
1048
1048
|
*
|
1049
|
-
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
1049
|
+
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public.html) to call the [`call` action](https://viem.sh/docs/actions/public/call.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
1050
1050
|
*
|
1051
1051
|
* @param args - {@link ReadContractParameters}
|
1052
1052
|
* @returns The response from the contract. Type is inferred. {@link ReadContractReturnType}
|
@@ -1081,9 +1081,9 @@ export type PublicActions<
|
|
1081
1081
|
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
1082
1082
|
*
|
1083
1083
|
* @remarks
|
1084
|
-
* This function does not require gas to execute and _**does not**_ change the state of the blockchain. It is almost identical to [`readContract`](https://viem.sh/docs/contract/readContract), but also supports contract write functions.
|
1084
|
+
* This function does not require gas to execute and _**does not**_ change the state of the blockchain. It is almost identical to [`readContract`](https://viem.sh/docs/contract/readContract.html), but also supports contract write functions.
|
1085
1085
|
*
|
1086
|
-
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
1086
|
+
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public.html) to call the [`call` action](https://viem.sh/docs/actions/public/call.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
1087
1087
|
*
|
1088
1088
|
* @param args - {@link SimulateContractParameters}
|
1089
1089
|
* @returns The simulation result and write request. {@link SimulateContractReturnType}
|
@@ -1127,9 +1127,9 @@ export type PublicActions<
|
|
1127
1127
|
/**
|
1128
1128
|
* Destroys a Filter that was created from one of the following Actions:
|
1129
1129
|
*
|
1130
|
-
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
1131
|
-
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
1132
|
-
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
1130
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter.html)
|
1131
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter.html)
|
1132
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter.html)
|
1133
1133
|
*
|
1134
1134
|
* - Docs: https://viem.sh/docs/actions/public/uninstallFilter.html
|
1135
1135
|
* - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)
|
@@ -1252,7 +1252,7 @@ export type PublicActions<
|
|
1252
1252
|
* @remarks
|
1253
1253
|
* This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent.html#onLogs).
|
1254
1254
|
*
|
1255
|
-
* `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.
|
1255
|
+
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter.html) 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.html) instead.
|
1256
1256
|
*
|
1257
1257
|
* @param args - {@link WatchContractEventParameters}
|
1258
1258
|
* @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}
|
@@ -1280,7 +1280,7 @@ export type PublicActions<
|
|
1280
1280
|
args: WatchContractEventParameters<TAbi, TEventName>,
|
1281
1281
|
) => WatchContractEventReturnType
|
1282
1282
|
/**
|
1283
|
-
* Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).
|
1283
|
+
* Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms.html#event-log).
|
1284
1284
|
*
|
1285
1285
|
* - Docs: https://viem.sh/docs/actions/public/watchEvent.html
|
1286
1286
|
* - JSON-RPC Methods:
|
@@ -1293,7 +1293,7 @@ export type PublicActions<
|
|
1293
1293
|
* @remarks
|
1294
1294
|
* This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent.html#onLogs).
|
1295
1295
|
*
|
1296
|
-
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter.html) 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.
|
1296
|
+
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter.html) 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.html) instead.
|
1297
1297
|
*
|
1298
1298
|
* @param args - {@link WatchEventParameters}
|
1299
1299
|
* @returns A function that can be invoked to stop watching for new Event Logs. {@link WatchEventReturnType}
|
@@ -390,7 +390,7 @@ export type TestActions = {
|
|
390
390
|
*/
|
391
391
|
setBlockGasLimit: (args: SetBlockGasLimitParameters) => Promise<void>
|
392
392
|
/**
|
393
|
-
* Similar to [`increaseTime`](https://viem.sh/docs/actions/test/increaseTime), but sets a block timestamp `interval`. The timestamp of future blocks will be computed as `lastBlock_timestamp` + `interval`.
|
393
|
+
* Similar to [`increaseTime`](https://viem.sh/docs/actions/test/increaseTime.html), but sets a block timestamp `interval`. The timestamp of future blocks will be computed as `lastBlock_timestamp` + `interval`.
|
394
394
|
*
|
395
395
|
* - Docs: https://viem.sh/docs/actions/test/setBlockTimestampInterval.html
|
396
396
|
*
|
@@ -641,7 +641,7 @@ export type TestActions = {
|
|
641
641
|
*/
|
642
642
|
snapshot: () => Promise<Quantity>
|
643
643
|
/**
|
644
|
-
* Stop impersonating an account after having previously used [`impersonateAccount`](https://viem.sh/docs/actions/test/impersonateAccount).
|
644
|
+
* Stop impersonating an account after having previously used [`impersonateAccount`](https://viem.sh/docs/actions/test/impersonateAccount.html).
|
645
645
|
*
|
646
646
|
* - Docs: https://viem.sh/docs/actions/test/stopImpersonatingAccount.html
|
647
647
|
*
|
@@ -93,7 +93,7 @@ export type WalletActions<
|
|
93
93
|
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts
|
94
94
|
*
|
95
95
|
* @param args - {@link DeployContractParameters}
|
96
|
-
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}
|
96
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link DeployContractReturnType}
|
97
97
|
*
|
98
98
|
* @example
|
99
99
|
* import { createWalletClient, http } from 'viem'
|
@@ -276,8 +276,8 @@ export type WalletActions<
|
|
276
276
|
* - Local Accounts: Signs locally. No JSON-RPC request.
|
277
277
|
*
|
278
278
|
* With the calculated signature, you can:
|
279
|
-
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,
|
280
|
-
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress) to recover the signing address from a signature.
|
279
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
280
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
281
281
|
*
|
282
282
|
* @param args - {@link SignMessageParameters}
|
283
283
|
* @returns The signed message. {@link SignMessageReturnType}
|
@@ -467,14 +467,14 @@ export type WalletActions<
|
|
467
467
|
* - Docs: https://viem.sh/docs/contract/writeContract.html
|
468
468
|
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
469
469
|
*
|
470
|
-
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.
|
470
|
+
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms.html) is needed to be broadcast in order to change the state.
|
471
471
|
*
|
472
|
-
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
472
|
+
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet.html) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
473
473
|
*
|
474
474
|
* __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract.html#usage) before you execute it.__
|
475
475
|
*
|
476
476
|
* @param args - {@link WriteContractParameters}
|
477
|
-
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms#hash). {@link WriteContractReturnType}
|
477
|
+
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms.html#hash). {@link WriteContractReturnType}
|
478
478
|
*
|
479
479
|
* @example
|
480
480
|
* import { createWalletClient, custom, parseAbi } from 'viem'
|
package/src/errors/abi.ts
CHANGED
@@ -293,8 +293,6 @@ export class DecodeLogDataMismatch extends BaseError {
|
|
293
293
|
].join('\n'),
|
294
294
|
{
|
295
295
|
metaMessages: [
|
296
|
-
'This error is usually caused if the ABI event has too many non-indexed event parameters for the emitted log.',
|
297
|
-
'',
|
298
296
|
`Params: (${formatAbiParams(params, { includeName: true })})`,
|
299
297
|
`Data: ${data} (${size} bytes)`,
|
300
298
|
],
|
package/src/errors/ccip.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Hex } from '../types/misc.js'
|
4
|
+
import { stringify } from '../utils/stringify.js'
|
4
5
|
|
5
6
|
import { BaseError } from './base.js'
|
6
7
|
import { getUrl } from './utils.js'
|
@@ -53,7 +54,7 @@ export class OffchainLookupResponseMalformedError extends BaseError {
|
|
53
54
|
{
|
54
55
|
metaMessages: [
|
55
56
|
`Gateway URL: ${getUrl(url)}`,
|
56
|
-
`Response: ${
|
57
|
+
`Response: ${stringify(result)}`,
|
57
58
|
],
|
58
59
|
},
|
59
60
|
)
|
package/src/errors/data.ts
CHANGED
@@ -2,9 +2,15 @@ import { BaseError } from './base.js'
|
|
2
2
|
|
3
3
|
export class SliceOffsetOutOfBoundsError extends BaseError {
|
4
4
|
override name = 'SliceOffsetOutOfBoundsError'
|
5
|
-
constructor({
|
5
|
+
constructor({
|
6
|
+
offset,
|
7
|
+
position,
|
8
|
+
size,
|
9
|
+
}: { offset: number; position: 'start' | 'end'; size: number }) {
|
6
10
|
super(
|
7
|
-
`Slice
|
11
|
+
`Slice ${
|
12
|
+
position === 'start' ? 'starting' : 'ending'
|
13
|
+
} at offset "${offset}" is out-of-bounds (size: ${size}).`,
|
8
14
|
)
|
9
15
|
}
|
10
16
|
}
|