@wagmi/core 2.3.0 → 2.5.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/getTransactionConfirmations.js +12 -0
- package/dist/esm/actions/getTransactionConfirmations.js.map +1 -0
- package/dist/esm/actions/prepareTransactionRequest.js +18 -0
- package/dist/esm/actions/prepareTransactionRequest.js.map +1 -0
- package/dist/esm/createConfig.js +14 -1
- package/dist/esm/createConfig.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 +2 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/query.js +2 -0
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/query/getTransactionConfirmations.js +26 -0
- package/dist/esm/query/getTransactionConfirmations.js.map +1 -0
- package/dist/esm/query/prepareTransactionRequest.js +26 -0
- package/dist/esm/query/prepareTransactionRequest.js.map +1 -0
- package/dist/esm/query/simulateContract.js +1 -0
- package/dist/esm/query/simulateContract.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/getTransactionConfirmations.d.ts +13 -0
- package/dist/types/actions/getTransactionConfirmations.d.ts.map +1 -0
- package/dist/types/actions/prepareTransactionRequest.d.ts +19 -0
- package/dist/types/actions/prepareTransactionRequest.d.ts.map +1 -0
- package/dist/types/createConfig.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 +2 -0
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts +2 -0
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/query/getTransactionConfirmations.d.ts +18 -0
- package/dist/types/query/getTransactionConfirmations.d.ts.map +1 -0
- package/dist/types/query/prepareTransactionRequest.d.ts +19 -0
- package/dist/types/query/prepareTransactionRequest.d.ts.map +1 -0
- package/dist/types/query/simulateContract.d.ts +1 -1
- package/dist/types/query/simulateContract.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/actions/getTransactionConfirmations.ts +49 -0
- package/src/actions/prepareTransactionRequest.ts +106 -0
- package/src/createConfig.ts +16 -1
- package/src/exports/actions.ts +14 -0
- package/src/exports/index.ts +14 -0
- package/src/exports/query.ts +18 -0
- package/src/query/getTransactionConfirmations.ts +78 -0
- package/src/query/prepareTransactionRequest.ts +83 -0
- package/src/query/simulateContract.ts +5 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type QueryOptions } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type GetTransactionConfirmationsErrorType,
|
|
5
|
+
type GetTransactionConfirmationsParameters,
|
|
6
|
+
type GetTransactionConfirmationsReturnType,
|
|
7
|
+
getTransactionConfirmations,
|
|
8
|
+
} from '../actions/getTransactionConfirmations.js'
|
|
9
|
+
import { type Config } from '../createConfig.js'
|
|
10
|
+
import { type ScopeKeyParameter } from '../types/properties.js'
|
|
11
|
+
import { type UnionPartial } from '../types/utils.js'
|
|
12
|
+
import { filterQueryOptions } from './utils.js'
|
|
13
|
+
|
|
14
|
+
export type GetTransactionConfirmationsOptions<
|
|
15
|
+
config extends Config,
|
|
16
|
+
chainId extends
|
|
17
|
+
| config['chains'][number]['id']
|
|
18
|
+
| undefined = config['chains'][number]['id'],
|
|
19
|
+
> = UnionPartial<GetTransactionConfirmationsParameters<config, chainId>> &
|
|
20
|
+
ScopeKeyParameter
|
|
21
|
+
|
|
22
|
+
export function getTransactionConfirmationsQueryOptions<
|
|
23
|
+
config extends Config,
|
|
24
|
+
chainId extends
|
|
25
|
+
| config['chains'][number]['id']
|
|
26
|
+
| undefined = config['chains'][number]['id'],
|
|
27
|
+
>(
|
|
28
|
+
config: config,
|
|
29
|
+
options: GetTransactionConfirmationsOptions<config, chainId> = {} as any,
|
|
30
|
+
) {
|
|
31
|
+
return {
|
|
32
|
+
async queryFn({ queryKey }) {
|
|
33
|
+
const {
|
|
34
|
+
hash,
|
|
35
|
+
transactionReceipt,
|
|
36
|
+
scopeKey: _,
|
|
37
|
+
...parameters
|
|
38
|
+
} = queryKey[1]
|
|
39
|
+
if (!hash && !transactionReceipt)
|
|
40
|
+
throw new Error('hash or transactionReceipt is required')
|
|
41
|
+
|
|
42
|
+
const confirmations = await getTransactionConfirmations(config, {
|
|
43
|
+
hash,
|
|
44
|
+
transactionReceipt,
|
|
45
|
+
...(parameters as any),
|
|
46
|
+
})
|
|
47
|
+
return confirmations ?? null
|
|
48
|
+
},
|
|
49
|
+
queryKey: getTransactionConfirmationsQueryKey(options),
|
|
50
|
+
} as const satisfies QueryOptions<
|
|
51
|
+
GetTransactionConfirmationsQueryFnData,
|
|
52
|
+
GetTransactionConfirmationsErrorType,
|
|
53
|
+
GetTransactionConfirmationsData,
|
|
54
|
+
GetTransactionConfirmationsQueryKey<config, chainId>
|
|
55
|
+
>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type GetTransactionConfirmationsQueryFnData =
|
|
59
|
+
GetTransactionConfirmationsReturnType
|
|
60
|
+
|
|
61
|
+
export type GetTransactionConfirmationsData =
|
|
62
|
+
GetTransactionConfirmationsQueryFnData
|
|
63
|
+
|
|
64
|
+
export function getTransactionConfirmationsQueryKey<
|
|
65
|
+
config extends Config,
|
|
66
|
+
chainId extends
|
|
67
|
+
| config['chains'][number]['id']
|
|
68
|
+
| undefined = config['chains'][number]['id'],
|
|
69
|
+
>(options: GetTransactionConfirmationsOptions<config, chainId> = {} as any) {
|
|
70
|
+
return ['transactionConfirmations', filterQueryOptions(options)] as const
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type GetTransactionConfirmationsQueryKey<
|
|
74
|
+
config extends Config,
|
|
75
|
+
chainId extends
|
|
76
|
+
| config['chains'][number]['id']
|
|
77
|
+
| undefined = config['chains'][number]['id'],
|
|
78
|
+
> = ReturnType<typeof getTransactionConfirmationsQueryKey<config, chainId>>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type QueryOptions } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import { type PrepareTransactionRequestParameterType as viem_PrepareTransactionRequestParameterType } from 'viem'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type PrepareTransactionRequestErrorType,
|
|
7
|
+
type PrepareTransactionRequestParameters,
|
|
8
|
+
type PrepareTransactionRequestReturnType,
|
|
9
|
+
prepareTransactionRequest,
|
|
10
|
+
} from '../actions/prepareTransactionRequest.js'
|
|
11
|
+
import { type Config } from '../createConfig.js'
|
|
12
|
+
import { type ScopeKeyParameter } from '../types/properties.js'
|
|
13
|
+
import { type UnionPartial } from '../types/utils.js'
|
|
14
|
+
import { filterQueryOptions } from './utils.js'
|
|
15
|
+
|
|
16
|
+
export type PrepareTransactionRequestOptions<
|
|
17
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
18
|
+
config extends Config,
|
|
19
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
20
|
+
> = UnionPartial<
|
|
21
|
+
PrepareTransactionRequestParameters<parameterType, config, chainId>
|
|
22
|
+
> &
|
|
23
|
+
ScopeKeyParameter
|
|
24
|
+
|
|
25
|
+
export function prepareTransactionRequestQueryOptions<
|
|
26
|
+
config extends Config,
|
|
27
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
28
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
29
|
+
>(
|
|
30
|
+
config: config,
|
|
31
|
+
options: PrepareTransactionRequestOptions<
|
|
32
|
+
parameterType,
|
|
33
|
+
config,
|
|
34
|
+
chainId
|
|
35
|
+
> = {} as any,
|
|
36
|
+
) {
|
|
37
|
+
return {
|
|
38
|
+
queryFn({ queryKey }) {
|
|
39
|
+
const { scopeKey: _, to, ...parameters } = queryKey[1]
|
|
40
|
+
if (!to) throw new Error('to is required')
|
|
41
|
+
return prepareTransactionRequest(config, {
|
|
42
|
+
to,
|
|
43
|
+
...(parameters as any),
|
|
44
|
+
}) as unknown as Promise<
|
|
45
|
+
PrepareTransactionRequestQueryFnData<parameterType, config, chainId>
|
|
46
|
+
>
|
|
47
|
+
},
|
|
48
|
+
queryKey: prepareTransactionRequestQueryKey(options),
|
|
49
|
+
} as const satisfies QueryOptions<
|
|
50
|
+
PrepareTransactionRequestQueryFnData<parameterType, config, chainId>,
|
|
51
|
+
PrepareTransactionRequestErrorType,
|
|
52
|
+
PrepareTransactionRequestData<parameterType, config, chainId>,
|
|
53
|
+
PrepareTransactionRequestQueryKey<parameterType, config, chainId>
|
|
54
|
+
>
|
|
55
|
+
}
|
|
56
|
+
export type PrepareTransactionRequestQueryFnData<
|
|
57
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
58
|
+
config extends Config,
|
|
59
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
60
|
+
> = PrepareTransactionRequestReturnType<parameterType, config, chainId>
|
|
61
|
+
|
|
62
|
+
export type PrepareTransactionRequestData<
|
|
63
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
64
|
+
config extends Config,
|
|
65
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
66
|
+
> = PrepareTransactionRequestQueryFnData<parameterType, config, chainId>
|
|
67
|
+
|
|
68
|
+
export function prepareTransactionRequestQueryKey<
|
|
69
|
+
config extends Config,
|
|
70
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
71
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
72
|
+
>(options: PrepareTransactionRequestOptions<parameterType, config, chainId>) {
|
|
73
|
+
const { connector: _c, ...rest } = options
|
|
74
|
+
return ['prepareTransactionRequest', filterQueryOptions(rest)] as const
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type PrepareTransactionRequestQueryKey<
|
|
78
|
+
parameterType extends viem_PrepareTransactionRequestParameterType,
|
|
79
|
+
config extends Config,
|
|
80
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
81
|
+
> = ReturnType<
|
|
82
|
+
typeof prepareTransactionRequestQueryKey<config, parameterType, chainId>
|
|
83
|
+
>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type QueryOptions } from '@tanstack/query-core'
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
type Abi,
|
|
4
|
+
type ContractFunctionArgs,
|
|
5
|
+
type ContractFunctionName,
|
|
6
|
+
} from 'viem'
|
|
3
7
|
|
|
4
8
|
import {
|
|
5
9
|
type SimulateContractErrorType,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.5.0'
|