viem 0.0.1-alpha.19 → 0.0.1-alpha.20

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.
Files changed (151) hide show
  1. package/dist/{rpc-858670f1.d.ts → chain-32f56cfa.d.ts} +68 -18
  2. package/dist/chain-f12cdc7f.d.ts +5 -0
  3. package/dist/chains.d.ts +757 -170
  4. package/dist/chains.js +80 -86
  5. package/dist/chains.js.map +1 -1
  6. package/dist/chains.mjs +120 -126
  7. package/dist/chains.mjs.map +1 -1
  8. package/dist/{chunk-PHSAQQGZ.mjs → chunk-5Q6FSUU2.mjs} +75 -37
  9. package/dist/chunk-5Q6FSUU2.mjs.map +1 -0
  10. package/dist/{chunk-24EKKMUO.js → chunk-FHXXG7I6.js} +12 -12
  11. package/dist/chunk-FHXXG7I6.js.map +1 -0
  12. package/dist/{chunk-HRE6LYF3.js → chunk-IAQPMSGJ.js} +13 -13
  13. package/dist/chunk-IAQPMSGJ.js.map +1 -0
  14. package/dist/{chunk-IVWG22RQ.mjs → chunk-MYQNZSWD.mjs} +69 -12
  15. package/dist/chunk-MYQNZSWD.mjs.map +1 -0
  16. package/dist/{chunk-NYMS65YI.js → chunk-NHAKUPTF.js} +124 -67
  17. package/dist/chunk-NHAKUPTF.js.map +1 -0
  18. package/dist/{chunk-BZFF747V.js → chunk-SF4I2NKC.js} +81 -43
  19. package/dist/chunk-SF4I2NKC.js.map +1 -0
  20. package/dist/{chunk-VAT5CEF7.mjs → chunk-T7CBAKLI.mjs} +2 -2
  21. package/dist/chunk-T7CBAKLI.mjs.map +1 -0
  22. package/dist/{chunk-CTU4PQLY.js → chunk-YFKR74XG.js} +14 -14
  23. package/dist/{chunk-CTU4PQLY.js.map → chunk-YFKR74XG.js.map} +0 -0
  24. package/dist/{chunk-NSRORL3O.mjs → chunk-YODUQCHJ.mjs} +2 -2
  25. package/dist/{chunk-NSRORL3O.mjs.map → chunk-YODUQCHJ.mjs.map} +0 -0
  26. package/dist/{chunk-E7LH5H76.mjs → chunk-ZVGTYLKU.mjs} +2 -2
  27. package/dist/chunk-ZVGTYLKU.mjs.map +1 -0
  28. package/dist/clients/index.d.ts +7 -8
  29. package/dist/clients/index.js +3 -3
  30. package/dist/clients/index.mjs +2 -2
  31. package/dist/{transactionReceipt-aed524b4.d.ts → contract-9af4608b.d.ts} +30 -18
  32. package/dist/{createClient-03ba79e8.d.ts → createClient-5d316c7e.d.ts} +2 -2
  33. package/dist/{createPublicClient-818241ba.d.ts → createPublicClient-9d2b42e1.d.ts} +3 -3
  34. package/dist/{createTestClient-24eb7be8.d.ts → createTestClient-79498dab.d.ts} +3 -3
  35. package/dist/{createWalletClient-7cbd6ad1.d.ts → createWalletClient-f69a5230.d.ts} +3 -3
  36. package/dist/{eip1193-71d8e27d.d.ts → eip1193-6c485d63.d.ts} +1 -1
  37. package/dist/index.d.ts +45 -23
  38. package/dist/index.js +10 -6
  39. package/dist/index.mjs +9 -5
  40. package/dist/{parseGwei-dbd12305.d.ts → parseGwei-4308ad80.d.ts} +17 -4
  41. package/dist/public.d.ts +9 -10
  42. package/dist/public.js +4 -4
  43. package/dist/public.mjs +3 -3
  44. package/dist/{sendTransaction-d09961a7.d.ts → sendTransaction-1c8290a9.d.ts} +3 -4
  45. package/dist/{stopImpersonatingAccount-c8a00be7.d.ts → stopImpersonatingAccount-7781842a.d.ts} +2 -2
  46. package/dist/test.d.ts +5 -6
  47. package/dist/test.js +3 -3
  48. package/dist/test.mjs +2 -2
  49. package/dist/transactionRequest-341b6ed2.d.ts +15 -0
  50. package/dist/utils/index.d.ts +9 -8
  51. package/dist/utils/index.js +22 -2
  52. package/dist/utils/index.mjs +25 -5
  53. package/dist/wallet.d.ts +7 -8
  54. package/dist/wallet.js +3 -3
  55. package/dist/wallet.mjs +2 -2
  56. package/dist/{watchAsset-c39645b7.d.ts → watchAsset-afaad3c7.d.ts} +3 -4
  57. package/dist/{watchPendingTransactions-01e6be4f.d.ts → watchPendingTransactions-3b722547.d.ts} +21 -16
  58. package/dist/{webSocket-3a00015b.d.ts → webSocket-b180e679.d.ts} +2 -2
  59. package/dist/window.d.ts +3 -2
  60. package/package.json +3 -3
  61. package/src/_test/abis.ts +188 -0
  62. package/src/_test/constants.ts +0 -3
  63. package/src/_test/index.ts +5 -2
  64. package/src/actions/index.test.ts +2 -0
  65. package/src/actions/index.ts +6 -0
  66. package/src/actions/public/call.ts +2 -1
  67. package/src/actions/public/createContractEventFilter.test.ts +119 -0
  68. package/src/actions/public/createContractEventFilter.ts +69 -0
  69. package/src/actions/public/createEventFilter.ts +5 -8
  70. package/src/actions/public/deployContract.ts +1 -2
  71. package/src/actions/public/getBlock.test.ts +3 -3
  72. package/src/actions/public/getBlock.ts +1 -2
  73. package/src/actions/public/getBlockTransactionCount.ts +1 -2
  74. package/src/actions/public/getFilterChanges.test.ts +9 -7
  75. package/src/actions/public/getFilterLogs.test.ts +7 -5
  76. package/src/actions/public/getLogs.test.ts +7 -5
  77. package/src/actions/public/getLogs.ts +3 -2
  78. package/src/actions/public/getTransaction.ts +1 -2
  79. package/src/actions/public/getTransactionConfirmations.ts +1 -2
  80. package/src/actions/public/getTransactionReceipt.test.ts +24 -62
  81. package/src/actions/public/getTransactionReceipt.ts +1 -2
  82. package/src/actions/public/index.test.ts +4 -0
  83. package/src/actions/public/index.ts +18 -0
  84. package/src/actions/public/readContract.ts +1 -1
  85. package/src/actions/public/simulateContract.ts +1 -1
  86. package/src/actions/public/waitForTransactionReceipt.ts +1 -2
  87. package/src/actions/public/watchBlocks.test.ts +27 -2
  88. package/src/actions/public/watchBlocks.ts +33 -14
  89. package/src/actions/public/watchContractEvent.test.ts +301 -0
  90. package/src/actions/public/watchContractEvent.ts +108 -0
  91. package/src/actions/public/watchEvent.test.ts +190 -0
  92. package/src/actions/public/watchEvent.ts +95 -0
  93. package/src/actions/public/watchPendingTransactions.ts +1 -0
  94. package/src/actions/wallet/addChain.ts +1 -1
  95. package/src/actions/wallet/sendTransaction.ts +2 -1
  96. package/src/actions/wallet/switchChain.ts +1 -1
  97. package/src/actions/wallet/writeContract.ts +1 -1
  98. package/src/chains.test.ts +830 -52
  99. package/src/chains.ts +90 -158
  100. package/src/clients/createClient.ts +1 -1
  101. package/src/clients/createPublicClient.ts +1 -1
  102. package/src/clients/createTestClient.ts +1 -1
  103. package/src/clients/createWalletClient.ts +1 -1
  104. package/src/clients/transports/createTransport.ts +1 -1
  105. package/src/index.test.ts +2 -0
  106. package/src/index.ts +10 -2
  107. package/src/types/chain.ts +6 -0
  108. package/src/types/contract.ts +17 -2
  109. package/src/types/formatter.ts +23 -0
  110. package/src/types/index.ts +6 -0
  111. package/src/types/transaction.ts +1 -1
  112. package/src/utils/abi/decodeErrorResult.ts +2 -2
  113. package/src/utils/abi/decodeFunctionData.ts +2 -2
  114. package/src/utils/abi/encodeErrorResult.ts +2 -2
  115. package/src/utils/abi/encodeEventTopics.ts +4 -4
  116. package/src/utils/abi/encodeFunctionData.ts +2 -2
  117. package/src/utils/abi/{formatAbiItemWithParams.test.ts → formatAbiItem.test.ts} +11 -11
  118. package/src/utils/abi/{formatAbiItemWithParams.ts → formatAbiItem.ts} +1 -1
  119. package/src/utils/abi/index.test.ts +1 -1
  120. package/src/utils/abi/index.ts +1 -1
  121. package/src/utils/chain.test.ts +43 -0
  122. package/src/utils/chain.ts +8 -0
  123. package/src/utils/contract/getContractError.ts +2 -6
  124. package/src/utils/formatters/block.ts +4 -3
  125. package/src/utils/formatters/extract.ts +1 -1
  126. package/src/utils/formatters/format.ts +39 -2
  127. package/src/utils/formatters/index.test.ts +10 -0
  128. package/src/utils/formatters/index.ts +15 -5
  129. package/src/utils/formatters/transaction.ts +16 -4
  130. package/src/utils/formatters/transactionReceipt.ts +13 -4
  131. package/src/utils/formatters/transactionRequest.ts +12 -3
  132. package/src/utils/hash/getEventSignature.ts +2 -2
  133. package/src/utils/index.test.ts +24 -1
  134. package/src/utils/index.ts +12 -1
  135. package/src/{constants.test.ts → utils/unit/constants.test.ts} +0 -5
  136. package/src/{constants.ts → utils/unit/constants.ts} +0 -6
  137. package/src/utils/unit/formatEther.ts +1 -1
  138. package/src/utils/unit/formatGwei.ts +1 -1
  139. package/src/utils/unit/index.test.ts +12 -0
  140. package/src/utils/unit/index.ts +1 -0
  141. package/src/utils/unit/parseEther.ts +1 -1
  142. package/src/utils/unit/parseGwei.ts +1 -1
  143. package/dist/chunk-24EKKMUO.js.map +0 -1
  144. package/dist/chunk-BZFF747V.js.map +0 -1
  145. package/dist/chunk-E7LH5H76.mjs.map +0 -1
  146. package/dist/chunk-HRE6LYF3.js.map +0 -1
  147. package/dist/chunk-IVWG22RQ.mjs.map +0 -1
  148. package/dist/chunk-NYMS65YI.js.map +0 -1
  149. package/dist/chunk-PHSAQQGZ.mjs.map +0 -1
  150. package/dist/chunk-VAT5CEF7.mjs.map +0 -1
  151. package/dist/transactionRequest-8e970b0e.d.ts +0 -33
package/src/_test/abis.ts CHANGED
@@ -1223,3 +1223,191 @@ export const wagmiContractConfig = {
1223
1223
  },
1224
1224
  ],
1225
1225
  } as const
1226
+
1227
+ export const usdcContractConfig = {
1228
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1229
+ abi: [
1230
+ {
1231
+ type: 'event',
1232
+ name: 'Approval',
1233
+ inputs: [
1234
+ {
1235
+ indexed: true,
1236
+ name: 'owner',
1237
+ type: 'address',
1238
+ },
1239
+ {
1240
+ indexed: true,
1241
+ name: 'spender',
1242
+ type: 'address',
1243
+ },
1244
+ {
1245
+ indexed: false,
1246
+ name: 'value',
1247
+ type: 'uint256',
1248
+ },
1249
+ ],
1250
+ },
1251
+ {
1252
+ type: 'event',
1253
+ name: 'Transfer',
1254
+ inputs: [
1255
+ {
1256
+ indexed: true,
1257
+ name: 'from',
1258
+ type: 'address',
1259
+ },
1260
+ {
1261
+ indexed: true,
1262
+ name: 'to',
1263
+ type: 'address',
1264
+ },
1265
+ {
1266
+ indexed: false,
1267
+ name: 'value',
1268
+ type: 'uint256',
1269
+ },
1270
+ ],
1271
+ },
1272
+ {
1273
+ type: 'function',
1274
+ name: 'allowance',
1275
+ stateMutability: 'view',
1276
+ inputs: [
1277
+ {
1278
+ name: 'owner',
1279
+ type: 'address',
1280
+ },
1281
+ {
1282
+ name: 'spender',
1283
+ type: 'address',
1284
+ },
1285
+ ],
1286
+ outputs: [{ type: 'uint256' }],
1287
+ },
1288
+ {
1289
+ type: 'function',
1290
+ name: 'approve',
1291
+ stateMutability: 'nonpayable',
1292
+ inputs: [
1293
+ {
1294
+ name: 'spender',
1295
+ type: 'address',
1296
+ },
1297
+ {
1298
+ name: 'amount',
1299
+ type: 'uint256',
1300
+ },
1301
+ ],
1302
+ outputs: [{ type: 'bool' }],
1303
+ },
1304
+ {
1305
+ type: 'function',
1306
+ name: 'balanceOf',
1307
+ stateMutability: 'view',
1308
+ inputs: [
1309
+ {
1310
+ name: 'account',
1311
+ type: 'address',
1312
+ },
1313
+ ],
1314
+ outputs: [{ type: 'uint256' }],
1315
+ },
1316
+ {
1317
+ type: 'function',
1318
+ name: 'decimals',
1319
+ stateMutability: 'view',
1320
+ inputs: [],
1321
+ outputs: [{ type: 'uint8' }],
1322
+ },
1323
+ {
1324
+ type: 'function',
1325
+ name: 'name',
1326
+ stateMutability: 'view',
1327
+ inputs: [],
1328
+ outputs: [{ type: 'string' }],
1329
+ },
1330
+ {
1331
+ type: 'function',
1332
+ name: 'symbol',
1333
+ stateMutability: 'view',
1334
+ inputs: [],
1335
+ outputs: [{ type: 'string' }],
1336
+ },
1337
+ {
1338
+ type: 'function',
1339
+ name: 'totalSupply',
1340
+ stateMutability: 'view',
1341
+ inputs: [],
1342
+ outputs: [{ type: 'uint256' }],
1343
+ },
1344
+ {
1345
+ type: 'function',
1346
+ name: 'transfer',
1347
+ stateMutability: 'nonpayable',
1348
+ inputs: [
1349
+ {
1350
+ name: 'recipient',
1351
+ type: 'address',
1352
+ },
1353
+ {
1354
+ name: 'amount',
1355
+ type: 'uint256',
1356
+ },
1357
+ ],
1358
+ outputs: [{ type: 'bool' }],
1359
+ },
1360
+ {
1361
+ type: 'function',
1362
+ name: 'transferFrom',
1363
+ stateMutability: 'nonpayable',
1364
+ inputs: [
1365
+ {
1366
+ name: 'sender',
1367
+ type: 'address',
1368
+ },
1369
+ {
1370
+ name: 'recipient',
1371
+ type: 'address',
1372
+ },
1373
+ {
1374
+ name: 'amount',
1375
+ type: 'uint256',
1376
+ },
1377
+ ],
1378
+ outputs: [{ type: 'bool' }],
1379
+ },
1380
+ {
1381
+ type: 'function',
1382
+ name: 'increaseAllowance',
1383
+ stateMutability: 'nonpayable',
1384
+ inputs: [
1385
+ {
1386
+ name: 'spender',
1387
+ type: 'address',
1388
+ },
1389
+ {
1390
+ name: 'addedValue',
1391
+ type: 'uint256',
1392
+ },
1393
+ ],
1394
+ outputs: [{ type: 'bool' }],
1395
+ },
1396
+ {
1397
+ type: 'function',
1398
+ name: 'decreaseAllowance',
1399
+ stateMutability: 'nonpayable',
1400
+ inputs: [
1401
+ {
1402
+ name: 'spender',
1403
+ type: 'address',
1404
+ },
1405
+ {
1406
+ name: 'subtractedValue',
1407
+ type: 'uint256',
1408
+ },
1409
+ ],
1410
+ outputs: [{ type: 'bool' }],
1411
+ },
1412
+ ],
1413
+ } as const
@@ -58,6 +58,3 @@ export const transfer1Data = (address: string): Hex =>
58
58
 
59
59
  // vitalik.eth
60
60
  export const vitalikAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
61
-
62
- // USDC ERC20 contract
63
- export const usdcAddress = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
@@ -1,4 +1,8 @@
1
- export { wagmiContractConfig } from './abis'
1
+ export {
2
+ wagmiContractConfig,
3
+ uniswapV3PositionsContractConfig,
4
+ usdcContractConfig,
5
+ } from './abis'
2
6
 
3
7
  export { essentialProvider, ethersProvider, web3Provider } from './bench'
4
8
 
@@ -8,7 +12,6 @@ export {
8
12
  localHttpUrl,
9
13
  localWsUrl,
10
14
  transfer1Data,
11
- usdcAddress,
12
15
  vitalikAddress,
13
16
  } from './constants'
14
17
 
@@ -8,6 +8,8 @@ test('exports actions', () => {
8
8
  "addChain": [Function],
9
9
  "call": [Function],
10
10
  "createBlockFilter": [Function],
11
+ "createContractEventFilter": [Function],
12
+ "createEventFilter": [Function],
11
13
  "createPendingTransactionFilter": [Function],
12
14
  "deployContract": [Function],
13
15
  "dropTransaction": [Function],
@@ -1,6 +1,8 @@
1
1
  export {
2
2
  call,
3
3
  createBlockFilter,
4
+ createContractEventFilter,
5
+ createEventFilter,
4
6
  createPendingTransactionFilter,
5
7
  deployContract,
6
8
  estimateGas,
@@ -33,6 +35,10 @@ export type {
33
35
  CallArgs,
34
36
  CallResponse,
35
37
  CreateBlockFilterResponse,
38
+ CreateContractEventFilterArgs,
39
+ CreateContractEventFilterResponse,
40
+ CreateEventFilterArgs,
41
+ CreateEventFilterResponse,
36
42
  CreatePendingTransactionFilterResponse,
37
43
  DeployContractArgs,
38
44
  DeployContractResponse,
@@ -1,9 +1,10 @@
1
- import type { Chain, Formatter } from '../../chains'
2
1
  import type { PublicClient } from '../../clients'
3
2
  import { InvalidGasArgumentsError } from '../../errors'
4
3
  import type {
5
4
  Address,
6
5
  BlockTag,
6
+ Chain,
7
+ Formatter,
7
8
  Hex,
8
9
  MergeIntersectionProperties,
9
10
  TransactionRequest,
@@ -0,0 +1,119 @@
1
+ import { expect, test } from 'vitest'
2
+
3
+ import {
4
+ accounts,
5
+ initialBlockNumber,
6
+ publicClient,
7
+ usdcContractConfig,
8
+ } from '../../_test'
9
+
10
+ import { createContractEventFilter } from './createContractEventFilter'
11
+
12
+ test('default', async () => {
13
+ expect(
14
+ (
15
+ await createContractEventFilter(publicClient, {
16
+ abi: usdcContractConfig.abi,
17
+ eventName: 'Transfer',
18
+ })
19
+ ).id,
20
+ ).toBeDefined()
21
+ })
22
+
23
+ test('args: address', async () => {
24
+ expect(
25
+ (
26
+ await createContractEventFilter(publicClient, {
27
+ address: usdcContractConfig.address,
28
+ abi: usdcContractConfig.abi,
29
+ eventName: 'Transfer',
30
+ })
31
+ ).id,
32
+ ).toBeDefined()
33
+ })
34
+
35
+ test('args: args', async () => {
36
+ expect(
37
+ (
38
+ await createContractEventFilter(publicClient, {
39
+ address: usdcContractConfig.address,
40
+ abi: usdcContractConfig.abi,
41
+ eventName: 'Transfer',
42
+ args: {
43
+ from: accounts[0].address,
44
+ to: accounts[0].address,
45
+ },
46
+ })
47
+ ).id,
48
+ ).toBeDefined()
49
+ expect(
50
+ (
51
+ await createContractEventFilter(publicClient, {
52
+ address: usdcContractConfig.address,
53
+ abi: usdcContractConfig.abi,
54
+ eventName: 'Transfer',
55
+ args: {
56
+ from: accounts[0].address,
57
+ },
58
+ })
59
+ ).id,
60
+ ).toBeDefined()
61
+ expect(
62
+ (
63
+ await createContractEventFilter(publicClient, {
64
+ address: usdcContractConfig.address,
65
+ abi: usdcContractConfig.abi,
66
+ eventName: 'Transfer',
67
+ args: {
68
+ to: [accounts[0].address, accounts[1].address],
69
+ },
70
+ })
71
+ ).id,
72
+ ).toBeDefined()
73
+ })
74
+
75
+ test('args: fromBlock', async () => {
76
+ expect(
77
+ (
78
+ await createContractEventFilter(publicClient, {
79
+ address: usdcContractConfig.address,
80
+ abi: usdcContractConfig.abi,
81
+ eventName: 'Transfer',
82
+ fromBlock: 'latest',
83
+ })
84
+ ).id,
85
+ ).toBeDefined()
86
+ expect(
87
+ (
88
+ await createContractEventFilter(publicClient, {
89
+ address: usdcContractConfig.address,
90
+ abi: usdcContractConfig.abi,
91
+ eventName: 'Transfer',
92
+ fromBlock: initialBlockNumber,
93
+ })
94
+ ).id,
95
+ ).toBeDefined()
96
+ })
97
+
98
+ test('args: toBlock', async () => {
99
+ expect(
100
+ (
101
+ await createContractEventFilter(publicClient, {
102
+ address: usdcContractConfig.address,
103
+ abi: usdcContractConfig.abi,
104
+ eventName: 'Transfer',
105
+ toBlock: 'latest',
106
+ })
107
+ ).id,
108
+ ).toBeDefined()
109
+ expect(
110
+ (
111
+ await createContractEventFilter(publicClient, {
112
+ address: usdcContractConfig.address,
113
+ abi: usdcContractConfig.abi,
114
+ eventName: 'Transfer',
115
+ toBlock: initialBlockNumber,
116
+ })
117
+ ).id,
118
+ ).toBeDefined()
119
+ })
@@ -0,0 +1,69 @@
1
+ import { Abi } from 'abitype'
2
+ import type { PublicClient } from '../../clients'
3
+
4
+ import type {
5
+ Address,
6
+ BlockNumber,
7
+ BlockTag,
8
+ EventDefinition,
9
+ ExtractArgsFromEventDefinition,
10
+ ExtractEventArgsFromAbi,
11
+ ExtractEventNameFromAbi,
12
+ Filter,
13
+ } from '../../types'
14
+ import {
15
+ encodeEventTopics,
16
+ EncodeEventTopicsArgs,
17
+ numberToHex,
18
+ } from '../../utils'
19
+
20
+ export type EventFilterArgs<TEventDefinition extends EventDefinition> =
21
+ ExtractArgsFromEventDefinition<TEventDefinition>
22
+
23
+ export type CreateContractEventFilterArgs<
24
+ TAbi extends Abi | readonly unknown[] = Abi,
25
+ TEventName extends string = any,
26
+ > = {
27
+ address?: Address | Address[]
28
+ abi: TAbi
29
+ eventName: ExtractEventNameFromAbi<TAbi, TEventName>
30
+ fromBlock?: BlockNumber | BlockTag
31
+ toBlock?: BlockNumber | BlockTag
32
+ } & ExtractEventArgsFromAbi<TAbi, TEventName>
33
+ export type CreateContractEventFilterResponse = Filter<'event'>
34
+
35
+ export async function createContractEventFilter<
36
+ TAbi extends Abi | readonly unknown[] = Abi,
37
+ TEventName extends string = any,
38
+ >(
39
+ client: PublicClient,
40
+ {
41
+ address,
42
+ abi,
43
+ args,
44
+ eventName,
45
+ fromBlock,
46
+ toBlock,
47
+ }: CreateContractEventFilterArgs<TAbi, TEventName>,
48
+ ): Promise<CreateContractEventFilterResponse> {
49
+ const topics = eventName
50
+ ? encodeEventTopics({
51
+ abi,
52
+ args,
53
+ eventName,
54
+ } as unknown as EncodeEventTopicsArgs)
55
+ : undefined
56
+ const id = await client.request({
57
+ method: 'eth_newFilter',
58
+ params: [
59
+ {
60
+ address,
61
+ fromBlock:
62
+ typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,
63
+ toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,
64
+ topics,
65
+ },
66
+ ],
67
+ })
68
+ return { id, type: 'event' }
69
+ }
@@ -4,18 +4,17 @@ import type {
4
4
  Address,
5
5
  BlockNumber,
6
6
  BlockTag,
7
+ EventDefinition,
7
8
  ExtractArgsFromEventDefinition,
8
9
  Filter,
9
10
  LogTopic,
10
11
  } from '../../types'
11
12
  import { getEventSignature, numberToHex } from '../../utils'
12
13
 
13
- export type EventFilterArgs<TEventDefinition extends `${string}(${string})`> =
14
+ export type EventFilterArgs<TEventDefinition extends EventDefinition> =
14
15
  ExtractArgsFromEventDefinition<TEventDefinition>
15
16
 
16
- export type CreateEventFilterArgs<
17
- TEventDefinition extends `${string}(${string})`,
18
- > = {
17
+ export type CreateEventFilterArgs<TEventDefinition extends EventDefinition> = {
19
18
  address?: Address | Address[]
20
19
  fromBlock?: BlockNumber | BlockTag
21
20
  toBlock?: BlockNumber | BlockTag
@@ -32,7 +31,7 @@ export type CreateEventFilterArgs<
32
31
  export type CreateEventFilterResponse = Filter<'event'>
33
32
 
34
33
  export async function createEventFilter<
35
- TEventDefinition extends `${string}(${string})`,
34
+ TEventDefinition extends EventDefinition,
36
35
  >(
37
36
  client: PublicClient,
38
37
  {
@@ -62,9 +61,7 @@ export async function createEventFilter<
62
61
  return { id, type: 'event' }
63
62
  }
64
63
 
65
- export function buildFilterTopics<
66
- TEventDefinition extends `${string}(${string})`,
67
- >({
64
+ export function buildFilterTopics<TEventDefinition extends EventDefinition,>({
68
65
  event,
69
66
  args: _args,
70
67
  }: {
@@ -1,8 +1,7 @@
1
1
  import { Abi } from 'abitype'
2
- import { Chain } from '../../chains'
3
2
  import { WalletClient } from '../../clients'
4
3
 
5
- import { ExtractConstructorArgsFromAbi, Hex } from '../../types'
4
+ import { Chain, ExtractConstructorArgsFromAbi, Hex } from '../../types'
6
5
  import { encodeDeployData } from '../../utils'
7
6
  import {
8
7
  sendTransaction,
@@ -52,11 +52,11 @@ test('chain w/ custom block type', async () => {
52
52
  randomness: { committed: Hex; revealed: Hex }
53
53
  }
54
54
  >(block)
55
- expect(block).toMatchInlineSnapshot(`
55
+ const { extraData, ...rest } = block
56
+ expect(rest).toMatchInlineSnapshot(`
56
57
  {
57
- "baseFeePerGas": 100000000n,
58
+ "baseFeePerGas": null,
58
59
  "epochSnarkData": null,
59
- "extraData": "0xd983010700846765746889676f312e31372e3133856c696e7578000000000000f8ccc0c080b84169807e4d7934803decfde330167e444ec323431e1ff4cd70f40f2e79f24ce91f60340b99f97e3562ee57389e2c72343a74379e0b8b7ca5237ec141e84278bb3e00f8418e3e8af95497b7f6ffe7d3c4cbfbbdb06b26f6f3e913ca2cb7dff23532eaf3eb9f3b06ae75498c88353d279cf58fb0570736e2aa20cf53381722b6485f0f3c8180f8418e3fffffffffffffffffffffffffffb0005d23be939b9f8135e6b1ff283baff985c1b6ccacf2b6aa7fbd8939c4b6178b1d242b574a614b6347182a3b3195258080",
60
60
  "gasUsed": 5045322n,
61
61
  "hash": "0xac8c9bc3b84e103dc321bbe83b670e425ff68bfc9a333a4f1b1b204ad11c583d",
62
62
  "logsBloom": "0x02004000004200000000000000800020000000000000400002040000002020000000802000000000000180000001000020800000000000000000000000000000000000000022000260000008000800000000000000000000000000000000000000000008000410002100000140000800000044c00200000000400010000800008800000080000000000010000040000000000000000000000000000000800020028000000100000000000000000000002002881000000000000800020000040020900402020000180000000000000040000800000011020090002000400000200010002000001000000000000080000000000000000000000000000004000000",
@@ -1,7 +1,6 @@
1
- import type { Chain } from '../../chains'
2
1
  import type { PublicClient } from '../../clients'
3
2
  import { BlockNotFoundError } from '../../errors'
4
- import type { BlockTag, Hash, RpcBlock } from '../../types'
3
+ import type { BlockTag, Chain, Hash, RpcBlock } from '../../types'
5
4
  import type { BlockFormatter, FormattedBlock } from '../../utils'
6
5
  import { format, formatBlock, numberToHex } from '../../utils'
7
6
 
@@ -1,6 +1,5 @@
1
- import type { Chain } from '../../chains'
2
1
  import type { PublicClient } from '../../clients'
3
- import type { BlockTag, Hash, Quantity } from '../../types'
2
+ import type { BlockTag, Chain, Hash, Quantity } from '../../types'
4
3
  import { hexToNumber, numberToHex } from '../../utils'
5
4
 
6
5
  export type GetBlockTransactionCountArgs =
@@ -6,9 +6,9 @@ import {
6
6
  publicClient,
7
7
  testClient,
8
8
  transfer1Data,
9
- usdcAddress,
10
9
  vitalikAddress,
11
10
  walletClient,
11
+ usdcContractConfig,
12
12
  } from '../../_test'
13
13
 
14
14
  import {
@@ -103,12 +103,12 @@ describe('events', () => {
103
103
 
104
104
  await sendTransaction(walletClient, {
105
105
  from: vitalikAddress,
106
- to: usdcAddress,
106
+ to: usdcContractConfig.address,
107
107
  data: transfer1Data(accounts[0].address),
108
108
  })
109
109
  await sendTransaction(walletClient, {
110
110
  from: vitalikAddress,
111
- to: usdcAddress,
111
+ to: usdcContractConfig.address,
112
112
  data: transfer1Data(accounts[1].address),
113
113
  })
114
114
 
@@ -123,7 +123,7 @@ describe('events', () => {
123
123
 
124
124
  await sendTransaction(walletClient, {
125
125
  from: vitalikAddress,
126
- to: usdcAddress,
126
+ to: usdcContractConfig.address,
127
127
  data: transfer1Data(accounts[2].address),
128
128
  })
129
129
 
@@ -140,12 +140,12 @@ describe('events', () => {
140
140
 
141
141
  await sendTransaction(walletClient, {
142
142
  from: vitalikAddress,
143
- to: usdcAddress,
143
+ to: usdcContractConfig.address,
144
144
  data: transfer1Data(accounts[0].address),
145
145
  })
146
146
  await sendTransaction(walletClient, {
147
147
  from: vitalikAddress,
148
- to: usdcAddress,
148
+ to: usdcContractConfig.address,
149
149
  data: transfer1Data(accounts[1].address),
150
150
  })
151
151
 
@@ -160,7 +160,7 @@ describe('events', () => {
160
160
 
161
161
  await sendTransaction(walletClient, {
162
162
  from: vitalikAddress,
163
- to: usdcAddress,
163
+ to: usdcContractConfig.address,
164
164
  data: transfer1Data(accounts[2].address),
165
165
  })
166
166
 
@@ -184,4 +184,6 @@ describe('events', () => {
184
184
  logs = await getFilterChanges(publicClient, { filter })
185
185
  expect(logs.length).toBe(0)
186
186
  })
187
+
188
+ test.todo('args: args')
187
189
  })
@@ -6,7 +6,7 @@ import {
6
6
  publicClient,
7
7
  testClient,
8
8
  transfer1Data,
9
- usdcAddress,
9
+ usdcContractConfig,
10
10
  vitalikAddress,
11
11
  walletClient,
12
12
  } from '../../_test'
@@ -49,12 +49,12 @@ describe('events', () => {
49
49
 
50
50
  await sendTransaction(walletClient, {
51
51
  from: vitalikAddress,
52
- to: usdcAddress,
52
+ to: usdcContractConfig.address,
53
53
  data: transfer1Data(accounts[0].address),
54
54
  })
55
55
  await sendTransaction(walletClient, {
56
56
  from: vitalikAddress,
57
- to: usdcAddress,
57
+ to: usdcContractConfig.address,
58
58
  data: transfer1Data(accounts[1].address),
59
59
  })
60
60
 
@@ -72,12 +72,12 @@ describe('events', () => {
72
72
 
73
73
  await sendTransaction(walletClient, {
74
74
  from: vitalikAddress,
75
- to: usdcAddress,
75
+ to: usdcContractConfig.address,
76
76
  data: transfer1Data(accounts[0].address),
77
77
  })
78
78
  await sendTransaction(walletClient, {
79
79
  from: vitalikAddress,
80
- to: usdcAddress,
80
+ to: usdcContractConfig.address,
81
81
  data: transfer1Data(accounts[1].address),
82
82
  })
83
83
 
@@ -99,4 +99,6 @@ describe('events', () => {
99
99
  assertType<Log[]>(logs)
100
100
  expect(logs.length).toBe(1056)
101
101
  })
102
+
103
+ test.todo('args: args')
102
104
  })
@@ -6,8 +6,8 @@ import {
6
6
  publicClient,
7
7
  testClient,
8
8
  transfer1Data,
9
- usdcAddress,
10
9
  vitalikAddress,
10
+ usdcContractConfig,
11
11
  walletClient,
12
12
  } from '../../_test'
13
13
 
@@ -45,12 +45,12 @@ describe('events', () => {
45
45
  test('no args', async () => {
46
46
  await sendTransaction(walletClient, {
47
47
  from: vitalikAddress,
48
- to: usdcAddress,
48
+ to: usdcContractConfig.address,
49
49
  data: transfer1Data(accounts[0].address),
50
50
  })
51
51
  await sendTransaction(walletClient, {
52
52
  from: vitalikAddress,
53
- to: usdcAddress,
53
+ to: usdcContractConfig.address,
54
54
  data: transfer1Data(accounts[1].address),
55
55
  })
56
56
  await mine(testClient, { blocks: 1 })
@@ -63,12 +63,12 @@ describe('events', () => {
63
63
  test('args: event', async () => {
64
64
  await sendTransaction(walletClient, {
65
65
  from: vitalikAddress,
66
- to: usdcAddress,
66
+ to: usdcContractConfig.address,
67
67
  data: transfer1Data(accounts[0].address),
68
68
  })
69
69
  await sendTransaction(walletClient, {
70
70
  from: vitalikAddress,
71
- to: usdcAddress,
71
+ to: usdcContractConfig.address,
72
72
  data: transfer1Data(accounts[1].address),
73
73
  })
74
74
 
@@ -102,4 +102,6 @@ describe('events', () => {
102
102
  assertType<Log[]>(logs)
103
103
  expect(logs.length).toBe(118)
104
104
  })
105
+
106
+ test.todo('args: args')
105
107
  })