wagmi 3.3.1 → 3.3.2
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/hooks/codegen/createUseReadContract.js.map +1 -1
- package/dist/esm/hooks/codegen/createUseSimulateContract.js.map +1 -1
- package/dist/esm/hooks/useBalance.js +2 -3
- package/dist/esm/hooks/useBalance.js.map +1 -1
- package/dist/esm/hooks/useBlock.js +10 -13
- package/dist/esm/hooks/useBlock.js.map +1 -1
- package/dist/esm/hooks/useBlockNumber.js +10 -9
- package/dist/esm/hooks/useBlockNumber.js.map +1 -1
- package/dist/esm/hooks/useBlockTransactionCount.js +4 -5
- package/dist/esm/hooks/useBlockTransactionCount.js.map +1 -1
- package/dist/esm/hooks/useBytecode.js +2 -3
- package/dist/esm/hooks/useBytecode.js.map +1 -1
- package/dist/esm/hooks/useCall.js +2 -2
- package/dist/esm/hooks/useCall.js.map +1 -1
- package/dist/esm/hooks/useCallsStatus.js +8 -3
- package/dist/esm/hooks/useCallsStatus.js.map +1 -1
- package/dist/esm/hooks/useCapabilities.js +5 -7
- package/dist/esm/hooks/useCapabilities.js.map +1 -1
- package/dist/esm/hooks/useConnectorClient.js +10 -20
- package/dist/esm/hooks/useConnectorClient.js.map +1 -1
- package/dist/esm/hooks/useEnsAddress.js +2 -3
- package/dist/esm/hooks/useEnsAddress.js.map +1 -1
- package/dist/esm/hooks/useEnsAvatar.js +2 -3
- package/dist/esm/hooks/useEnsAvatar.js.map +1 -1
- package/dist/esm/hooks/useEnsName.js +2 -3
- package/dist/esm/hooks/useEnsName.js.map +1 -1
- package/dist/esm/hooks/useEnsResolver.js +2 -3
- package/dist/esm/hooks/useEnsResolver.js.map +1 -1
- package/dist/esm/hooks/useEnsText.js +2 -3
- package/dist/esm/hooks/useEnsText.js.map +1 -1
- package/dist/esm/hooks/useEstimateFeesPerGas.js +2 -2
- package/dist/esm/hooks/useEstimateFeesPerGas.js.map +1 -1
- package/dist/esm/hooks/useEstimateGas.js +6 -12
- package/dist/esm/hooks/useEstimateGas.js.map +1 -1
- package/dist/esm/hooks/useEstimateMaxPriorityFeePerGas.js +2 -2
- package/dist/esm/hooks/useEstimateMaxPriorityFeePerGas.js.map +1 -1
- package/dist/esm/hooks/useFeeHistory.js +2 -3
- package/dist/esm/hooks/useFeeHistory.js.map +1 -1
- package/dist/esm/hooks/useGasPrice.js +4 -5
- package/dist/esm/hooks/useGasPrice.js.map +1 -1
- package/dist/esm/hooks/usePrepareTransactionRequest.js +2 -7
- package/dist/esm/hooks/usePrepareTransactionRequest.js.map +1 -1
- package/dist/esm/hooks/useProof.js +2 -3
- package/dist/esm/hooks/useProof.js.map +1 -1
- package/dist/esm/hooks/useReadContract.js +6 -11
- package/dist/esm/hooks/useReadContract.js.map +1 -1
- package/dist/esm/hooks/useReadContracts.js +9 -24
- package/dist/esm/hooks/useReadContracts.js.map +1 -1
- package/dist/esm/hooks/useSimulateContract.js +6 -10
- package/dist/esm/hooks/useSimulateContract.js.map +1 -1
- package/dist/esm/hooks/useStorageAt.js +2 -3
- package/dist/esm/hooks/useStorageAt.js.map +1 -1
- package/dist/esm/hooks/useTransaction.js +2 -7
- package/dist/esm/hooks/useTransaction.js.map +1 -1
- package/dist/esm/hooks/useTransactionConfirmations.js +2 -5
- package/dist/esm/hooks/useTransactionConfirmations.js.map +1 -1
- package/dist/esm/hooks/useTransactionCount.js +2 -3
- package/dist/esm/hooks/useTransactionCount.js.map +1 -1
- package/dist/esm/hooks/useTransactionReceipt.js +2 -7
- package/dist/esm/hooks/useTransactionReceipt.js.map +1 -1
- package/dist/esm/hooks/useVerifyMessage.js +2 -3
- package/dist/esm/hooks/useVerifyMessage.js.map +1 -1
- package/dist/esm/hooks/useVerifyTypedData.js +2 -8
- package/dist/esm/hooks/useVerifyTypedData.js.map +1 -1
- package/dist/esm/hooks/useWaitForCallsStatus.js +8 -4
- package/dist/esm/hooks/useWaitForCallsStatus.js.map +1 -1
- package/dist/esm/hooks/useWaitForTransactionReceipt.js +2 -7
- package/dist/esm/hooks/useWaitForTransactionReceipt.js.map +1 -1
- package/dist/esm/hooks/useWalletClient.js +9 -19
- package/dist/esm/hooks/useWalletClient.js.map +1 -1
- package/dist/esm/tempo/hooks/amm.js.map +1 -1
- package/dist/esm/tempo/hooks/dex.js.map +1 -1
- package/dist/esm/tempo/hooks/fee.js.map +1 -1
- package/dist/esm/tempo/hooks/nonce.js.map +1 -1
- package/dist/esm/tempo/hooks/policy.js.map +1 -1
- package/dist/esm/tempo/hooks/reward.js.map +1 -1
- package/dist/esm/tempo/hooks/token.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/hooks/codegen/createUseReadContract.d.ts +5 -5
- package/dist/types/hooks/codegen/createUseReadContract.d.ts.map +1 -1
- package/dist/types/hooks/codegen/createUseSimulateContract.d.ts +5 -5
- package/dist/types/hooks/codegen/createUseSimulateContract.d.ts.map +1 -1
- package/dist/types/hooks/useBalance.d.ts +3 -4
- package/dist/types/hooks/useBalance.d.ts.map +1 -1
- package/dist/types/hooks/useBlock.d.ts +3 -3
- package/dist/types/hooks/useBlock.d.ts.map +1 -1
- package/dist/types/hooks/useBlockNumber.d.ts +3 -3
- package/dist/types/hooks/useBlockNumber.d.ts.map +1 -1
- package/dist/types/hooks/useBlockTransactionCount.d.ts +3 -3
- package/dist/types/hooks/useBlockTransactionCount.d.ts.map +1 -1
- package/dist/types/hooks/useBytecode.d.ts +3 -4
- package/dist/types/hooks/useBytecode.d.ts.map +1 -1
- package/dist/types/hooks/useCall.d.ts +3 -4
- package/dist/types/hooks/useCall.d.ts.map +1 -1
- package/dist/types/hooks/useCallsStatus.d.ts +3 -3
- package/dist/types/hooks/useCallsStatus.d.ts.map +1 -1
- package/dist/types/hooks/useCapabilities.d.ts +3 -3
- package/dist/types/hooks/useCapabilities.d.ts.map +1 -1
- package/dist/types/hooks/useConnectorClient.d.ts +4 -6
- package/dist/types/hooks/useConnectorClient.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAddress.d.ts +3 -3
- package/dist/types/hooks/useEnsAddress.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAvatar.d.ts +3 -3
- package/dist/types/hooks/useEnsAvatar.d.ts.map +1 -1
- package/dist/types/hooks/useEnsName.d.ts +3 -3
- package/dist/types/hooks/useEnsName.d.ts.map +1 -1
- package/dist/types/hooks/useEnsResolver.d.ts +3 -3
- package/dist/types/hooks/useEnsResolver.d.ts.map +1 -1
- package/dist/types/hooks/useEnsText.d.ts +3 -3
- package/dist/types/hooks/useEnsText.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts +3 -3
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateGas.d.ts +3 -3
- package/dist/types/hooks/useEstimateGas.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateMaxPriorityFeePerGas.d.ts +3 -3
- package/dist/types/hooks/useEstimateMaxPriorityFeePerGas.d.ts.map +1 -1
- package/dist/types/hooks/useFeeHistory.d.ts +3 -3
- package/dist/types/hooks/useFeeHistory.d.ts.map +1 -1
- package/dist/types/hooks/useGasPrice.d.ts +3 -3
- package/dist/types/hooks/useGasPrice.d.ts.map +1 -1
- package/dist/types/hooks/usePrepareTransactionRequest.d.ts +3 -4
- package/dist/types/hooks/usePrepareTransactionRequest.d.ts.map +1 -1
- package/dist/types/hooks/useProof.d.ts +3 -4
- package/dist/types/hooks/useProof.d.ts.map +1 -1
- package/dist/types/hooks/useReadContract.d.ts +3 -3
- package/dist/types/hooks/useReadContract.d.ts.map +1 -1
- package/dist/types/hooks/useReadContracts.d.ts +3 -3
- package/dist/types/hooks/useReadContracts.d.ts.map +1 -1
- package/dist/types/hooks/useSimulateContract.d.ts +4 -4
- package/dist/types/hooks/useSimulateContract.d.ts.map +1 -1
- package/dist/types/hooks/useStorageAt.d.ts +3 -4
- package/dist/types/hooks/useStorageAt.d.ts.map +1 -1
- package/dist/types/hooks/useTransaction.d.ts +3 -3
- package/dist/types/hooks/useTransaction.d.ts.map +1 -1
- package/dist/types/hooks/useTransactionConfirmations.d.ts +3 -3
- package/dist/types/hooks/useTransactionConfirmations.d.ts.map +1 -1
- package/dist/types/hooks/useTransactionCount.d.ts +3 -4
- package/dist/types/hooks/useTransactionCount.d.ts.map +1 -1
- package/dist/types/hooks/useTransactionReceipt.d.ts +3 -4
- package/dist/types/hooks/useTransactionReceipt.d.ts.map +1 -1
- package/dist/types/hooks/useVerifyMessage.d.ts +3 -4
- package/dist/types/hooks/useVerifyMessage.d.ts.map +1 -1
- package/dist/types/hooks/useVerifyTypedData.d.ts +3 -4
- package/dist/types/hooks/useVerifyTypedData.d.ts.map +1 -1
- package/dist/types/hooks/useWaitForCallsStatus.d.ts +3 -3
- package/dist/types/hooks/useWaitForCallsStatus.d.ts.map +1 -1
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts +3 -3
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/hooks/useWalletClient.d.ts +4 -6
- package/dist/types/hooks/useWalletClient.d.ts.map +1 -1
- package/dist/types/tempo/hooks/amm.d.ts +3 -3
- package/dist/types/tempo/hooks/amm.d.ts.map +1 -1
- package/dist/types/tempo/hooks/dex.d.ts +7 -7
- package/dist/types/tempo/hooks/dex.d.ts.map +1 -1
- package/dist/types/tempo/hooks/fee.d.ts +2 -2
- package/dist/types/tempo/hooks/fee.d.ts.map +1 -1
- package/dist/types/tempo/hooks/nonce.d.ts +2 -2
- package/dist/types/tempo/hooks/nonce.d.ts.map +1 -1
- package/dist/types/tempo/hooks/policy.d.ts +3 -3
- package/dist/types/tempo/hooks/policy.d.ts.map +1 -1
- package/dist/types/tempo/hooks/reward.d.ts +3 -3
- package/dist/types/tempo/hooks/reward.d.ts.map +1 -1
- package/dist/types/tempo/hooks/token.d.ts +6 -6
- package/dist/types/tempo/hooks/token.d.ts.map +1 -1
- package/dist/types/types/properties.d.ts +1 -4
- package/dist/types/types/properties.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/exports/internal.ts +1 -4
- package/src/hooks/codegen/createUseReadContract.ts +9 -10
- package/src/hooks/codegen/createUseSimulateContract.ts +9 -6
- package/src/hooks/useBalance.ts +4 -21
- package/src/hooks/useBlock.ts +13 -36
- package/src/hooks/useBlockNumber.ts +13 -26
- package/src/hooks/useBlockTransactionCount.ts +7 -21
- package/src/hooks/useBytecode.ts +4 -20
- package/src/hooks/useCall.ts +4 -20
- package/src/hooks/useCallsStatus.ts +10 -21
- package/src/hooks/useCapabilities.ts +7 -23
- package/src/hooks/useConnectorClient.ts +13 -50
- package/src/hooks/useEnsAddress.ts +4 -21
- package/src/hooks/useEnsAvatar.ts +4 -21
- package/src/hooks/useEnsName.ts +4 -21
- package/src/hooks/useEnsResolver.ts +4 -21
- package/src/hooks/useEnsText.ts +4 -21
- package/src/hooks/useEstimateFeesPerGas.ts +4 -18
- package/src/hooks/useEstimateGas.ts +8 -28
- package/src/hooks/useEstimateMaxPriorityFeePerGas.ts +5 -18
- package/src/hooks/useFeeHistory.ts +4 -21
- package/src/hooks/useGasPrice.ts +6 -21
- package/src/hooks/usePrepareTransactionRequest.ts +5 -28
- package/src/hooks/useProof.ts +4 -21
- package/src/hooks/useReadContract.ts +9 -33
- package/src/hooks/useReadContracts.ts +13 -45
- package/src/hooks/useSimulateContract.ts +19 -37
- package/src/hooks/useStorageAt.ts +4 -20
- package/src/hooks/useTransaction.ts +4 -25
- package/src/hooks/useTransactionConfirmations.ts +5 -23
- package/src/hooks/useTransactionCount.ts +4 -19
- package/src/hooks/useTransactionReceipt.ts +5 -22
- package/src/hooks/useVerifyMessage.ts +4 -22
- package/src/hooks/useVerifyTypedData.ts +9 -39
- package/src/hooks/useWaitForCallsStatus.ts +10 -22
- package/src/hooks/useWaitForTransactionReceipt.ts +5 -23
- package/src/hooks/useWalletClient.ts +15 -56
- package/src/tempo/hooks/amm.ts +5 -23
- package/src/tempo/hooks/dex.ts +13 -55
- package/src/tempo/hooks/fee.ts +3 -10
- package/src/tempo/hooks/nonce.ts +2 -11
- package/src/tempo/hooks/policy.ts +3 -21
- package/src/tempo/hooks/reward.ts +7 -25
- package/src/tempo/hooks/token.ts +6 -51
- package/src/types/properties.ts +1 -18
- package/src/version.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
EstimateGasErrorType,
|
|
@@ -8,29 +7,19 @@ import type {
|
|
|
8
7
|
import {
|
|
9
8
|
type EstimateGasData,
|
|
10
9
|
type EstimateGasOptions,
|
|
11
|
-
type EstimateGasQueryFnData,
|
|
12
|
-
type EstimateGasQueryKey,
|
|
13
10
|
estimateGasQueryOptions,
|
|
14
11
|
} from '@wagmi/core/query'
|
|
15
|
-
|
|
16
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
12
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
17
13
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
18
14
|
import { useChainId } from './useChainId.js'
|
|
19
15
|
import { useConfig } from './useConfig.js'
|
|
20
|
-
import {
|
|
16
|
+
import { useConnection } from './useConnection.js'
|
|
21
17
|
|
|
22
18
|
export type UseEstimateGasParameters<
|
|
23
19
|
config extends Config = Config,
|
|
24
20
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
25
21
|
selectData = EstimateGasData,
|
|
26
|
-
> = EstimateGasOptions<config, chainId> &
|
|
27
|
-
ConfigParameter<config> &
|
|
28
|
-
QueryParameter<
|
|
29
|
-
EstimateGasQueryFnData,
|
|
30
|
-
EstimateGasErrorType,
|
|
31
|
-
selectData,
|
|
32
|
-
EstimateGasQueryKey<config, chainId>
|
|
33
|
-
>
|
|
22
|
+
> = EstimateGasOptions<config, chainId, selectData> & ConfigParameter<config>
|
|
34
23
|
|
|
35
24
|
export type UseEstimateGasReturnType<selectData = EstimateGasData> =
|
|
36
25
|
UseQueryReturnType<selectData, EstimateGasErrorType>
|
|
@@ -47,24 +36,15 @@ export function useEstimateGas<
|
|
|
47
36
|
export function useEstimateGas(
|
|
48
37
|
parameters: UseEstimateGasParameters = {},
|
|
49
38
|
): UseEstimateGasReturnType {
|
|
50
|
-
const { connector, query = {} } = parameters
|
|
51
|
-
|
|
52
39
|
const config = useConfig(parameters)
|
|
53
|
-
const {
|
|
54
|
-
config,
|
|
55
|
-
connector,
|
|
56
|
-
query: { enabled: parameters.account === undefined },
|
|
57
|
-
})
|
|
58
|
-
const account = parameters.account ?? connectorClient?.account
|
|
40
|
+
const { address, connector } = useConnection()
|
|
59
41
|
const chainId = useChainId({ config })
|
|
60
|
-
|
|
61
42
|
const options = estimateGasQueryOptions(config, {
|
|
62
43
|
...parameters,
|
|
63
|
-
account,
|
|
44
|
+
account: parameters.account ?? address,
|
|
64
45
|
chainId: parameters.chainId ?? chainId,
|
|
65
|
-
connector,
|
|
46
|
+
connector: parameters.connector ?? connector,
|
|
47
|
+
query: parameters.query,
|
|
66
48
|
})
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return useQuery({ ...query, ...options, enabled })
|
|
49
|
+
return useQuery(options)
|
|
70
50
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
EstimateMaxPriorityFeePerGasErrorType,
|
|
@@ -9,12 +8,9 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
9
8
|
import {
|
|
10
9
|
type EstimateMaxPriorityFeePerGasData,
|
|
11
10
|
type EstimateMaxPriorityFeePerGasOptions,
|
|
12
|
-
type EstimateMaxPriorityFeePerGasQueryFnData,
|
|
13
|
-
type EstimateMaxPriorityFeePerGasQueryKey,
|
|
14
11
|
estimateMaxPriorityFeePerGasQueryOptions,
|
|
15
12
|
} from '@wagmi/core/query'
|
|
16
|
-
|
|
17
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
18
14
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
15
|
import { useChainId } from './useChainId.js'
|
|
20
16
|
import { useConfig } from './useConfig.js'
|
|
@@ -23,14 +19,8 @@ export type UseEstimateMaxPriorityFeePerGasParameters<
|
|
|
23
19
|
config extends Config = Config,
|
|
24
20
|
selectData = EstimateMaxPriorityFeePerGasData,
|
|
25
21
|
> = Compute<
|
|
26
|
-
EstimateMaxPriorityFeePerGasOptions<config> &
|
|
27
|
-
ConfigParameter<config>
|
|
28
|
-
QueryParameter<
|
|
29
|
-
EstimateMaxPriorityFeePerGasQueryFnData,
|
|
30
|
-
EstimateMaxPriorityFeePerGasErrorType,
|
|
31
|
-
selectData,
|
|
32
|
-
EstimateMaxPriorityFeePerGasQueryKey<config>
|
|
33
|
-
>
|
|
22
|
+
EstimateMaxPriorityFeePerGasOptions<config, selectData> &
|
|
23
|
+
ConfigParameter<config>
|
|
34
24
|
>
|
|
35
25
|
|
|
36
26
|
export type UseEstimateMaxPriorityFeePerGasReturnType<
|
|
@@ -47,15 +37,12 @@ export function useEstimateMaxPriorityFeePerGas<
|
|
|
47
37
|
selectData
|
|
48
38
|
> = {},
|
|
49
39
|
): UseEstimateMaxPriorityFeePerGasReturnType<selectData> {
|
|
50
|
-
const { query = {} } = parameters
|
|
51
|
-
|
|
52
40
|
const config = useConfig(parameters)
|
|
53
41
|
const chainId = useChainId({ config })
|
|
54
|
-
|
|
55
42
|
const options = estimateMaxPriorityFeePerGasQueryOptions(config, {
|
|
56
43
|
...parameters,
|
|
57
44
|
chainId: parameters.chainId ?? chainId,
|
|
45
|
+
query: parameters.query,
|
|
58
46
|
})
|
|
59
|
-
|
|
60
|
-
return useQuery({ ...query, ...options })
|
|
47
|
+
return useQuery(options)
|
|
61
48
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
GetFeeHistoryErrorType,
|
|
@@ -9,12 +8,9 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
9
8
|
import {
|
|
10
9
|
type GetFeeHistoryData,
|
|
11
10
|
type GetFeeHistoryOptions,
|
|
12
|
-
type GetFeeHistoryQueryFnData,
|
|
13
|
-
type GetFeeHistoryQueryKey,
|
|
14
11
|
getFeeHistoryQueryOptions,
|
|
15
12
|
} from '@wagmi/core/query'
|
|
16
|
-
|
|
17
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
18
14
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
15
|
import { useChainId } from './useChainId.js'
|
|
20
16
|
import { useConfig } from './useConfig.js'
|
|
@@ -25,14 +21,7 @@ export type UseFeeHistoryParameters<
|
|
|
25
21
|
config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
26
22
|
selectData = GetFeeHistoryData,
|
|
27
23
|
> = Compute<
|
|
28
|
-
GetFeeHistoryOptions<config, chainId> &
|
|
29
|
-
ConfigParameter<config> &
|
|
30
|
-
QueryParameter<
|
|
31
|
-
GetFeeHistoryQueryFnData,
|
|
32
|
-
GetFeeHistoryErrorType,
|
|
33
|
-
selectData,
|
|
34
|
-
GetFeeHistoryQueryKey<config, chainId>
|
|
35
|
-
>
|
|
24
|
+
GetFeeHistoryOptions<config, chainId, selectData> & ConfigParameter<config>
|
|
36
25
|
>
|
|
37
26
|
|
|
38
27
|
export type UseFeeHistoryReturnType<selectData = GetFeeHistoryData> =
|
|
@@ -47,18 +36,12 @@ export function useFeeHistory<
|
|
|
47
36
|
>(
|
|
48
37
|
parameters: UseFeeHistoryParameters<config, chainId, selectData> = {},
|
|
49
38
|
): UseFeeHistoryReturnType<selectData> {
|
|
50
|
-
const { blockCount, rewardPercentiles, query = {} } = parameters
|
|
51
|
-
|
|
52
39
|
const config = useConfig(parameters)
|
|
53
40
|
const chainId = useChainId({ config })
|
|
54
|
-
|
|
55
41
|
const options = getFeeHistoryQueryOptions(config, {
|
|
56
42
|
...parameters,
|
|
57
43
|
chainId: parameters.chainId ?? chainId,
|
|
44
|
+
query: parameters.query,
|
|
58
45
|
})
|
|
59
|
-
|
|
60
|
-
blockCount && rewardPercentiles && (query.enabled ?? true),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
return useQuery({ ...query, ...options, enabled })
|
|
46
|
+
return useQuery(options)
|
|
64
47
|
}
|
package/src/hooks/useGasPrice.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
GetGasPriceErrorType,
|
|
@@ -9,12 +8,9 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
9
8
|
import {
|
|
10
9
|
type GetGasPriceData,
|
|
11
10
|
type GetGasPriceOptions,
|
|
12
|
-
type GetGasPriceQueryFnData,
|
|
13
|
-
type GetGasPriceQueryKey,
|
|
14
11
|
getGasPriceQueryOptions,
|
|
15
12
|
} from '@wagmi/core/query'
|
|
16
|
-
|
|
17
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
18
14
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
15
|
import { useChainId } from './useChainId.js'
|
|
20
16
|
import { useConfig } from './useConfig.js'
|
|
@@ -25,14 +21,7 @@ export type UseGasPriceParameters<
|
|
|
25
21
|
config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
26
22
|
selectData = GetGasPriceData,
|
|
27
23
|
> = Compute<
|
|
28
|
-
GetGasPriceOptions<config, chainId> &
|
|
29
|
-
ConfigParameter<config> &
|
|
30
|
-
QueryParameter<
|
|
31
|
-
GetGasPriceQueryFnData,
|
|
32
|
-
GetGasPriceErrorType,
|
|
33
|
-
selectData,
|
|
34
|
-
GetGasPriceQueryKey<config, chainId>
|
|
35
|
-
>
|
|
24
|
+
GetGasPriceOptions<config, chainId, selectData> & ConfigParameter<config>
|
|
36
25
|
>
|
|
37
26
|
|
|
38
27
|
export type UseGasPriceReturnType<selectData = GetGasPriceData> =
|
|
@@ -47,16 +36,12 @@ export function useGasPrice<
|
|
|
47
36
|
>(
|
|
48
37
|
parameters: UseGasPriceParameters<config, chainId, selectData> = {},
|
|
49
38
|
): UseGasPriceReturnType<selectData> {
|
|
50
|
-
const { query = {} } = parameters
|
|
51
|
-
|
|
52
39
|
const config = useConfig(parameters)
|
|
53
|
-
const
|
|
54
|
-
const chainId = parameters.chainId ?? configChainId
|
|
55
|
-
|
|
40
|
+
const chainId = useChainId({ config })
|
|
56
41
|
const options = getGasPriceQueryOptions(config, {
|
|
57
42
|
...parameters,
|
|
58
|
-
chainId,
|
|
43
|
+
chainId: parameters.chainId ?? chainId,
|
|
44
|
+
query: parameters.query,
|
|
59
45
|
})
|
|
60
|
-
|
|
61
|
-
return useQuery({ ...query, ...options })
|
|
46
|
+
return useQuery(options)
|
|
62
47
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
PrepareTransactionRequestErrorType,
|
|
6
5
|
ResolvedRegister,
|
|
7
6
|
SelectChains,
|
|
8
7
|
} from '@wagmi/core'
|
|
9
|
-
import type { PrepareTransactionRequestQueryFnData } from '@wagmi/core/query'
|
|
10
8
|
import {
|
|
11
9
|
type PrepareTransactionRequestData,
|
|
12
10
|
type PrepareTransactionRequestOptions,
|
|
13
|
-
type PrepareTransactionRequestQueryKey,
|
|
14
11
|
prepareTransactionRequestQueryOptions,
|
|
15
12
|
} from '@wagmi/core/query'
|
|
16
13
|
import type { PrepareTransactionRequestRequest as viem_PrepareTransactionRequestRequest } from 'viem'
|
|
17
|
-
|
|
18
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
14
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
19
15
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
20
16
|
import { useChainId } from './useChainId.js'
|
|
21
17
|
import { useConfig } from './useConfig.js'
|
|
@@ -31,14 +27,8 @@ export type UsePrepareTransactionRequestParameters<
|
|
|
31
27
|
SelectChains<config, chainId>[0]
|
|
32
28
|
>,
|
|
33
29
|
selectData = PrepareTransactionRequestData<config, chainId, request>,
|
|
34
|
-
> = PrepareTransactionRequestOptions<config, chainId, request> &
|
|
35
|
-
ConfigParameter<config>
|
|
36
|
-
QueryParameter<
|
|
37
|
-
PrepareTransactionRequestQueryFnData<config, chainId, request>,
|
|
38
|
-
PrepareTransactionRequestErrorType,
|
|
39
|
-
selectData,
|
|
40
|
-
PrepareTransactionRequestQueryKey<config, chainId, request>
|
|
41
|
-
>
|
|
30
|
+
> = PrepareTransactionRequestOptions<config, chainId, request, selectData> &
|
|
31
|
+
ConfigParameter<config>
|
|
42
32
|
|
|
43
33
|
export type UsePrepareTransactionRequestReturnType<
|
|
44
34
|
config extends Config = Config,
|
|
@@ -78,25 +68,12 @@ export function usePrepareTransactionRequest<
|
|
|
78
68
|
request,
|
|
79
69
|
selectData
|
|
80
70
|
> {
|
|
81
|
-
const { to, query = {} } = parameters
|
|
82
|
-
|
|
83
71
|
const config = useConfig(parameters)
|
|
84
72
|
const chainId = useChainId({ config })
|
|
85
|
-
|
|
86
73
|
const options = prepareTransactionRequestQueryOptions(config, {
|
|
87
74
|
...parameters,
|
|
88
75
|
chainId: parameters.chainId ?? chainId,
|
|
76
|
+
query: parameters.query,
|
|
89
77
|
} as PrepareTransactionRequestOptions<config, chainId, request>)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return useQuery({
|
|
93
|
-
...(query as any),
|
|
94
|
-
...options,
|
|
95
|
-
enabled,
|
|
96
|
-
}) as UsePrepareTransactionRequestReturnType<
|
|
97
|
-
config,
|
|
98
|
-
chainId,
|
|
99
|
-
request,
|
|
100
|
-
selectData
|
|
101
|
-
>
|
|
78
|
+
return useQuery(options) as any
|
|
102
79
|
}
|
package/src/hooks/useProof.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type { Config, GetProofErrorType, ResolvedRegister } from '@wagmi/core'
|
|
4
3
|
import type { Compute } from '@wagmi/core/internal'
|
|
5
|
-
import type { GetProofQueryFnData } from '@wagmi/core/query'
|
|
6
4
|
import {
|
|
7
5
|
type GetProofData,
|
|
8
6
|
type GetProofOptions,
|
|
9
|
-
type GetProofQueryKey,
|
|
10
7
|
getProofQueryOptions,
|
|
11
8
|
} from '@wagmi/core/query'
|
|
12
|
-
|
|
13
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
9
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
14
10
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
15
11
|
import { useChainId } from './useChainId.js'
|
|
16
12
|
import { useConfig } from './useConfig.js'
|
|
@@ -18,16 +14,7 @@ import { useConfig } from './useConfig.js'
|
|
|
18
14
|
export type UseProofParameters<
|
|
19
15
|
config extends Config = Config,
|
|
20
16
|
selectData = GetProofData,
|
|
21
|
-
> = Compute<
|
|
22
|
-
GetProofOptions<config> &
|
|
23
|
-
ConfigParameter<config> &
|
|
24
|
-
QueryParameter<
|
|
25
|
-
GetProofQueryFnData,
|
|
26
|
-
GetProofErrorType,
|
|
27
|
-
selectData,
|
|
28
|
-
GetProofQueryKey<config>
|
|
29
|
-
>
|
|
30
|
-
>
|
|
17
|
+
> = Compute<GetProofOptions<config, selectData> & ConfigParameter<config>>
|
|
31
18
|
|
|
32
19
|
export type UseProofReturnType<selectData = GetProofData> = UseQueryReturnType<
|
|
33
20
|
selectData,
|
|
@@ -41,16 +28,12 @@ export function useProof<
|
|
|
41
28
|
>(
|
|
42
29
|
parameters: UseProofParameters<config, selectData> = {},
|
|
43
30
|
): UseProofReturnType<selectData> {
|
|
44
|
-
const { address, storageKeys, query = {} } = parameters
|
|
45
|
-
|
|
46
31
|
const config = useConfig(parameters)
|
|
47
32
|
const chainId = useChainId({ config })
|
|
48
|
-
|
|
49
33
|
const options = getProofQueryOptions(config, {
|
|
50
34
|
...parameters,
|
|
51
35
|
chainId: parameters.chainId ?? chainId,
|
|
36
|
+
query: parameters.query,
|
|
52
37
|
})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return useQuery({ ...query, ...options, enabled })
|
|
38
|
+
return useQuery(options)
|
|
56
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
ReadContractErrorType,
|
|
@@ -9,14 +8,10 @@ import type { UnionCompute } from '@wagmi/core/internal'
|
|
|
9
8
|
import {
|
|
10
9
|
type ReadContractData,
|
|
11
10
|
type ReadContractOptions,
|
|
12
|
-
type ReadContractQueryFnData,
|
|
13
|
-
type ReadContractQueryKey,
|
|
14
11
|
readContractQueryOptions,
|
|
15
|
-
structuralSharing,
|
|
16
12
|
} from '@wagmi/core/query'
|
|
17
|
-
import type { Abi, ContractFunctionArgs, ContractFunctionName
|
|
18
|
-
|
|
19
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'
|
|
14
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
20
15
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
21
16
|
import { useChainId } from './useChainId.js'
|
|
22
17
|
import { useConfig } from './useConfig.js'
|
|
@@ -35,14 +30,8 @@ export type UseReadContractParameters<
|
|
|
35
30
|
config extends Config = Config,
|
|
36
31
|
selectData = ReadContractData<abi, functionName, args>,
|
|
37
32
|
> = UnionCompute<
|
|
38
|
-
ReadContractOptions<abi, functionName, args, config> &
|
|
39
|
-
ConfigParameter<config>
|
|
40
|
-
QueryParameter<
|
|
41
|
-
ReadContractQueryFnData<abi, functionName, args>,
|
|
42
|
-
ReadContractErrorType,
|
|
43
|
-
selectData,
|
|
44
|
-
ReadContractQueryKey<abi, functionName, args, config>
|
|
45
|
-
>
|
|
33
|
+
ReadContractOptions<abi, functionName, args, config, selectData> &
|
|
34
|
+
ConfigParameter<config>
|
|
46
35
|
>
|
|
47
36
|
|
|
48
37
|
export type UseReadContractReturnType<
|
|
@@ -75,25 +64,12 @@ export function useReadContract<
|
|
|
75
64
|
selectData
|
|
76
65
|
> = {} as any,
|
|
77
66
|
): UseReadContractReturnType<abi, functionName, args, selectData> {
|
|
78
|
-
const { abi, address, functionName, query = {} } = parameters
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
const code = parameters.code as Hex | undefined
|
|
81
|
-
|
|
82
67
|
const config = useConfig(parameters)
|
|
83
68
|
const chainId = useChainId({ config })
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
const enabled = Boolean(
|
|
90
|
-
(address || code) && abi && functionName && (query.enabled ?? true),
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
return useQuery({
|
|
94
|
-
...query,
|
|
95
|
-
...options,
|
|
96
|
-
enabled,
|
|
97
|
-
structuralSharing: query.structuralSharing ?? structuralSharing,
|
|
69
|
+
const options = readContractQueryOptions(config, {
|
|
70
|
+
...(parameters as any),
|
|
71
|
+
chainId: parameters.chainId ?? chainId,
|
|
72
|
+
query: parameters.query,
|
|
98
73
|
})
|
|
74
|
+
return useQuery(options) as any
|
|
99
75
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
ReadContractsErrorType,
|
|
@@ -9,15 +8,11 @@ import type { Compute } from '@wagmi/core/internal'
|
|
|
9
8
|
import {
|
|
10
9
|
type ReadContractsData,
|
|
11
10
|
type ReadContractsOptions,
|
|
12
|
-
type ReadContractsQueryFnData,
|
|
13
|
-
type ReadContractsQueryKey,
|
|
14
11
|
readContractsQueryOptions,
|
|
15
|
-
structuralSharing,
|
|
16
12
|
} from '@wagmi/core/query'
|
|
17
13
|
import { useMemo } from 'react'
|
|
18
14
|
import type { ContractFunctionParameters } from 'viem'
|
|
19
|
-
|
|
20
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
15
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
21
16
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
22
17
|
import { useChainId } from './useChainId.js'
|
|
23
18
|
import { useConfig } from './useConfig.js'
|
|
@@ -28,14 +23,8 @@ export type UseReadContractsParameters<
|
|
|
28
23
|
config extends Config = Config,
|
|
29
24
|
selectData = ReadContractsData<contracts, allowFailure>,
|
|
30
25
|
> = Compute<
|
|
31
|
-
ReadContractsOptions<contracts, allowFailure, config> &
|
|
32
|
-
ConfigParameter<config>
|
|
33
|
-
QueryParameter<
|
|
34
|
-
ReadContractsQueryFnData<contracts, allowFailure>,
|
|
35
|
-
ReadContractsErrorType,
|
|
36
|
-
selectData,
|
|
37
|
-
ReadContractsQueryKey<contracts, allowFailure, config>
|
|
38
|
-
>
|
|
26
|
+
ReadContractsOptions<contracts, allowFailure, config, selectData> &
|
|
27
|
+
ConfigParameter<config>
|
|
39
28
|
>
|
|
40
29
|
|
|
41
30
|
export type UseReadContractsReturnType<
|
|
@@ -58,45 +47,24 @@ export function useReadContracts<
|
|
|
58
47
|
selectData
|
|
59
48
|
> = {},
|
|
60
49
|
): UseReadContractsReturnType<contracts, allowFailure, selectData> {
|
|
61
|
-
const { contracts = [], query = {} } = parameters
|
|
62
|
-
|
|
63
50
|
const config = useConfig(parameters)
|
|
64
51
|
const chainId = useChainId({ config })
|
|
65
52
|
const contractsChainId = useMemo(() => {
|
|
66
|
-
const firstChainId = (
|
|
67
|
-
?.chainId
|
|
53
|
+
const firstChainId = (
|
|
54
|
+
parameters.contracts?.[0] as { chainId?: number } | undefined
|
|
55
|
+
)?.chainId
|
|
68
56
|
if (
|
|
69
|
-
(contracts as { chainId?: number }[]).every(
|
|
57
|
+
((parameters.contracts ?? []) as { chainId?: number }[]).every(
|
|
70
58
|
(contract) => contract.chainId === firstChainId,
|
|
71
59
|
)
|
|
72
60
|
)
|
|
73
61
|
return firstChainId
|
|
74
62
|
return undefined
|
|
75
|
-
}, [contracts])
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
const enabled = useMemo(() => {
|
|
83
|
-
let isContractsValid = false
|
|
84
|
-
for (const contract of contracts) {
|
|
85
|
-
const { abi, address, functionName } =
|
|
86
|
-
contract as ContractFunctionParameters
|
|
87
|
-
if (!abi || !address || !functionName) {
|
|
88
|
-
isContractsValid = false
|
|
89
|
-
break
|
|
90
|
-
}
|
|
91
|
-
isContractsValid = true
|
|
92
|
-
}
|
|
93
|
-
return Boolean(isContractsValid && (query.enabled ?? true))
|
|
94
|
-
}, [contracts, query.enabled])
|
|
95
|
-
|
|
96
|
-
return useQuery({
|
|
97
|
-
...options,
|
|
98
|
-
...query,
|
|
99
|
-
enabled,
|
|
100
|
-
structuralSharing: query.structuralSharing ?? structuralSharing,
|
|
63
|
+
}, [parameters.contracts])
|
|
64
|
+
const options = readContractsQueryOptions(config, {
|
|
65
|
+
...parameters,
|
|
66
|
+
chainId: contractsChainId ?? chainId,
|
|
67
|
+
query: parameters.query,
|
|
101
68
|
})
|
|
69
|
+
return useQuery(options) as any
|
|
102
70
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
ResolvedRegister,
|
|
@@ -8,17 +7,14 @@ import type {
|
|
|
8
7
|
import {
|
|
9
8
|
type SimulateContractData,
|
|
10
9
|
type SimulateContractOptions,
|
|
11
|
-
type SimulateContractQueryFnData,
|
|
12
|
-
type SimulateContractQueryKey,
|
|
13
10
|
simulateContractQueryOptions,
|
|
14
11
|
} from '@wagmi/core/query'
|
|
15
12
|
import type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'
|
|
16
|
-
|
|
17
|
-
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
18
14
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
15
|
import { useChainId } from './useChainId.js'
|
|
20
16
|
import { useConfig } from './useConfig.js'
|
|
21
|
-
import {
|
|
17
|
+
import { useConnection } from './useConnection.js'
|
|
22
18
|
|
|
23
19
|
export type UseSimulateContractParameters<
|
|
24
20
|
abi extends Abi | readonly unknown[] = Abi,
|
|
@@ -34,14 +30,15 @@ export type UseSimulateContractParameters<
|
|
|
34
30
|
config extends Config = Config,
|
|
35
31
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
36
32
|
selectData = SimulateContractData<abi, functionName, args, config, chainId>,
|
|
37
|
-
> = SimulateContractOptions<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
> = SimulateContractOptions<
|
|
34
|
+
abi,
|
|
35
|
+
functionName,
|
|
36
|
+
args,
|
|
37
|
+
config,
|
|
38
|
+
chainId,
|
|
39
|
+
selectData
|
|
40
|
+
> &
|
|
41
|
+
ConfigParameter<config>
|
|
45
42
|
|
|
46
43
|
export type UseSimulateContractReturnType<
|
|
47
44
|
abi extends Abi | readonly unknown[] = Abi,
|
|
@@ -63,7 +60,7 @@ export type UseSimulateContractReturnType<
|
|
|
63
60
|
export function useSimulateContract<
|
|
64
61
|
const abi extends Abi | readonly unknown[],
|
|
65
62
|
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
66
|
-
args extends ContractFunctionArgs<
|
|
63
|
+
const args extends ContractFunctionArgs<
|
|
67
64
|
abi,
|
|
68
65
|
'nonpayable' | 'payable',
|
|
69
66
|
functionName
|
|
@@ -88,30 +85,15 @@ export function useSimulateContract<
|
|
|
88
85
|
chainId,
|
|
89
86
|
selectData
|
|
90
87
|
> {
|
|
91
|
-
const { abi, address, connector, functionName, query = {} } = parameters
|
|
92
|
-
|
|
93
88
|
const config = useConfig(parameters)
|
|
94
|
-
const {
|
|
95
|
-
config,
|
|
96
|
-
connector,
|
|
97
|
-
query: { enabled: parameters.account === undefined },
|
|
98
|
-
})
|
|
89
|
+
const { address, connector } = useConnection()
|
|
99
90
|
const chainId = useChainId({ config })
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
abi,
|
|
104
|
-
functionName,
|
|
105
|
-
args,
|
|
106
|
-
chainId
|
|
107
|
-
>(config, {
|
|
108
|
-
...parameters,
|
|
109
|
-
account: parameters.account ?? connectorClient?.account,
|
|
91
|
+
const options = simulateContractQueryOptions(config, {
|
|
92
|
+
...(parameters as any),
|
|
93
|
+
account: parameters.account ?? address,
|
|
110
94
|
chainId: parameters.chainId ?? chainId,
|
|
95
|
+
connector: parameters.connector ?? connector,
|
|
96
|
+
query: parameters.query,
|
|
111
97
|
})
|
|
112
|
-
|
|
113
|
-
abi && address && functionName && (query.enabled ?? true),
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
return useQuery({ ...query, ...options, enabled })
|
|
98
|
+
return useQuery(options) as any
|
|
117
99
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
2
|
import type {
|
|
4
3
|
Config,
|
|
5
4
|
GetStorageAtErrorType,
|
|
6
5
|
ResolvedRegister,
|
|
7
6
|
} from '@wagmi/core'
|
|
8
7
|
import type { Compute } from '@wagmi/core/internal'
|
|
9
|
-
import type { GetStorageAtQueryFnData } from '@wagmi/core/query'
|
|
10
8
|
import {
|
|
11
9
|
type GetStorageAtData,
|
|
12
10
|
type GetStorageAtOptions,
|
|
13
|
-
type GetStorageAtQueryKey,
|
|
14
11
|
getStorageAtQueryOptions,
|
|
15
12
|
} from '@wagmi/core/query'
|
|
16
|
-
import type { ConfigParameter
|
|
13
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
17
14
|
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
18
15
|
import { useChainId } from './useChainId.js'
|
|
19
16
|
import { useConfig } from './useConfig.js'
|
|
@@ -21,16 +18,7 @@ import { useConfig } from './useConfig.js'
|
|
|
21
18
|
export type UseStorageAtParameters<
|
|
22
19
|
config extends Config = Config,
|
|
23
20
|
selectData = GetStorageAtData,
|
|
24
|
-
> = Compute<
|
|
25
|
-
GetStorageAtOptions<config> &
|
|
26
|
-
ConfigParameter<config> &
|
|
27
|
-
QueryParameter<
|
|
28
|
-
GetStorageAtQueryFnData,
|
|
29
|
-
GetStorageAtErrorType,
|
|
30
|
-
selectData,
|
|
31
|
-
GetStorageAtQueryKey<config>
|
|
32
|
-
>
|
|
33
|
-
>
|
|
21
|
+
> = Compute<GetStorageAtOptions<config, selectData> & ConfigParameter<config>>
|
|
34
22
|
|
|
35
23
|
export type UseStorageAtReturnType<selectData = GetStorageAtData> =
|
|
36
24
|
UseQueryReturnType<selectData, GetStorageAtErrorType>
|
|
@@ -42,16 +30,12 @@ export function useStorageAt<
|
|
|
42
30
|
>(
|
|
43
31
|
parameters: UseStorageAtParameters<config, selectData> = {},
|
|
44
32
|
): UseStorageAtReturnType<selectData> {
|
|
45
|
-
const { address, slot, query = {} } = parameters
|
|
46
|
-
|
|
47
33
|
const config = useConfig(parameters)
|
|
48
34
|
const chainId = useChainId({ config })
|
|
49
|
-
|
|
50
35
|
const options = getStorageAtQueryOptions(config, {
|
|
51
36
|
...parameters,
|
|
52
37
|
chainId: parameters.chainId ?? chainId,
|
|
38
|
+
query: parameters.query,
|
|
53
39
|
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return useQuery({ ...query, ...options, enabled })
|
|
40
|
+
return useQuery(options)
|
|
57
41
|
}
|