@ensdomains/ensjs-query-core 0.0.1

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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +85 -0
  3. package/src/actions/public/getAbiRecord.ts +39 -0
  4. package/src/actions/public/getAddressRecord.ts +38 -0
  5. package/src/actions/public/getAvailable.ts +39 -0
  6. package/src/actions/public/getContentHashRecord.ts +41 -0
  7. package/src/actions/public/getCredentials.ts +39 -0
  8. package/src/actions/public/getExpiry.ts +42 -0
  9. package/src/actions/public/getName.ts +39 -0
  10. package/src/actions/public/getOwner.ts +45 -0
  11. package/src/actions/public/getPrice.ts +42 -0
  12. package/src/actions/public/getRecords.ts +69 -0
  13. package/src/actions/public/getResolver.ts +39 -0
  14. package/src/actions/public/getSupportedInterfaces.ts +53 -0
  15. package/src/actions/public/getTextRecord.ts +39 -0
  16. package/src/actions/public/getWrapperData.ts +39 -0
  17. package/src/actions/public/getWrapperName.ts +39 -0
  18. package/src/actions/public/resolveNameData.ts +46 -0
  19. package/src/actions/wallet/clearRecords.ts +69 -0
  20. package/src/actions/wallet/commitName.ts +62 -0
  21. package/src/actions/wallet/createSubname.ts +67 -0
  22. package/src/actions/wallet/deleteSubname.ts +64 -0
  23. package/src/actions/wallet/index.ts +84 -0
  24. package/src/actions/wallet/registerName.ts +62 -0
  25. package/src/actions/wallet/renewNames.ts +65 -0
  26. package/src/actions/wallet/setAbiRecord.ts +63 -0
  27. package/src/actions/wallet/setAddressRecord.ts +58 -0
  28. package/src/actions/wallet/setContentHashRecord.ts +63 -0
  29. package/src/actions/wallet/setPrimaryName.ts +67 -0
  30. package/src/actions/wallet/setRecords.ts +62 -0
  31. package/src/actions/wallet/setResolver.ts +62 -0
  32. package/src/actions/wallet/setTextRecord.ts +58 -0
  33. package/src/actions/wallet/transferName.ts +73 -0
  34. package/src/example.ts +39 -0
  35. package/src/query/public/getAbiRecord.ts +61 -0
  36. package/src/query/public/getAddressRecord.ts +61 -0
  37. package/src/query/public/getAvailable.ts +61 -0
  38. package/src/query/public/getContentHashRecord.ts +61 -0
  39. package/src/query/public/getCredentials.ts +61 -0
  40. package/src/query/public/getExpiry.ts +64 -0
  41. package/src/query/public/getName.ts +61 -0
  42. package/src/query/public/getOwner.ts +67 -0
  43. package/src/query/public/getPrice.ts +65 -0
  44. package/src/query/public/getRecords.ts +83 -0
  45. package/src/query/public/getResolver.ts +61 -0
  46. package/src/query/public/getSupportedInterfaces.ts +80 -0
  47. package/src/query/public/getTextRecord.ts +62 -0
  48. package/src/query/public/getWrapperData.ts +61 -0
  49. package/src/query/public/getWrapperName.ts +61 -0
  50. package/src/query/public/index.ts +134 -0
  51. package/src/query/utils.ts +26 -0
  52. package/src/query/wallet/clearRecords.ts +54 -0
  53. package/src/query/wallet/commitName.ts +54 -0
  54. package/src/query/wallet/createSubname.ts +57 -0
  55. package/src/query/wallet/deleteSubname.ts +54 -0
  56. package/src/query/wallet/index.ts +85 -0
  57. package/src/query/wallet/registerName.ts +54 -0
  58. package/src/query/wallet/renewNames.ts +57 -0
  59. package/src/query/wallet/setAbiRecord.ts +53 -0
  60. package/src/query/wallet/setAddressRecord.ts +50 -0
  61. package/src/query/wallet/setContentHashRecord.ts +50 -0
  62. package/src/query/wallet/setPrimaryName.ts +57 -0
  63. package/src/query/wallet/setRecords.ts +54 -0
  64. package/src/query/wallet/setResolver.ts +54 -0
  65. package/src/query/wallet/setTextRecord.ts +50 -0
  66. package/src/query/wallet/transferName.ts +66 -0
  67. package/src/utils/chain.ts +50 -0
  68. package/src/utils/getAction.ts +56 -0
@@ -0,0 +1,54 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import type { Chain } from 'viem'
13
+ import {
14
+ type RegisterNameErrorType,
15
+ type RegisterNameParameters,
16
+ type RegisterNameReturnType,
17
+ registerName,
18
+ } from '../../actions/wallet/registerName.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type RegisterNameOptions<config extends Config> = Compute<
23
+ ExactPartial<RegisterNameParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function registerNameMutationOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<chains, 'ensEthRegistrarController'>,
30
+ options: RegisterNameOptions<ExcludeTE<typeof config>>,
31
+ ) {
32
+ ASSERT_NO_TYPE_ERROR(config)
33
+
34
+ return {
35
+ mutationFn: async (variables: RegisterNameParameters<typeof config>) => {
36
+ return registerName(config, variables)
37
+ },
38
+ mutationKey: registerNameMutationKey(options),
39
+ } as const satisfies MutationOptions<
40
+ RegisterNameReturnType,
41
+ RegisterNameErrorType,
42
+ RegisterNameParameters<typeof config>
43
+ >
44
+ }
45
+
46
+ export function registerNameMutationKey<config extends Config>(
47
+ options: RegisterNameOptions<config>,
48
+ ) {
49
+ return ['ensjs_registerName', filterQueryOptions(options)] as const
50
+ }
51
+
52
+ export type RegisterNameMutationKey<config extends Config> = ReturnType<
53
+ typeof registerNameMutationKey<config>
54
+ >
@@ -0,0 +1,57 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import type { Chain } from 'viem'
13
+ import {
14
+ type RenewNamesErrorType,
15
+ type RenewNamesParameters,
16
+ type RenewNamesReturnType,
17
+ renewNames,
18
+ } from '../../actions/wallet/renewNames.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type RenewNamesOptions<config extends Config> = Compute<
23
+ ExactPartial<RenewNamesParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function renewNamesMutationOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<
30
+ chains,
31
+ 'ensEthRegistrarController' | 'ensBulkRenewal'
32
+ >,
33
+ options: RenewNamesOptions<ExcludeTE<typeof config>>,
34
+ ) {
35
+ ASSERT_NO_TYPE_ERROR(config)
36
+
37
+ return {
38
+ mutationFn: async (variables: RenewNamesParameters<typeof config>) => {
39
+ return renewNames(config, variables)
40
+ },
41
+ mutationKey: renewNamesMutationKey(options),
42
+ } as const satisfies MutationOptions<
43
+ RenewNamesReturnType,
44
+ RenewNamesErrorType,
45
+ RenewNamesParameters<typeof config>
46
+ >
47
+ }
48
+
49
+ export function renewNamesMutationKey<config extends Config>(
50
+ options: RenewNamesOptions<config>,
51
+ ) {
52
+ return ['ensjs_renewNames', filterQueryOptions(options)] as const
53
+ }
54
+
55
+ export type RenewNamesMutationKey<config extends Config> = ReturnType<
56
+ typeof renewNamesMutationKey<config>
57
+ >
@@ -0,0 +1,53 @@
1
+ import { ASSERT_NO_TYPE_ERROR } from '@ensdomains/ensjs/internal'
2
+ import type { AbiEncodeAs } from '@ensdomains/ensjs/utils'
3
+ import type { MutationOptions } from '@tanstack/query-core'
4
+ import type { Config } from '@wagmi/core'
5
+ import type {
6
+ Compute,
7
+ ExactPartial,
8
+ ScopeKeyParameter,
9
+ } from '@wagmi/core/internal'
10
+ import {
11
+ type SetAbiRecordErrorType,
12
+ type SetAbiRecordParameters,
13
+ type SetAbiRecordReturnType,
14
+ setAbiRecord,
15
+ } from '../../actions/wallet/setAbiRecord.js'
16
+ import { filterQueryOptions } from '../utils.js'
17
+
18
+ export type SetAbiRecordOptions<
19
+ encodeAs extends AbiEncodeAs,
20
+ config extends Config,
21
+ > = Compute<
22
+ ExactPartial<SetAbiRecordParameters<encodeAs, config>> & ScopeKeyParameter
23
+ >
24
+
25
+ export function setAbiRecordMutationOptions<
26
+ encodeAs extends AbiEncodeAs,
27
+ config extends Config,
28
+ >(config: config, options: SetAbiRecordOptions<encodeAs, config>) {
29
+ ASSERT_NO_TYPE_ERROR(config)
30
+
31
+ return {
32
+ mutationFn: async (variables: SetAbiRecordParameters<encodeAs, config>) => {
33
+ return setAbiRecord(config, variables)
34
+ },
35
+ mutationKey: setAbiRecordMutationKey(options),
36
+ } as const satisfies MutationOptions<
37
+ SetAbiRecordReturnType,
38
+ SetAbiRecordErrorType,
39
+ SetAbiRecordParameters<encodeAs, config>
40
+ >
41
+ }
42
+
43
+ export function setAbiRecordMutationKey<
44
+ encodeAs extends AbiEncodeAs,
45
+ config extends Config,
46
+ >(options: SetAbiRecordOptions<encodeAs, config>) {
47
+ return ['ensjs_setAbiRecord', filterQueryOptions(options)] as const
48
+ }
49
+
50
+ export type SetAbiRecordMutationKey<
51
+ encodeAs extends AbiEncodeAs,
52
+ config extends Config,
53
+ > = ReturnType<typeof setAbiRecordMutationKey<encodeAs, config>>
@@ -0,0 +1,50 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import {
13
+ type SetAddressRecordErrorType,
14
+ type SetAddressRecordParameters,
15
+ type SetAddressRecordReturnType,
16
+ setAddressRecord,
17
+ } from '../../actions/wallet/setAddressRecord.js'
18
+ import { filterQueryOptions } from '../utils.js'
19
+
20
+ export type SetAddressRecordOptions<config extends Config> = Compute<
21
+ ExactPartial<SetAddressRecordParameters<config>> & ScopeKeyParameter
22
+ >
23
+
24
+ export function setAddressRecordMutationOptions<config extends Config>(
25
+ config: config,
26
+ options: SetAddressRecordOptions<ExcludeTE<typeof config>>,
27
+ ) {
28
+ ASSERT_NO_TYPE_ERROR(config)
29
+
30
+ return {
31
+ mutationFn: async (variables: SetAddressRecordParameters<config>) => {
32
+ return setAddressRecord(config, variables)
33
+ },
34
+ mutationKey: setAddressRecordMutationKey(options),
35
+ } as const satisfies MutationOptions<
36
+ SetAddressRecordReturnType,
37
+ SetAddressRecordErrorType,
38
+ SetAddressRecordParameters<config>
39
+ >
40
+ }
41
+
42
+ export function setAddressRecordMutationKey<config extends Config>(
43
+ options: SetAddressRecordOptions<config>,
44
+ ) {
45
+ return ['ensjs_setAddressRecord', filterQueryOptions(options)] as const
46
+ }
47
+
48
+ export type SetAddressRecordMutationKey<config extends Config> = ReturnType<
49
+ typeof setAddressRecordMutationKey<config>
50
+ >
@@ -0,0 +1,50 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import {
13
+ type SetContentHashRecordErrorType,
14
+ type SetContentHashRecordParameters,
15
+ type SetContentHashRecordReturnType,
16
+ setContentHashRecord,
17
+ } from '../../actions/wallet/setContentHashRecord.js'
18
+ import { filterQueryOptions } from '../utils.js'
19
+
20
+ export type SetContentHashRecordOptions<config extends Config> = Compute<
21
+ ExactPartial<SetContentHashRecordParameters<config>> & ScopeKeyParameter
22
+ >
23
+
24
+ export function setContentHashRecordMutationOptions<config extends Config>(
25
+ config: config,
26
+ options: SetContentHashRecordOptions<ExcludeTE<typeof config>>,
27
+ ) {
28
+ ASSERT_NO_TYPE_ERROR(config)
29
+
30
+ return {
31
+ mutationFn: async (variables: SetContentHashRecordParameters<config>) => {
32
+ return setContentHashRecord(config, variables)
33
+ },
34
+ mutationKey: setContentHashRecordMutationKey(options),
35
+ } as const satisfies MutationOptions<
36
+ SetContentHashRecordReturnType,
37
+ SetContentHashRecordErrorType,
38
+ SetContentHashRecordParameters<config>
39
+ >
40
+ }
41
+
42
+ export function setContentHashRecordMutationKey<config extends Config>(
43
+ options: SetContentHashRecordOptions<config>,
44
+ ) {
45
+ return ['ensjs_setContentHashRecord', filterQueryOptions(options)] as const
46
+ }
47
+
48
+ export type SetContentHashRecordMutationKey<config extends Config> = ReturnType<
49
+ typeof setContentHashRecordMutationKey<config>
50
+ >
@@ -0,0 +1,57 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import type { Chain } from 'viem'
13
+ import {
14
+ type SetPrimaryNameErrorType,
15
+ type SetPrimaryNameParameters,
16
+ type SetPrimaryNameReturnType,
17
+ setPrimaryName,
18
+ } from '../../actions/wallet/setPrimaryName.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type SetPrimaryNameOptions<config extends Config> = Compute<
23
+ ExactPartial<SetPrimaryNameParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function setPrimaryNameMutationOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<
30
+ chains,
31
+ 'ensPublicResolver' | 'ensReverseRegistrar'
32
+ >,
33
+ options: SetPrimaryNameOptions<ExcludeTE<typeof config>>,
34
+ ) {
35
+ ASSERT_NO_TYPE_ERROR(config)
36
+
37
+ return {
38
+ mutationFn: async (variables: SetPrimaryNameParameters<typeof config>) => {
39
+ return setPrimaryName(config, variables)
40
+ },
41
+ mutationKey: setPrimaryNameMutationKey(options),
42
+ } as const satisfies MutationOptions<
43
+ SetPrimaryNameReturnType,
44
+ SetPrimaryNameErrorType,
45
+ SetPrimaryNameParameters<typeof config>
46
+ >
47
+ }
48
+
49
+ export function setPrimaryNameMutationKey<config extends Config>(
50
+ options: SetPrimaryNameOptions<config>,
51
+ ) {
52
+ return ['ensjs_setPrimaryName', filterQueryOptions(options)] as const
53
+ }
54
+
55
+ export type SetPrimaryNameMutationKey<config extends Config> = ReturnType<
56
+ typeof setPrimaryNameMutationKey<config>
57
+ >
@@ -0,0 +1,54 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import type { Chain } from 'viem'
13
+ import {
14
+ type SetRecordsErrorType,
15
+ type SetRecordsParameters,
16
+ type SetRecordsReturnType,
17
+ setRecords,
18
+ } from '../../actions/wallet/setRecords.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type SetRecordsOptions<config extends Config> = Compute<
23
+ ExactPartial<SetRecordsParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function setRecordsMutationOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<chains, 'ensPublicResolver'>,
30
+ options: SetRecordsOptions<ExcludeTE<typeof config>>,
31
+ ) {
32
+ ASSERT_NO_TYPE_ERROR(config)
33
+
34
+ return {
35
+ mutationFn: async (variables: SetRecordsParameters<typeof config>) => {
36
+ return setRecords(config, variables)
37
+ },
38
+ mutationKey: setRecordsMutationKey(options),
39
+ } as const satisfies MutationOptions<
40
+ SetRecordsReturnType,
41
+ SetRecordsErrorType,
42
+ SetRecordsParameters<typeof config>
43
+ >
44
+ }
45
+
46
+ export function setRecordsMutationKey<config extends Config>(
47
+ options: SetRecordsOptions<config>,
48
+ ) {
49
+ return ['ensjs_setRecords', filterQueryOptions(options)] as const
50
+ }
51
+
52
+ export type SetRecordsMutationKey<config extends Config> = ReturnType<
53
+ typeof setRecordsMutationKey<config>
54
+ >
@@ -0,0 +1,54 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import type { Chain } from 'viem'
13
+ import {
14
+ type SetResolverErrorType,
15
+ type SetResolverParameters,
16
+ type SetResolverReturnType,
17
+ setResolver,
18
+ } from '../../actions/wallet/setResolver.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type SetResolverOptions<config extends Config> = Compute<
23
+ ExactPartial<SetResolverParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function setResolverMutationOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<chains, 'ensRegistry' | 'ensNameWrapper'>,
30
+ options: SetResolverOptions<ExcludeTE<typeof config>>,
31
+ ) {
32
+ ASSERT_NO_TYPE_ERROR(config)
33
+
34
+ return {
35
+ mutationFn: async (variables: SetResolverParameters<typeof config>) => {
36
+ return setResolver(config, variables)
37
+ },
38
+ mutationKey: setResolverMutationKey(options),
39
+ } as const satisfies MutationOptions<
40
+ SetResolverReturnType,
41
+ SetResolverErrorType,
42
+ SetResolverParameters<typeof config>
43
+ >
44
+ }
45
+
46
+ export function setResolverMutationKey<config extends Config>(
47
+ options: SetResolverOptions<config>,
48
+ ) {
49
+ return ['ensjs_setResolver', filterQueryOptions(options)] as const
50
+ }
51
+
52
+ export type SetResolverMutationKey<config extends Config> = ReturnType<
53
+ typeof setResolverMutationKey<config>
54
+ >
@@ -0,0 +1,50 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { MutationOptions } from '@tanstack/query-core'
6
+ import type { Config } from '@wagmi/core'
7
+ import type {
8
+ Compute,
9
+ ExactPartial,
10
+ ScopeKeyParameter,
11
+ } from '@wagmi/core/internal'
12
+ import {
13
+ type SetTextRecordErrorType,
14
+ type SetTextRecordParameters,
15
+ type SetTextRecordReturnType,
16
+ setTextRecord,
17
+ } from '../../actions/wallet/setTextRecord.js'
18
+ import { filterQueryOptions } from '../utils.js'
19
+
20
+ export type SetTextRecordOptions<config extends Config> = Compute<
21
+ ExactPartial<SetTextRecordParameters<config>> & ScopeKeyParameter
22
+ >
23
+
24
+ export function setTextRecordMutationOptions<config extends Config>(
25
+ config: config,
26
+ options: SetTextRecordOptions<ExcludeTE<typeof config>>,
27
+ ) {
28
+ ASSERT_NO_TYPE_ERROR(config)
29
+
30
+ return {
31
+ mutationFn: async (variables: SetTextRecordParameters<config>) => {
32
+ return setTextRecord(config, variables)
33
+ },
34
+ mutationKey: setTextRecordMutationKey(options),
35
+ } as const satisfies MutationOptions<
36
+ SetTextRecordReturnType,
37
+ SetTextRecordErrorType,
38
+ SetTextRecordParameters<config>
39
+ >
40
+ }
41
+
42
+ export function setTextRecordMutationKey<config extends Config>(
43
+ options: SetTextRecordOptions<config>,
44
+ ) {
45
+ return ['ensjs_setTextRecord', filterQueryOptions(options)] as const
46
+ }
47
+
48
+ export type SetTextRecordMutationKey<config extends Config> = ReturnType<
49
+ typeof setTextRecordMutationKey<config>
50
+ >
@@ -0,0 +1,66 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { TransferNameSupportedContract } from '@ensdomains/ensjs/wallet'
6
+ import type { MutationOptions } from '@tanstack/query-core'
7
+ import type { Config } from '@wagmi/core'
8
+ import type {
9
+ Compute,
10
+ ExactPartial,
11
+ ScopeKeyParameter,
12
+ } from '@wagmi/core/internal'
13
+ import type { Chain } from 'viem/chains'
14
+ import {
15
+ type TransferNameErrorType,
16
+ type TransferNameParameters,
17
+ type TransferNameReturnType,
18
+ transferName,
19
+ } from '../../actions/wallet/transferName.js'
20
+ import type { RequireConfigContracts } from '../../utils/chain.js'
21
+ import { filterQueryOptions } from '../utils.js'
22
+
23
+ export type TransferNameOptions<
24
+ contract extends TransferNameSupportedContract,
25
+ config extends Config,
26
+ > = Compute<
27
+ ExactPartial<TransferNameParameters<contract, config>> & ScopeKeyParameter
28
+ >
29
+
30
+ export function transferNameMutationOptions<
31
+ contract extends TransferNameSupportedContract,
32
+ chains extends readonly [Chain, ...Chain[]],
33
+ >(
34
+ config: RequireConfigContracts<
35
+ chains,
36
+ 'ensRegistry' | 'ensNameWrapper' | 'ensBaseRegistrarImplementation'
37
+ >,
38
+ options: TransferNameOptions<contract, ExcludeTE<typeof config>>,
39
+ ) {
40
+ ASSERT_NO_TYPE_ERROR(config)
41
+
42
+ return {
43
+ mutationFn: async (
44
+ variables: TransferNameParameters<contract, typeof config>,
45
+ ) => {
46
+ return transferName(config, variables)
47
+ },
48
+ mutationKey: transferNameMutationKey(options),
49
+ } as const satisfies MutationOptions<
50
+ TransferNameReturnType,
51
+ TransferNameErrorType,
52
+ TransferNameParameters<contract, typeof config>
53
+ >
54
+ }
55
+
56
+ export function transferNameMutationKey<
57
+ contract extends TransferNameSupportedContract,
58
+ config extends Config,
59
+ >(options: TransferNameOptions<contract, config>) {
60
+ return ['ensjs_transferName', filterQueryOptions(options)] as const
61
+ }
62
+
63
+ export type TransferNameMutationKey<
64
+ contract extends TransferNameSupportedContract,
65
+ config extends Config,
66
+ > = ReturnType<typeof transferNameMutationKey<contract, config>>
@@ -0,0 +1,50 @@
1
+ import type { SupportedL1Contract } from '@ensdomains/ensjs/chain'
2
+ import type {
3
+ StringConcatenationOrder,
4
+ // biome-ignore lint/suspicious/noShadowRestrictedNames: import
5
+ TypeError,
6
+ } from '@ensdomains/ensjs/internal'
7
+ import type { Config, CreateConnectorFn, Transport } from '@wagmi/core'
8
+ import type { ChainContract } from 'viem'
9
+ import type { Chain } from 'viem/chains'
10
+
11
+ export type BaseChainContracts = {
12
+ [key in keyof NonNullable<Chain['contracts']> as string extends key
13
+ ? never
14
+ : key]: NonNullable<Chain['contracts']>[key]
15
+ }
16
+
17
+ type SuggestedContracts =
18
+ | SupportedL1Contract
19
+ | keyof BaseChainContracts
20
+ | (string & {})
21
+
22
+ export type RequireConfigContracts<
23
+ chains extends readonly [Chain, ...Chain[]],
24
+ contracts extends SuggestedContracts,
25
+ transports extends Record<chains[number]['id'], Transport> = Record<
26
+ chains[number]['id'],
27
+ Transport
28
+ >,
29
+ connectorFns extends
30
+ readonly CreateConnectorFn[] = readonly CreateConnectorFn[],
31
+ > = chains[number] extends Chain & {
32
+ contracts: {
33
+ [key in contracts]: ChainContract
34
+ }
35
+ }
36
+ ? Config<chains, transports, connectorFns>
37
+ : TypeError<`One of the "${chains[number]['name']}" chains are missing a required contract: ${StringConcatenationOrder<contracts, ', '>}`>
38
+
39
+ export type RequireConfigContracts2<
40
+ config extends Config,
41
+ contracts extends SupportedL1Contract,
42
+ > = config extends Config<infer chains, infer transports, infer connectorFns>
43
+ ? chains[number] extends Chain & {
44
+ contracts: {
45
+ [key in contracts]: ChainContract
46
+ }
47
+ }
48
+ ? Config<chains, transports, connectorFns>
49
+ : TypeError<`One of the "${chains[number]['name']}" chains are missing a required contract: ${StringConcatenationOrder<contracts, ', '>}`>
50
+ : TypeError<`Invalid config`>
@@ -0,0 +1,56 @@
1
+ // Source: https://github.com/wevm/wagmi/blob/main/packages/core/src/utils/getAction.ts
2
+
3
+ import type { EnsPublicActions, EnsWalletActions } from '@ensdomains/ensjs'
4
+ import type {
5
+ ChainWithContracts,
6
+ SupportedL1Contract,
7
+ } from '@ensdomains/ensjs/chain'
8
+ import type {
9
+ Account,
10
+ Chain,
11
+ Client,
12
+ // PublicActions,
13
+ RpcSchema,
14
+ Transport,
15
+ // WalletActions,
16
+ } from 'viem'
17
+
18
+ /**
19
+ * Retrieves and returns an action from the client (if exists), and falls
20
+ * back to the tree-shakable action.
21
+ *
22
+ * Useful for extracting overridden actions from a client (ie. if a consumer
23
+ * wants to override the `sendTransaction` implementation).
24
+ */
25
+ export function getAction<
26
+ transport extends Transport,
27
+ chain extends Chain,
28
+ account extends Account | undefined,
29
+ rpcSchema extends RpcSchema | undefined,
30
+ extended extends { [key: string]: unknown },
31
+ client extends Client<transport, chain, account, rpcSchema, extended>,
32
+ parameters,
33
+ returnType,
34
+ >(
35
+ client: client,
36
+ actionFn: (_: any, parameters: parameters) => returnType,
37
+ // Some minifiers drop `Function.prototype.name`, or replace it with short letters,
38
+ // meaning that `actionFn.name` will not always work. For that case, the consumer
39
+ // needs to pass the name explicitly.
40
+ name:
41
+ | keyof EnsPublicActions
42
+ | keyof EnsWalletActions<
43
+ ChainWithContracts<SupportedL1Contract>,
44
+ NonNullable<account>
45
+ >,
46
+ ): (parameters: parameters) => returnType {
47
+ const action_implicit = client[actionFn.name]
48
+ if (typeof action_implicit === 'function')
49
+ return action_implicit as (params: parameters) => returnType
50
+
51
+ const action_explicit = client[name]
52
+ if (typeof action_explicit === 'function')
53
+ return action_explicit as (params: parameters) => returnType
54
+
55
+ return (params) => actionFn(client, params)
56
+ }