@wagmi/core 3.2.2 → 3.3.0
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/dist/esm/actions/deployContract.js +7 -1
- package/dist/esm/actions/deployContract.js.map +1 -1
- package/dist/esm/actions/getBlobBaseFee.js +10 -0
- package/dist/esm/actions/getBlobBaseFee.js.map +1 -0
- package/dist/esm/actions/getContractEvents.js +10 -0
- package/dist/esm/actions/getContractEvents.js.map +1 -0
- package/dist/esm/actions/sendTransaction.js +7 -1
- package/dist/esm/actions/sendTransaction.js.map +1 -1
- package/dist/esm/actions/sendTransactionSync.js +7 -1
- package/dist/esm/actions/sendTransactionSync.js.map +1 -1
- package/dist/esm/actions/writeContract.js +7 -1
- package/dist/esm/actions/writeContract.js.map +1 -1
- package/dist/esm/actions/writeContractSync.js +31 -0
- package/dist/esm/actions/writeContractSync.js.map +1 -0
- package/dist/esm/connectors/mock.js +2 -0
- package/dist/esm/connectors/mock.js.map +1 -1
- package/dist/esm/exports/actions.js +2 -0
- package/dist/esm/exports/actions.js.map +1 -1
- package/dist/esm/exports/index.js +3 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/query.js +3 -0
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/query/connect.js +3 -2
- package/dist/esm/query/connect.js.map +1 -1
- package/dist/esm/query/deployContract.js +2 -1
- package/dist/esm/query/deployContract.js.map +1 -1
- package/dist/esm/query/disconnect.js +3 -2
- package/dist/esm/query/disconnect.js.map +1 -1
- package/dist/esm/query/getBlobBaseFee.js +17 -0
- package/dist/esm/query/getBlobBaseFee.js.map +1 -0
- package/dist/esm/query/getContractEvents.js +24 -0
- package/dist/esm/query/getContractEvents.js.map +1 -0
- package/dist/esm/query/readContracts.js +13 -2
- package/dist/esm/query/readContracts.js.map +1 -1
- package/dist/esm/query/reconnect.js +2 -1
- package/dist/esm/query/reconnect.js.map +1 -1
- package/dist/esm/query/sendCalls.js +2 -1
- package/dist/esm/query/sendCalls.js.map +1 -1
- package/dist/esm/query/sendCallsSync.js +2 -1
- package/dist/esm/query/sendCallsSync.js.map +1 -1
- package/dist/esm/query/sendTransaction.js +2 -1
- package/dist/esm/query/sendTransaction.js.map +1 -1
- package/dist/esm/query/sendTransactionSync.js +2 -1
- package/dist/esm/query/sendTransactionSync.js.map +1 -1
- package/dist/esm/query/showCallsStatus.js +2 -1
- package/dist/esm/query/showCallsStatus.js.map +1 -1
- package/dist/esm/query/signMessage.js +2 -1
- package/dist/esm/query/signMessage.js.map +1 -1
- package/dist/esm/query/signTypedData.js +2 -1
- package/dist/esm/query/signTypedData.js.map +1 -1
- package/dist/esm/query/switchChain.js +2 -1
- package/dist/esm/query/switchChain.js.map +1 -1
- package/dist/esm/query/switchConnection.js +2 -1
- package/dist/esm/query/switchConnection.js.map +1 -1
- package/dist/esm/query/verifyTypedData.js.map +1 -1
- package/dist/esm/query/watchAsset.js +2 -1
- package/dist/esm/query/watchAsset.js.map +1 -1
- package/dist/esm/query/writeContract.js +2 -1
- package/dist/esm/query/writeContract.js.map +1 -1
- package/dist/esm/query/writeContractSync.js +11 -0
- package/dist/esm/query/writeContractSync.js.map +1 -0
- package/dist/esm/tempo/Connectors.js +10 -4
- package/dist/esm/tempo/Connectors.js.map +1 -1
- package/dist/esm/tempo/KeyManager.js +49 -1
- package/dist/esm/tempo/KeyManager.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/deployContract.d.ts.map +1 -1
- package/dist/types/actions/getBlobBaseFee.d.ts +10 -0
- package/dist/types/actions/getBlobBaseFee.d.ts.map +1 -0
- package/dist/types/actions/getContractEvents.d.ts +11 -0
- package/dist/types/actions/getContractEvents.d.ts.map +1 -0
- package/dist/types/actions/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/sendTransactionSync.d.ts.map +1 -1
- package/dist/types/actions/writeContract.d.ts.map +1 -1
- package/dist/types/actions/writeContractSync.d.ts +16 -0
- package/dist/types/actions/writeContractSync.d.ts.map +1 -0
- package/dist/types/connectors/mock.d.ts.map +1 -1
- package/dist/types/exports/actions.d.ts +2 -0
- package/dist/types/exports/actions.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +3 -0
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts +21 -14
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/query/connect.d.ts +5 -5
- package/dist/types/query/connect.d.ts.map +1 -1
- package/dist/types/query/deployContract.d.ts +5 -5
- package/dist/types/query/deployContract.d.ts.map +1 -1
- package/dist/types/query/disconnect.d.ts +5 -4
- package/dist/types/query/disconnect.d.ts.map +1 -1
- package/dist/types/query/getBlobBaseFee.d.ts +16 -0
- package/dist/types/query/getBlobBaseFee.d.ts.map +1 -0
- package/dist/types/query/getContractEvents.d.ts +24 -0
- package/dist/types/query/getContractEvents.d.ts.map +1 -0
- package/dist/types/query/getEnsAddress.d.ts +1 -1
- package/dist/types/query/getEnsAvatar.d.ts +1 -1
- package/dist/types/query/getEnsName.d.ts +1 -1
- package/dist/types/query/getEnsText.d.ts +1 -1
- package/dist/types/query/readContracts.d.ts +1 -1
- package/dist/types/query/readContracts.d.ts.map +1 -1
- package/dist/types/query/reconnect.d.ts +5 -4
- package/dist/types/query/reconnect.d.ts.map +1 -1
- package/dist/types/query/sendCalls.d.ts +5 -10
- package/dist/types/query/sendCalls.d.ts.map +1 -1
- package/dist/types/query/sendCallsSync.d.ts +5 -18
- package/dist/types/query/sendCallsSync.d.ts.map +1 -1
- package/dist/types/query/sendTransaction.d.ts +5 -5
- package/dist/types/query/sendTransaction.d.ts.map +1 -1
- package/dist/types/query/sendTransactionSync.d.ts +5 -5
- package/dist/types/query/sendTransactionSync.d.ts.map +1 -1
- package/dist/types/query/showCallsStatus.d.ts +5 -5
- package/dist/types/query/showCallsStatus.d.ts.map +1 -1
- package/dist/types/query/signMessage.d.ts +5 -8
- package/dist/types/query/signMessage.d.ts.map +1 -1
- package/dist/types/query/signTypedData.d.ts +5 -223
- package/dist/types/query/signTypedData.d.ts.map +1 -1
- package/dist/types/query/switchChain.d.ts +5 -21
- package/dist/types/query/switchChain.d.ts.map +1 -1
- package/dist/types/query/switchConnection.d.ts +5 -6
- package/dist/types/query/switchConnection.d.ts.map +1 -1
- package/dist/types/query/verifyTypedData.d.ts.map +1 -1
- package/dist/types/query/watchAsset.d.ts +5 -13
- package/dist/types/query/watchAsset.d.ts.map +1 -1
- package/dist/types/query/writeContract.d.ts +5 -7
- package/dist/types/query/writeContract.d.ts.map +1 -1
- package/dist/types/query/writeContractSync.d.ts +14 -0
- package/dist/types/query/writeContractSync.d.ts.map +1 -0
- package/dist/types/tempo/Connectors.d.ts.map +1 -1
- package/dist/types/tempo/KeyManager.d.ts.map +1 -1
- package/dist/types/types/query.d.ts +4 -1
- package/dist/types/types/query.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/actions/deployContract.ts +7 -1
- package/src/actions/getBlobBaseFee.ts +35 -0
- package/src/actions/getContractEvents.ts +68 -0
- package/src/actions/sendTransaction.ts +7 -1
- package/src/actions/sendTransactionSync.ts +7 -1
- package/src/actions/writeContract.ts +7 -1
- package/src/actions/writeContractSync.ts +120 -0
- package/src/connectors/mock.ts +1 -0
- package/src/exports/actions.ts +14 -0
- package/src/exports/index.ts +21 -0
- package/src/exports/query.ts +64 -0
- package/src/query/connect.ts +24 -8
- package/src/query/deployContract.ts +20 -5
- package/src/query/disconnect.ts +20 -9
- package/src/query/getBlobBaseFee.ts +75 -0
- package/src/query/getContractEvents.ts +214 -0
- package/src/query/readContracts.ts +12 -2
- package/src/query/reconnect.ts +20 -7
- package/src/query/sendCalls.ts +22 -8
- package/src/query/sendCallsSync.ts +20 -5
- package/src/query/sendTransaction.ts +20 -5
- package/src/query/sendTransactionSync.ts +23 -5
- package/src/query/showCallsStatus.ts +19 -8
- package/src/query/signMessage.ts +20 -7
- package/src/query/signTypedData.ts +19 -8
- package/src/query/switchChain.ts +22 -8
- package/src/query/switchConnection.ts +20 -5
- package/src/query/verifyTypedData.ts +0 -1
- package/src/query/watchAsset.ts +20 -7
- package/src/query/writeContract.ts +26 -5
- package/src/query/writeContractSync.ts +130 -0
- package/src/tempo/Connectors.ts +9 -6
- package/src/tempo/KeyManager.ts +64 -1
- package/src/types/query.ts +15 -1
- package/src/version.ts +1 -1
package/src/exports/query.ts
CHANGED
|
@@ -17,6 +17,8 @@ export {
|
|
|
17
17
|
type ConnectData,
|
|
18
18
|
type ConnectMutate,
|
|
19
19
|
type ConnectMutateAsync,
|
|
20
|
+
type ConnectMutationOptions,
|
|
21
|
+
type ConnectOptions,
|
|
20
22
|
type ConnectVariables,
|
|
21
23
|
connectMutationOptions,
|
|
22
24
|
} from '../query/connect.js'
|
|
@@ -25,6 +27,8 @@ export {
|
|
|
25
27
|
type DeployContractData,
|
|
26
28
|
type DeployContractMutate,
|
|
27
29
|
type DeployContractMutateAsync,
|
|
30
|
+
type DeployContractMutationOptions,
|
|
31
|
+
type DeployContractOptions,
|
|
28
32
|
type DeployContractVariables,
|
|
29
33
|
deployContractMutationOptions,
|
|
30
34
|
} from '../query/deployContract.js'
|
|
@@ -33,6 +37,8 @@ export {
|
|
|
33
37
|
type DisconnectData,
|
|
34
38
|
type DisconnectMutate,
|
|
35
39
|
type DisconnectMutateAsync,
|
|
40
|
+
type DisconnectMutationOptions,
|
|
41
|
+
type DisconnectOptions,
|
|
36
42
|
type DisconnectVariables,
|
|
37
43
|
disconnectMutationOptions,
|
|
38
44
|
} from '../query/disconnect.js'
|
|
@@ -77,6 +83,16 @@ export {
|
|
|
77
83
|
getBalanceQueryOptions,
|
|
78
84
|
} from '../query/getBalance.js'
|
|
79
85
|
|
|
86
|
+
export {
|
|
87
|
+
type GetBlobBaseFeeData,
|
|
88
|
+
type GetBlobBaseFeeOptions,
|
|
89
|
+
type GetBlobBaseFeeQueryFnData,
|
|
90
|
+
type GetBlobBaseFeeQueryKey,
|
|
91
|
+
type GetBlobBaseFeeQueryOptions,
|
|
92
|
+
getBlobBaseFeeQueryKey,
|
|
93
|
+
getBlobBaseFeeQueryOptions,
|
|
94
|
+
} from '../query/getBlobBaseFee.js'
|
|
95
|
+
|
|
80
96
|
export {
|
|
81
97
|
type GetBlockData,
|
|
82
98
|
type GetBlockOptions,
|
|
@@ -147,6 +163,16 @@ export {
|
|
|
147
163
|
getConnectorClientQueryOptions,
|
|
148
164
|
} from '../query/getConnectorClient.js'
|
|
149
165
|
|
|
166
|
+
export {
|
|
167
|
+
type GetContractEventsData,
|
|
168
|
+
type GetContractEventsOptions,
|
|
169
|
+
type GetContractEventsQueryFnData,
|
|
170
|
+
type GetContractEventsQueryKey,
|
|
171
|
+
type GetContractEventsQueryOptions,
|
|
172
|
+
getContractEventsQueryKey,
|
|
173
|
+
getContractEventsQueryOptions,
|
|
174
|
+
} from '../query/getContractEvents.js'
|
|
175
|
+
|
|
150
176
|
export {
|
|
151
177
|
type GetEnsAddressData,
|
|
152
178
|
type GetEnsAddressOptions,
|
|
@@ -330,6 +356,8 @@ export {
|
|
|
330
356
|
type ReconnectData,
|
|
331
357
|
type ReconnectMutate,
|
|
332
358
|
type ReconnectMutateAsync,
|
|
359
|
+
type ReconnectMutationOptions,
|
|
360
|
+
type ReconnectOptions,
|
|
333
361
|
type ReconnectVariables,
|
|
334
362
|
reconnectMutationOptions,
|
|
335
363
|
} from '../query/reconnect.js'
|
|
@@ -338,6 +366,8 @@ export {
|
|
|
338
366
|
type SendCallsData,
|
|
339
367
|
type SendCallsMutate,
|
|
340
368
|
type SendCallsMutateAsync,
|
|
369
|
+
type SendCallsMutationOptions,
|
|
370
|
+
type SendCallsOptions,
|
|
341
371
|
type SendCallsVariables,
|
|
342
372
|
sendCallsMutationOptions,
|
|
343
373
|
} from '../query/sendCalls.js'
|
|
@@ -346,6 +376,8 @@ export {
|
|
|
346
376
|
type SendCallsSyncData,
|
|
347
377
|
type SendCallsSyncMutate,
|
|
348
378
|
type SendCallsSyncMutateAsync,
|
|
379
|
+
type SendCallsSyncMutationOptions,
|
|
380
|
+
type SendCallsSyncOptions,
|
|
349
381
|
type SendCallsSyncVariables,
|
|
350
382
|
sendCallsSyncMutationOptions,
|
|
351
383
|
} from '../query/sendCallsSync.js'
|
|
@@ -354,6 +386,8 @@ export {
|
|
|
354
386
|
type SendTransactionData,
|
|
355
387
|
type SendTransactionMutate,
|
|
356
388
|
type SendTransactionMutateAsync,
|
|
389
|
+
type SendTransactionMutationOptions,
|
|
390
|
+
type SendTransactionOptions,
|
|
357
391
|
type SendTransactionVariables,
|
|
358
392
|
sendTransactionMutationOptions,
|
|
359
393
|
} from '../query/sendTransaction.js'
|
|
@@ -362,6 +396,8 @@ export {
|
|
|
362
396
|
type SendTransactionSyncData,
|
|
363
397
|
type SendTransactionSyncMutate,
|
|
364
398
|
type SendTransactionSyncMutateAsync,
|
|
399
|
+
type SendTransactionSyncMutationOptions,
|
|
400
|
+
type SendTransactionSyncOptions,
|
|
365
401
|
type SendTransactionSyncVariables,
|
|
366
402
|
sendTransactionSyncMutationOptions,
|
|
367
403
|
} from '../query/sendTransactionSync.js'
|
|
@@ -370,6 +406,8 @@ export {
|
|
|
370
406
|
type ShowCallsStatusData,
|
|
371
407
|
type ShowCallsStatusMutate,
|
|
372
408
|
type ShowCallsStatusMutateAsync,
|
|
409
|
+
type ShowCallsStatusMutationOptions,
|
|
410
|
+
type ShowCallsStatusOptions,
|
|
373
411
|
type ShowCallsStatusVariables,
|
|
374
412
|
showCallsStatusMutationOptions,
|
|
375
413
|
} from '../query/showCallsStatus.js'
|
|
@@ -378,6 +416,8 @@ export {
|
|
|
378
416
|
type SignMessageData,
|
|
379
417
|
type SignMessageMutate,
|
|
380
418
|
type SignMessageMutateAsync,
|
|
419
|
+
type SignMessageMutationOptions,
|
|
420
|
+
type SignMessageOptions,
|
|
381
421
|
type SignMessageVariables,
|
|
382
422
|
signMessageMutationOptions,
|
|
383
423
|
} from '../query/signMessage.js'
|
|
@@ -386,6 +426,8 @@ export {
|
|
|
386
426
|
type SignTypedDataData,
|
|
387
427
|
type SignTypedDataMutate,
|
|
388
428
|
type SignTypedDataMutateAsync,
|
|
429
|
+
type SignTypedDataMutationOptions,
|
|
430
|
+
type SignTypedDataOptions,
|
|
389
431
|
type SignTypedDataVariables,
|
|
390
432
|
signTypedDataMutationOptions,
|
|
391
433
|
} from '../query/signTypedData.js'
|
|
@@ -404,6 +446,8 @@ export {
|
|
|
404
446
|
type SwitchChainData,
|
|
405
447
|
type SwitchChainMutate,
|
|
406
448
|
type SwitchChainMutateAsync,
|
|
449
|
+
type SwitchChainMutationOptions,
|
|
450
|
+
type SwitchChainOptions,
|
|
407
451
|
type SwitchChainVariables,
|
|
408
452
|
switchChainMutationOptions,
|
|
409
453
|
} from '../query/switchChain.js'
|
|
@@ -418,6 +462,12 @@ export {
|
|
|
418
462
|
/** @deprecated use `SwitchConnectionMutateAsync` instead */
|
|
419
463
|
type SwitchConnectionMutateAsync as SwitchAccountMutateAsync,
|
|
420
464
|
type SwitchConnectionMutateAsync,
|
|
465
|
+
/** @deprecated use `SwitchConnectionMutationOptions` instead */
|
|
466
|
+
type SwitchConnectionMutationOptions as SwitchAccountMutationOptions,
|
|
467
|
+
type SwitchConnectionMutationOptions,
|
|
468
|
+
/** @deprecated use `SwitchConnectionOptions` instead */
|
|
469
|
+
type SwitchConnectionOptions as SwitchAccountOptions,
|
|
470
|
+
type SwitchConnectionOptions,
|
|
421
471
|
/** @deprecated use `SwitchConnectionVariables` instead */
|
|
422
472
|
type SwitchConnectionVariables as SwitchAccountVariables,
|
|
423
473
|
type SwitchConnectionVariables,
|
|
@@ -475,6 +525,8 @@ export {
|
|
|
475
525
|
type WatchAssetData,
|
|
476
526
|
type WatchAssetMutate,
|
|
477
527
|
type WatchAssetMutateAsync,
|
|
528
|
+
type WatchAssetMutationOptions,
|
|
529
|
+
type WatchAssetOptions,
|
|
478
530
|
type WatchAssetVariables,
|
|
479
531
|
watchAssetMutationOptions,
|
|
480
532
|
} from '../query/watchAsset.js'
|
|
@@ -483,6 +535,18 @@ export {
|
|
|
483
535
|
type WriteContractData,
|
|
484
536
|
type WriteContractMutate,
|
|
485
537
|
type WriteContractMutateAsync,
|
|
538
|
+
type WriteContractMutationOptions,
|
|
539
|
+
type WriteContractOptions,
|
|
486
540
|
type WriteContractVariables,
|
|
487
541
|
writeContractMutationOptions,
|
|
488
542
|
} from '../query/writeContract.js'
|
|
543
|
+
|
|
544
|
+
export {
|
|
545
|
+
type WriteContractSyncData,
|
|
546
|
+
type WriteContractSyncMutate,
|
|
547
|
+
type WriteContractSyncMutateAsync,
|
|
548
|
+
type WriteContractSyncMutationOptions,
|
|
549
|
+
type WriteContractSyncOptions,
|
|
550
|
+
type WriteContractSyncVariables,
|
|
551
|
+
writeContractSyncMutationOptions,
|
|
552
|
+
} from '../query/writeContractSync.js'
|
package/src/query/connect.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
type ConnectErrorType,
|
|
5
4
|
type ConnectParameters,
|
|
@@ -8,21 +7,38 @@ import {
|
|
|
8
7
|
} from '../actions/connect.js'
|
|
9
8
|
import type { CreateConnectorFn } from '../connectors/createConnector.js'
|
|
10
9
|
import type { Config, Connector } from '../createConfig.js'
|
|
10
|
+
import type { MutationParameter } from '../types/query.js'
|
|
11
11
|
import type { Compute } from '../types/utils.js'
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type ConnectOptions<
|
|
14
|
+
config extends Config,
|
|
15
|
+
context = unknown,
|
|
16
|
+
> = MutationParameter<
|
|
17
|
+
ConnectData<config, config['connectors'][number], boolean>,
|
|
18
|
+
ConnectErrorType,
|
|
19
|
+
ConnectVariables<config, config['connectors'][number], boolean>,
|
|
20
|
+
context
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
export function connectMutationOptions<config extends Config, context>(
|
|
24
|
+
config: config,
|
|
25
|
+
options: ConnectOptions<config, context> = {},
|
|
26
|
+
): ConnectMutationOptions<config> {
|
|
14
27
|
return {
|
|
15
|
-
|
|
28
|
+
...(options.mutation as any),
|
|
29
|
+
mutationFn: async (variables) => {
|
|
16
30
|
return connect(config, variables)
|
|
17
31
|
},
|
|
18
32
|
mutationKey: ['connect'],
|
|
19
|
-
}
|
|
20
|
-
ConnectData<config, Connector | CreateConnectorFn, boolean>,
|
|
21
|
-
ConnectErrorType,
|
|
22
|
-
ConnectVariables<config, Connector | CreateConnectorFn, boolean>
|
|
23
|
-
>
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
35
|
|
|
36
|
+
export type ConnectMutationOptions<config extends Config> = MutationOptions<
|
|
37
|
+
ConnectData<config, config['connectors'][number], boolean>,
|
|
38
|
+
ConnectErrorType,
|
|
39
|
+
ConnectVariables<config, config['connectors'][number], boolean>
|
|
40
|
+
>
|
|
41
|
+
|
|
26
42
|
export type ConnectData<
|
|
27
43
|
config extends Config,
|
|
28
44
|
connector extends Connector | CreateConnectorFn,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
|
|
2
2
|
import type { Abi, ContractConstructorArgs } from 'viem'
|
|
3
|
-
|
|
4
3
|
import {
|
|
5
4
|
type DeployContractErrorType,
|
|
6
5
|
type DeployContractParameters,
|
|
@@ -8,22 +7,38 @@ import {
|
|
|
8
7
|
deployContract,
|
|
9
8
|
} from '../actions/deployContract.js'
|
|
10
9
|
import type { Config } from '../createConfig.js'
|
|
10
|
+
import type { MutationParameter } from '../types/query.js'
|
|
11
11
|
import type { Compute } from '../types/utils.js'
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type DeployContractOptions<
|
|
14
|
+
config extends Config,
|
|
15
|
+
context = unknown,
|
|
16
|
+
> = MutationParameter<
|
|
17
|
+
DeployContractData,
|
|
18
|
+
DeployContractErrorType,
|
|
19
|
+
DeployContractVariables<Abi, config, config['chains'][number]['id']>,
|
|
20
|
+
context
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
export function deployContractMutationOptions<config extends Config, context>(
|
|
14
24
|
config: config,
|
|
15
|
-
|
|
25
|
+
options: DeployContractOptions<config, context> = {},
|
|
26
|
+
): DeployContractMutationOptions<config> {
|
|
16
27
|
return {
|
|
28
|
+
...(options.mutation as any),
|
|
17
29
|
mutationFn(variables) {
|
|
18
30
|
return deployContract(config, variables)
|
|
19
31
|
},
|
|
20
32
|
mutationKey: ['deployContract'],
|
|
21
|
-
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type DeployContractMutationOptions<config extends Config> =
|
|
37
|
+
MutationOptions<
|
|
22
38
|
DeployContractData,
|
|
23
39
|
DeployContractErrorType,
|
|
24
40
|
DeployContractVariables<Abi, config, config['chains'][number]['id']>
|
|
25
41
|
>
|
|
26
|
-
}
|
|
27
42
|
|
|
28
43
|
export type DeployContractData = Compute<DeployContractReturnType>
|
|
29
44
|
|
package/src/query/disconnect.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MutationOptions } from '@tanstack/query-core'
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
type DisconnectErrorType,
|
|
5
4
|
type DisconnectParameters,
|
|
@@ -7,23 +6,35 @@ import {
|
|
|
7
6
|
disconnect,
|
|
8
7
|
} from '../actions/disconnect.js'
|
|
9
8
|
import type { Config } from '../createConfig.js'
|
|
9
|
+
import type { MutationParameter } from '../types/query.js'
|
|
10
10
|
import type { Mutate, MutateAsync } from './types.js'
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type DisconnectOptions<context = unknown> = MutationParameter<
|
|
13
|
+
DisconnectData,
|
|
14
|
+
DisconnectErrorType,
|
|
15
|
+
DisconnectVariables,
|
|
16
|
+
context
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
export function disconnectMutationOptions<config extends Config, context>(
|
|
13
20
|
config: config,
|
|
14
|
-
|
|
21
|
+
options: DisconnectOptions<context> = {},
|
|
22
|
+
): DisconnectMutationOptions {
|
|
15
23
|
return {
|
|
16
|
-
|
|
24
|
+
...(options.mutation as any),
|
|
25
|
+
mutationFn: async (variables) => {
|
|
17
26
|
return disconnect(config, variables)
|
|
18
27
|
},
|
|
19
28
|
mutationKey: ['disconnect'],
|
|
20
|
-
}
|
|
21
|
-
DisconnectData,
|
|
22
|
-
DisconnectErrorType,
|
|
23
|
-
DisconnectVariables
|
|
24
|
-
>
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
|
|
32
|
+
export type DisconnectMutationOptions = MutationOptions<
|
|
33
|
+
DisconnectData,
|
|
34
|
+
DisconnectErrorType,
|
|
35
|
+
DisconnectVariables
|
|
36
|
+
>
|
|
37
|
+
|
|
27
38
|
export type DisconnectData = DisconnectReturnType
|
|
28
39
|
|
|
29
40
|
export type DisconnectVariables = DisconnectParameters | undefined
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GetBlobBaseFeeErrorType,
|
|
3
|
+
type GetBlobBaseFeeParameters,
|
|
4
|
+
type GetBlobBaseFeeReturnType,
|
|
5
|
+
getBlobBaseFee,
|
|
6
|
+
} from '../actions/getBlobBaseFee.js'
|
|
7
|
+
import type { Config } from '../createConfig.js'
|
|
8
|
+
import type { ScopeKeyParameter } from '../types/properties.js'
|
|
9
|
+
import type { QueryOptions, QueryParameter } from '../types/query.js'
|
|
10
|
+
import type { Compute, ExactPartial } from '../types/utils.js'
|
|
11
|
+
import { filterQueryOptions } from './utils.js'
|
|
12
|
+
|
|
13
|
+
export type GetBlobBaseFeeOptions<
|
|
14
|
+
config extends Config,
|
|
15
|
+
chainId extends config['chains'][number]['id'],
|
|
16
|
+
selectData = GetBlobBaseFeeData,
|
|
17
|
+
> = Compute<
|
|
18
|
+
ExactPartial<GetBlobBaseFeeParameters<config, chainId>> & ScopeKeyParameter
|
|
19
|
+
> &
|
|
20
|
+
QueryParameter<
|
|
21
|
+
GetBlobBaseFeeQueryFnData,
|
|
22
|
+
GetBlobBaseFeeErrorType,
|
|
23
|
+
selectData,
|
|
24
|
+
GetBlobBaseFeeQueryKey<config, chainId>
|
|
25
|
+
>
|
|
26
|
+
|
|
27
|
+
export function getBlobBaseFeeQueryOptions<
|
|
28
|
+
config extends Config,
|
|
29
|
+
chainId extends config['chains'][number]['id'],
|
|
30
|
+
selectData = GetBlobBaseFeeData,
|
|
31
|
+
>(
|
|
32
|
+
config: config,
|
|
33
|
+
options: GetBlobBaseFeeOptions<config, chainId, selectData> = {},
|
|
34
|
+
): GetBlobBaseFeeQueryOptions<config, chainId, selectData> {
|
|
35
|
+
return {
|
|
36
|
+
...options.query,
|
|
37
|
+
queryFn: async (context) => {
|
|
38
|
+
const [, { scopeKey: _, ...parameters }] = context.queryKey
|
|
39
|
+
const blobBaseFee = await getBlobBaseFee(config, parameters)
|
|
40
|
+
return blobBaseFee ?? null
|
|
41
|
+
},
|
|
42
|
+
queryKey: getBlobBaseFeeQueryKey(options),
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type GetBlobBaseFeeQueryFnData = GetBlobBaseFeeReturnType
|
|
47
|
+
|
|
48
|
+
export type GetBlobBaseFeeData = GetBlobBaseFeeQueryFnData
|
|
49
|
+
|
|
50
|
+
export function getBlobBaseFeeQueryKey<
|
|
51
|
+
config extends Config,
|
|
52
|
+
chainId extends config['chains'][number]['id'],
|
|
53
|
+
>(
|
|
54
|
+
options: Compute<
|
|
55
|
+
ExactPartial<GetBlobBaseFeeParameters<config, chainId>> & ScopeKeyParameter
|
|
56
|
+
> = {},
|
|
57
|
+
) {
|
|
58
|
+
return ['blobBaseFee', filterQueryOptions(options)] as const
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type GetBlobBaseFeeQueryKey<
|
|
62
|
+
config extends Config,
|
|
63
|
+
chainId extends config['chains'][number]['id'],
|
|
64
|
+
> = ReturnType<typeof getBlobBaseFeeQueryKey<config, chainId>>
|
|
65
|
+
|
|
66
|
+
export type GetBlobBaseFeeQueryOptions<
|
|
67
|
+
config extends Config,
|
|
68
|
+
chainId extends config['chains'][number]['id'],
|
|
69
|
+
selectData = GetBlobBaseFeeData,
|
|
70
|
+
> = QueryOptions<
|
|
71
|
+
GetBlobBaseFeeQueryFnData,
|
|
72
|
+
GetBlobBaseFeeErrorType,
|
|
73
|
+
selectData,
|
|
74
|
+
GetBlobBaseFeeQueryKey<config, chainId>
|
|
75
|
+
>
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import type { Abi, BlockNumber, BlockTag, ContractEventName } from 'viem'
|
|
2
|
+
import {
|
|
3
|
+
type GetContractEventsErrorType,
|
|
4
|
+
type GetContractEventsParameters,
|
|
5
|
+
type GetContractEventsReturnType,
|
|
6
|
+
getContractEvents,
|
|
7
|
+
} from '../actions/getContractEvents.js'
|
|
8
|
+
import type { Config } from '../createConfig.js'
|
|
9
|
+
import type { ScopeKeyParameter } from '../types/properties.js'
|
|
10
|
+
import type { QueryOptions, QueryParameter } from '../types/query.js'
|
|
11
|
+
import type { UnionExactPartial } from '../types/utils.js'
|
|
12
|
+
import { filterQueryOptions, structuralSharing } from './utils.js'
|
|
13
|
+
|
|
14
|
+
export type GetContractEventsOptions<
|
|
15
|
+
abi extends Abi | readonly unknown[],
|
|
16
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
17
|
+
strict extends boolean | undefined,
|
|
18
|
+
fromBlock extends BlockNumber | BlockTag | undefined,
|
|
19
|
+
toBlock extends BlockNumber | BlockTag | undefined,
|
|
20
|
+
config extends Config,
|
|
21
|
+
chainId extends config['chains'][number]['id'],
|
|
22
|
+
selectData = GetContractEventsData<
|
|
23
|
+
abi,
|
|
24
|
+
eventName,
|
|
25
|
+
strict,
|
|
26
|
+
fromBlock,
|
|
27
|
+
toBlock
|
|
28
|
+
>,
|
|
29
|
+
> = UnionExactPartial<
|
|
30
|
+
GetContractEventsParameters<
|
|
31
|
+
abi,
|
|
32
|
+
eventName,
|
|
33
|
+
strict,
|
|
34
|
+
fromBlock,
|
|
35
|
+
toBlock,
|
|
36
|
+
config,
|
|
37
|
+
chainId
|
|
38
|
+
>
|
|
39
|
+
> &
|
|
40
|
+
ScopeKeyParameter &
|
|
41
|
+
QueryParameter<
|
|
42
|
+
GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>,
|
|
43
|
+
GetContractEventsErrorType,
|
|
44
|
+
selectData,
|
|
45
|
+
GetContractEventsQueryKey<
|
|
46
|
+
config,
|
|
47
|
+
chainId,
|
|
48
|
+
abi,
|
|
49
|
+
eventName,
|
|
50
|
+
strict,
|
|
51
|
+
fromBlock,
|
|
52
|
+
toBlock
|
|
53
|
+
>
|
|
54
|
+
>
|
|
55
|
+
|
|
56
|
+
export function getContractEventsQueryOptions<
|
|
57
|
+
config extends Config,
|
|
58
|
+
chainId extends config['chains'][number]['id'],
|
|
59
|
+
const abi extends Abi | readonly unknown[],
|
|
60
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
61
|
+
strict extends boolean | undefined = undefined,
|
|
62
|
+
fromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
|
63
|
+
toBlock extends BlockNumber | BlockTag | undefined = undefined,
|
|
64
|
+
selectData = GetContractEventsData<
|
|
65
|
+
abi,
|
|
66
|
+
eventName,
|
|
67
|
+
strict,
|
|
68
|
+
fromBlock,
|
|
69
|
+
toBlock
|
|
70
|
+
>,
|
|
71
|
+
>(
|
|
72
|
+
config: config,
|
|
73
|
+
options: GetContractEventsOptions<
|
|
74
|
+
abi,
|
|
75
|
+
eventName,
|
|
76
|
+
strict,
|
|
77
|
+
fromBlock,
|
|
78
|
+
toBlock,
|
|
79
|
+
config,
|
|
80
|
+
chainId,
|
|
81
|
+
selectData
|
|
82
|
+
> = {} as any,
|
|
83
|
+
): GetContractEventsQueryOptions<
|
|
84
|
+
abi,
|
|
85
|
+
eventName,
|
|
86
|
+
strict,
|
|
87
|
+
fromBlock,
|
|
88
|
+
toBlock,
|
|
89
|
+
config,
|
|
90
|
+
chainId,
|
|
91
|
+
selectData
|
|
92
|
+
> {
|
|
93
|
+
return {
|
|
94
|
+
...options.query,
|
|
95
|
+
enabled: Boolean(options.abi && (options.query?.enabled ?? true)),
|
|
96
|
+
queryFn: async (context) => {
|
|
97
|
+
if (!options.abi) throw new Error('abi is required')
|
|
98
|
+
const [, { scopeKey: _, ...parameters }] = context.queryKey
|
|
99
|
+
const result = await getContractEvents(config, {
|
|
100
|
+
...(parameters as any),
|
|
101
|
+
abi: options.abi,
|
|
102
|
+
})
|
|
103
|
+
return result as GetContractEventsData<
|
|
104
|
+
abi,
|
|
105
|
+
eventName,
|
|
106
|
+
strict,
|
|
107
|
+
fromBlock,
|
|
108
|
+
toBlock
|
|
109
|
+
>
|
|
110
|
+
},
|
|
111
|
+
queryKey: getContractEventsQueryKey(options as any) as any,
|
|
112
|
+
structuralSharing,
|
|
113
|
+
} as GetContractEventsQueryOptions<
|
|
114
|
+
abi,
|
|
115
|
+
eventName,
|
|
116
|
+
strict,
|
|
117
|
+
fromBlock,
|
|
118
|
+
toBlock,
|
|
119
|
+
config,
|
|
120
|
+
chainId,
|
|
121
|
+
selectData
|
|
122
|
+
>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type GetContractEventsQueryFnData<
|
|
126
|
+
abi extends Abi | readonly unknown[],
|
|
127
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
128
|
+
strict extends boolean | undefined,
|
|
129
|
+
fromBlock extends BlockNumber | BlockTag | undefined,
|
|
130
|
+
toBlock extends BlockNumber | BlockTag | undefined,
|
|
131
|
+
> = GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>
|
|
132
|
+
|
|
133
|
+
export type GetContractEventsData<
|
|
134
|
+
abi extends Abi | readonly unknown[],
|
|
135
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
136
|
+
strict extends boolean | undefined,
|
|
137
|
+
fromBlock extends BlockNumber | BlockTag | undefined,
|
|
138
|
+
toBlock extends BlockNumber | BlockTag | undefined,
|
|
139
|
+
> = GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>
|
|
140
|
+
|
|
141
|
+
export function getContractEventsQueryKey<
|
|
142
|
+
config extends Config,
|
|
143
|
+
chainId extends config['chains'][number]['id'],
|
|
144
|
+
const abi extends Abi | readonly unknown[],
|
|
145
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
146
|
+
strict extends boolean | undefined = undefined,
|
|
147
|
+
fromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
|
148
|
+
toBlock extends BlockNumber | BlockTag | undefined = undefined,
|
|
149
|
+
>(
|
|
150
|
+
options: UnionExactPartial<
|
|
151
|
+
GetContractEventsParameters<
|
|
152
|
+
abi,
|
|
153
|
+
eventName,
|
|
154
|
+
strict,
|
|
155
|
+
fromBlock,
|
|
156
|
+
toBlock,
|
|
157
|
+
config,
|
|
158
|
+
chainId
|
|
159
|
+
>
|
|
160
|
+
> &
|
|
161
|
+
ScopeKeyParameter = {} as any,
|
|
162
|
+
) {
|
|
163
|
+
return ['getContractEvents', filterQueryOptions(options)] as const
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type GetContractEventsQueryKey<
|
|
167
|
+
config extends Config,
|
|
168
|
+
chainId extends config['chains'][number]['id'],
|
|
169
|
+
abi extends Abi | readonly unknown[],
|
|
170
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
171
|
+
strict extends boolean | undefined,
|
|
172
|
+
fromBlock extends BlockNumber | BlockTag | undefined,
|
|
173
|
+
toBlock extends BlockNumber | BlockTag | undefined,
|
|
174
|
+
> = ReturnType<
|
|
175
|
+
typeof getContractEventsQueryKey<
|
|
176
|
+
config,
|
|
177
|
+
chainId,
|
|
178
|
+
abi,
|
|
179
|
+
eventName,
|
|
180
|
+
strict,
|
|
181
|
+
fromBlock,
|
|
182
|
+
toBlock
|
|
183
|
+
>
|
|
184
|
+
>
|
|
185
|
+
|
|
186
|
+
export type GetContractEventsQueryOptions<
|
|
187
|
+
abi extends Abi | readonly unknown[],
|
|
188
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
189
|
+
strict extends boolean | undefined,
|
|
190
|
+
fromBlock extends BlockNumber | BlockTag | undefined,
|
|
191
|
+
toBlock extends BlockNumber | BlockTag | undefined,
|
|
192
|
+
config extends Config,
|
|
193
|
+
chainId extends config['chains'][number]['id'],
|
|
194
|
+
selectData = GetContractEventsData<
|
|
195
|
+
abi,
|
|
196
|
+
eventName,
|
|
197
|
+
strict,
|
|
198
|
+
fromBlock,
|
|
199
|
+
toBlock
|
|
200
|
+
>,
|
|
201
|
+
> = QueryOptions<
|
|
202
|
+
GetContractEventsQueryFnData<abi, eventName, strict, fromBlock, toBlock>,
|
|
203
|
+
GetContractEventsErrorType,
|
|
204
|
+
selectData,
|
|
205
|
+
GetContractEventsQueryKey<
|
|
206
|
+
config,
|
|
207
|
+
chainId,
|
|
208
|
+
abi,
|
|
209
|
+
eventName,
|
|
210
|
+
strict,
|
|
211
|
+
fromBlock,
|
|
212
|
+
toBlock
|
|
213
|
+
>
|
|
214
|
+
>
|
|
@@ -92,14 +92,24 @@ export function readContractsQueryKey<
|
|
|
92
92
|
ChainIdParameter<config> = {},
|
|
93
93
|
) {
|
|
94
94
|
const contracts = []
|
|
95
|
+
let hasContractWithoutChainId = false
|
|
95
96
|
for (const contract of (options.contracts ??
|
|
96
97
|
[]) as (ContractFunctionParameters & { chainId: number })[]) {
|
|
97
98
|
const { abi: _, ...rest } = contract
|
|
98
|
-
|
|
99
|
+
if (rest.chainId === undefined) hasContractWithoutChainId = true
|
|
100
|
+
const chainId = rest.chainId ?? options.chainId
|
|
101
|
+
contracts.push({ ...rest, ...(chainId ? { chainId } : {}) })
|
|
99
102
|
}
|
|
103
|
+
const { chainId: _, ...rest } = options
|
|
100
104
|
return [
|
|
101
105
|
'readContracts',
|
|
102
|
-
filterQueryOptions({
|
|
106
|
+
filterQueryOptions({
|
|
107
|
+
...rest,
|
|
108
|
+
...(hasContractWithoutChainId && options.chainId
|
|
109
|
+
? { chainId: options.chainId }
|
|
110
|
+
: {}),
|
|
111
|
+
contracts,
|
|
112
|
+
}),
|
|
103
113
|
] as const
|
|
104
114
|
}
|
|
105
115
|
|
package/src/query/reconnect.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MutationOptions } from '@tanstack/query-core'
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
type ReconnectErrorType,
|
|
5
4
|
type ReconnectParameters,
|
|
@@ -7,22 +6,36 @@ import {
|
|
|
7
6
|
reconnect,
|
|
8
7
|
} from '../actions/reconnect.js'
|
|
9
8
|
import type { Config } from '../createConfig.js'
|
|
9
|
+
import type { MutationParameter } from '../types/query.js'
|
|
10
10
|
import type { Compute } from '../types/utils.js'
|
|
11
11
|
import type { Mutate, MutateAsync } from './types.js'
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type ReconnectOptions<context = unknown> = MutationParameter<
|
|
14
|
+
ReconnectData,
|
|
15
|
+
ReconnectErrorType,
|
|
16
|
+
ReconnectVariables,
|
|
17
|
+
context
|
|
18
|
+
>
|
|
19
|
+
|
|
20
|
+
export function reconnectMutationOptions<context>(
|
|
21
|
+
config: Config,
|
|
22
|
+
options: ReconnectOptions<context> = {},
|
|
23
|
+
): ReconnectMutationOptions {
|
|
14
24
|
return {
|
|
25
|
+
...(options.mutation as any),
|
|
15
26
|
mutationFn(variables) {
|
|
16
27
|
return reconnect(config, variables)
|
|
17
28
|
},
|
|
18
29
|
mutationKey: ['reconnect'],
|
|
19
|
-
}
|
|
20
|
-
ReconnectData,
|
|
21
|
-
ReconnectErrorType,
|
|
22
|
-
ReconnectVariables
|
|
23
|
-
>
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
|
|
33
|
+
export type ReconnectMutationOptions = MutationOptions<
|
|
34
|
+
ReconnectData,
|
|
35
|
+
ReconnectErrorType,
|
|
36
|
+
ReconnectVariables
|
|
37
|
+
>
|
|
38
|
+
|
|
26
39
|
export type ReconnectData = Compute<ReconnectReturnType>
|
|
27
40
|
|
|
28
41
|
export type ReconnectVariables = ReconnectParameters | undefined
|