@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,63 @@
1
+ import type { AbiEncodeAs } from '@ensdomains/ensjs/utils'
2
+ import {
3
+ type SetAbiRecordErrorType as ensjs_SetAbiRecordErrorType,
4
+ type SetAbiRecordParameters as ensjs_SetAbiRecordParameters,
5
+ type SetAbiRecordReturnType as ensjs_SetAbiRecordReturnType,
6
+ setAbiRecord as ensjs_setAbiRecord,
7
+ } from '@ensdomains/ensjs/wallet'
8
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
9
+ import type {
10
+ ChainIdParameter,
11
+ Compute,
12
+ ConnectorParameter,
13
+ } from '@wagmi/core/internal'
14
+ import type { Account, Chain, Client } from 'viem'
15
+ import { getAction } from '../../utils/getAction.js'
16
+
17
+ export type SetAbiRecordParameters<
18
+ encodeAs extends AbiEncodeAs = AbiEncodeAs,
19
+ config extends Config = Config,
20
+ chainId extends
21
+ config['chains'][number]['id'] = config['chains'][number]['id'],
22
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
23
+ > = {
24
+ [key in keyof chains]: Compute<
25
+ Omit<
26
+ ensjs_SetAbiRecordParameters<encodeAs, chains[key], Account, chains[key]>,
27
+ 'chain'
28
+ > &
29
+ ChainIdParameter<config, chainId> &
30
+ ConnectorParameter
31
+ >
32
+ }[number]
33
+
34
+ export type SetAbiRecordReturnType = ensjs_SetAbiRecordReturnType
35
+
36
+ export type SetAbiRecordErrorType = ensjs_SetAbiRecordErrorType
37
+
38
+ export async function setAbiRecord<
39
+ encodeAs extends AbiEncodeAs,
40
+ config extends Config,
41
+ >(
42
+ config: config,
43
+ parameters: SetAbiRecordParameters<encodeAs, config>,
44
+ ): Promise<SetAbiRecordReturnType> {
45
+ const { account, chainId, connector, ...rest } = parameters
46
+
47
+ let client: Client<any, Chain>
48
+ if (typeof account === 'object' && account?.type === 'local')
49
+ client = config.getClient({ chainId })
50
+ else
51
+ client = await getConnectorClient(config, {
52
+ account: account ?? undefined,
53
+ chainId,
54
+ connector,
55
+ })
56
+
57
+ const action = getAction(client, ensjs_setAbiRecord, 'setAbiRecord')
58
+ return await action({
59
+ ...(rest as any),
60
+ ...(account ? { account } : {}),
61
+ chain: chainId ? { id: chainId } : null,
62
+ })
63
+ }
@@ -0,0 +1,58 @@
1
+ import {
2
+ type SetAddressRecordErrorType as ensjs_SetAddressRecordErrorType,
3
+ type SetAddressRecordParameters as ensjs_SetAddressRecordParameters,
4
+ type SetAddressRecordReturnType as ensjs_SetAddressRecordReturnType,
5
+ setAddressRecord as ensjs_setAddressRecord,
6
+ } from '@ensdomains/ensjs/wallet'
7
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
8
+ import type {
9
+ ChainIdParameter,
10
+ Compute,
11
+ ConnectorParameter,
12
+ } from '@wagmi/core/internal'
13
+ import type { Account, Chain, Client } from 'viem'
14
+ import { getAction } from '../../utils/getAction.js'
15
+
16
+ export type SetAddressRecordParameters<
17
+ config extends Config = Config,
18
+ chainId extends
19
+ config['chains'][number]['id'] = config['chains'][number]['id'],
20
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
21
+ > = {
22
+ [key in keyof chains]: Compute<
23
+ Omit<
24
+ ensjs_SetAddressRecordParameters<chains[key], Account, chains[key]>,
25
+ 'chain'
26
+ > &
27
+ ChainIdParameter<config, chainId> &
28
+ ConnectorParameter
29
+ >
30
+ }[number]
31
+
32
+ export type SetAddressRecordReturnType = ensjs_SetAddressRecordReturnType
33
+
34
+ export type SetAddressRecordErrorType = ensjs_SetAddressRecordErrorType
35
+
36
+ export async function setAddressRecord<config extends Config>(
37
+ config: config,
38
+ parameters: SetAddressRecordParameters<config>,
39
+ ): Promise<SetAddressRecordReturnType> {
40
+ const { account, chainId, connector, ...rest } = parameters
41
+
42
+ let client: Client<any, Chain>
43
+ if (typeof account === 'object' && account?.type === 'local')
44
+ client = config.getClient({ chainId })
45
+ else
46
+ client = await getConnectorClient(config, {
47
+ account: account ?? undefined,
48
+ chainId,
49
+ connector,
50
+ })
51
+
52
+ const action = getAction(client, ensjs_setAddressRecord, 'setAddressRecord')
53
+ return await action({
54
+ ...(rest as any),
55
+ ...(account ? { account } : {}),
56
+ chain: chainId ? { id: chainId } : null,
57
+ })
58
+ }
@@ -0,0 +1,63 @@
1
+ import {
2
+ type SetContentHashRecordErrorType as ensjs_SetContentHashRecordErrorType,
3
+ type SetContentHashRecordParameters as ensjs_SetContentHashRecordParameters,
4
+ type SetContentHashRecordReturnType as ensjs_SetContentHashRecordReturnType,
5
+ setContentHashRecord as ensjs_setContentHashRecord,
6
+ } from '@ensdomains/ensjs/wallet'
7
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
8
+ import type {
9
+ ChainIdParameter,
10
+ Compute,
11
+ ConnectorParameter,
12
+ } from '@wagmi/core/internal'
13
+ import type { Account, Chain, Client } from 'viem'
14
+ import { getAction } from '../../utils/getAction.js'
15
+
16
+ export type SetContentHashRecordParameters<
17
+ config extends Config = Config,
18
+ chainId extends
19
+ config['chains'][number]['id'] = config['chains'][number]['id'],
20
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
21
+ > = {
22
+ [key in keyof chains]: Compute<
23
+ Omit<
24
+ ensjs_SetContentHashRecordParameters<chains[key], Account, any>,
25
+ 'chain'
26
+ > &
27
+ ChainIdParameter<config, chainId> &
28
+ ConnectorParameter
29
+ >
30
+ }[number]
31
+
32
+ export type SetContentHashRecordReturnType =
33
+ ensjs_SetContentHashRecordReturnType
34
+
35
+ export type SetContentHashRecordErrorType = ensjs_SetContentHashRecordErrorType
36
+
37
+ export async function setContentHashRecord<config extends Config>(
38
+ config: config,
39
+ parameters: SetContentHashRecordParameters<config>,
40
+ ): Promise<SetContentHashRecordReturnType> {
41
+ const { account, chainId, connector, ...rest } = parameters
42
+
43
+ let client: Client<any, Chain>
44
+ if (typeof account === 'object' && account?.type === 'local')
45
+ client = config.getClient({ chainId })
46
+ else
47
+ client = await getConnectorClient(config, {
48
+ account: account ?? undefined,
49
+ chainId,
50
+ connector,
51
+ })
52
+
53
+ const action = getAction(
54
+ client,
55
+ ensjs_setContentHashRecord,
56
+ 'setContentHashRecord',
57
+ )
58
+ return await action({
59
+ ...(rest as any),
60
+ ...(account ? { account } : {}),
61
+ chain: chainId ? { id: chainId } : null,
62
+ })
63
+ }
@@ -0,0 +1,67 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import {
6
+ type SetPrimaryNameErrorType as ensjs_SetPrimaryNameErrorType,
7
+ type SetPrimaryNameParameters as ensjs_SetPrimaryNameParameters,
8
+ type SetPrimaryNameReturnType as ensjs_SetPrimaryNameReturnType,
9
+ setPrimaryName as ensjs_setPrimaryName,
10
+ } from '@ensdomains/ensjs/wallet'
11
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
12
+ import type {
13
+ ChainIdParameter,
14
+ Compute,
15
+ ConnectorParameter,
16
+ } from '@wagmi/core/internal'
17
+ import type { Account, Chain, Client } from 'viem'
18
+ import type { RequireConfigContracts } from '../../utils/chain.js'
19
+ import { getAction } from '../../utils/getAction.js'
20
+
21
+ export type SetPrimaryNameParameters<
22
+ config extends Config = Config,
23
+ chainId extends
24
+ config['chains'][number]['id'] = config['chains'][number]['id'],
25
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
26
+ > = {
27
+ [key in keyof chains]: Compute<
28
+ Omit<ensjs_SetPrimaryNameParameters<chains[key], Account, any>, 'chain'> &
29
+ ChainIdParameter<config, chainId> &
30
+ ConnectorParameter
31
+ >
32
+ }[number]
33
+
34
+ export type SetPrimaryNameReturnType = ensjs_SetPrimaryNameReturnType
35
+
36
+ export type SetPrimaryNameErrorType = ensjs_SetPrimaryNameErrorType
37
+
38
+ export async function setPrimaryName<
39
+ chains extends readonly [Chain, ...Chain[]],
40
+ >(
41
+ config: RequireConfigContracts<
42
+ chains,
43
+ 'ensPublicResolver' | 'ensReverseRegistrar'
44
+ >,
45
+ parameters: SetPrimaryNameParameters<ExcludeTE<typeof config>>,
46
+ ): Promise<SetPrimaryNameReturnType> {
47
+ ASSERT_NO_TYPE_ERROR(config)
48
+
49
+ const { account, chainId, connector, ...rest } = parameters
50
+
51
+ let client: Client<any, Chain>
52
+ if (typeof account === 'object' && account?.type === 'local')
53
+ client = config.getClient({ chainId })
54
+ else
55
+ client = await getConnectorClient(config, {
56
+ account: account ?? undefined,
57
+ chainId,
58
+ connector,
59
+ })
60
+
61
+ const action = getAction(client, ensjs_setPrimaryName, 'setPrimaryName')
62
+ return await action({
63
+ ...(rest as any),
64
+ ...(account ? { account } : {}),
65
+ chain: chainId ? { id: chainId } : null,
66
+ })
67
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import {
6
+ type SetRecordsErrorType as ensjs_SetRecordsErrorType,
7
+ type SetRecordsParameters as ensjs_SetRecordsParameters,
8
+ type SetRecordsReturnType as ensjs_SetRecordsReturnType,
9
+ setRecords as ensjs_setRecords,
10
+ } from '@ensdomains/ensjs/wallet'
11
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
12
+ import type {
13
+ ChainIdParameter,
14
+ Compute,
15
+ ConnectorParameter,
16
+ } from '@wagmi/core/internal'
17
+ import type { Account, Chain, Client } from 'viem'
18
+ import type { RequireConfigContracts } from '../../utils/chain.js'
19
+ import { getAction } from '../../utils/getAction.js'
20
+
21
+ export type SetRecordsParameters<
22
+ config extends Config = Config,
23
+ chainId extends
24
+ config['chains'][number]['id'] = config['chains'][number]['id'],
25
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
26
+ > = {
27
+ [key in keyof chains]: Compute<
28
+ Omit<ensjs_SetRecordsParameters<chains[key], Account, any>, 'chain'> &
29
+ ChainIdParameter<config, chainId> &
30
+ ConnectorParameter
31
+ >
32
+ }[number]
33
+
34
+ export type SetRecordsReturnType = ensjs_SetRecordsReturnType
35
+
36
+ export type SetRecordsErrorType = ensjs_SetRecordsErrorType
37
+
38
+ export async function setRecords<chains extends readonly [Chain, ...Chain[]]>(
39
+ config: RequireConfigContracts<chains, 'ensPublicResolver'>,
40
+ parameters: SetRecordsParameters<ExcludeTE<typeof config>>,
41
+ ): Promise<SetRecordsReturnType> {
42
+ ASSERT_NO_TYPE_ERROR(config)
43
+
44
+ const { account, chainId, connector, ...rest } = parameters
45
+
46
+ let client: Client<any, Chain>
47
+ if (typeof account === 'object' && account?.type === 'local')
48
+ client = config.getClient({ chainId })
49
+ else
50
+ client = await getConnectorClient(config, {
51
+ account: account ?? undefined,
52
+ chainId,
53
+ connector,
54
+ })
55
+
56
+ const action = getAction(client, ensjs_setRecords, 'setRecords')
57
+ return await action({
58
+ ...(rest as any),
59
+ ...(account ? { account } : {}),
60
+ chain: chainId ? { id: chainId } : null,
61
+ })
62
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import {
6
+ type SetResolverErrorType as ensjs_SetResolverErrorType,
7
+ type SetResolverParameters as ensjs_SetResolverParameters,
8
+ type SetResolverReturnType as ensjs_SetResolverReturnType,
9
+ setResolver as ensjs_setResolver,
10
+ } from '@ensdomains/ensjs/wallet'
11
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
12
+ import type {
13
+ ChainIdParameter,
14
+ Compute,
15
+ ConnectorParameter,
16
+ } from '@wagmi/core/internal'
17
+ import type { Account, Chain, Client } from 'viem'
18
+ import type { RequireConfigContracts } from '../../utils/chain.js'
19
+ import { getAction } from '../../utils/getAction.js'
20
+
21
+ export type SetResolverParameters<
22
+ config extends Config = Config,
23
+ chainId extends
24
+ config['chains'][number]['id'] = config['chains'][number]['id'],
25
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
26
+ > = {
27
+ [key in keyof chains]: Compute<
28
+ Omit<ensjs_SetResolverParameters<chains[key], Account, any>, 'chain'> &
29
+ ChainIdParameter<config, chainId> &
30
+ ConnectorParameter
31
+ >
32
+ }[number]
33
+
34
+ export type SetResolverReturnType = ensjs_SetResolverReturnType
35
+
36
+ export type SetResolverErrorType = ensjs_SetResolverErrorType
37
+
38
+ export async function setResolver<chains extends readonly [Chain, ...Chain[]]>(
39
+ config: RequireConfigContracts<chains, 'ensRegistry' | 'ensNameWrapper'>,
40
+ parameters: SetResolverParameters<ExcludeTE<typeof config>>,
41
+ ): Promise<SetResolverReturnType> {
42
+ ASSERT_NO_TYPE_ERROR(config)
43
+
44
+ const { account, chainId, connector, ...rest } = parameters
45
+
46
+ let client: Client<any, Chain>
47
+ if (typeof account === 'object' && account?.type === 'local')
48
+ client = config.getClient({ chainId })
49
+ else
50
+ client = await getConnectorClient(config, {
51
+ account: account ?? undefined,
52
+ chainId,
53
+ connector,
54
+ })
55
+
56
+ const action = getAction(client, ensjs_setResolver, 'setResolver')
57
+ return await action({
58
+ ...(rest as any),
59
+ ...(account ? { account } : {}),
60
+ chain: chainId ? { id: chainId } : null,
61
+ })
62
+ }
@@ -0,0 +1,58 @@
1
+ import {
2
+ type SetTextRecordErrorType as ensjs_SetTextRecordErrorType,
3
+ type SetTextRecordParameters as ensjs_SetTextRecordParameters,
4
+ type SetTextRecordReturnType as ensjs_SetTextRecordReturnType,
5
+ setTextRecord as ensjs_setTextRecord,
6
+ } from '@ensdomains/ensjs/wallet'
7
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
8
+ import type {
9
+ ChainIdParameter,
10
+ Compute,
11
+ ConnectorParameter,
12
+ } from '@wagmi/core/internal'
13
+ import type { Account, Chain, Client } from 'viem'
14
+ import { getAction } from '../../utils/getAction.js'
15
+
16
+ export type SetTextRecordParameters<
17
+ config extends Config = Config,
18
+ chainId extends
19
+ config['chains'][number]['id'] = config['chains'][number]['id'],
20
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
21
+ > = {
22
+ [key in keyof chains]: Compute<
23
+ Omit<
24
+ ensjs_SetTextRecordParameters<chains[key], Account, chains[key]>,
25
+ 'chain'
26
+ > &
27
+ ChainIdParameter<config, chainId> &
28
+ ConnectorParameter
29
+ >
30
+ }[number]
31
+
32
+ export type SetTextRecordReturnType = ensjs_SetTextRecordReturnType
33
+
34
+ export type SetTextRecordErrorType = ensjs_SetTextRecordErrorType
35
+
36
+ export async function setTextRecord<config extends Config>(
37
+ config: config,
38
+ parameters: SetTextRecordParameters<config>,
39
+ ): Promise<SetTextRecordReturnType> {
40
+ const { account, chainId, connector, ...rest } = parameters
41
+
42
+ let client: Client<any, Chain>
43
+ if (typeof account === 'object' && account?.type === 'local')
44
+ client = config.getClient({ chainId })
45
+ else
46
+ client = await getConnectorClient(config, {
47
+ account: account ?? undefined,
48
+ chainId,
49
+ connector,
50
+ })
51
+
52
+ const action = getAction(client, ensjs_setTextRecord, 'setTextRecord')
53
+ return await action({
54
+ ...(rest as any),
55
+ ...(account ? { account } : {}),
56
+ chain: chainId ? { id: chainId } : null,
57
+ })
58
+ }
@@ -0,0 +1,73 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import {
6
+ type TransferNameErrorType as ensjs_TransferNameErrorType,
7
+ type TransferNameParameters as ensjs_TransferNameParameters,
8
+ type TransferNameReturnType as ensjs_TransferNameReturnType,
9
+ transferName as ensjs_transferName,
10
+ type TransferNameSupportedContract,
11
+ } from '@ensdomains/ensjs/wallet'
12
+ import { type Config, getConnectorClient, type SelectChains } from '@wagmi/core'
13
+ import type {
14
+ ChainIdParameter,
15
+ Compute,
16
+ ConnectorParameter,
17
+ } from '@wagmi/core/internal'
18
+ import type { Account, Chain, Client } from 'viem'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { getAction } from '../../utils/getAction.js'
21
+
22
+ export type TransferNameParameters<
23
+ contract extends TransferNameSupportedContract,
24
+ config extends Config = Config,
25
+ chainId extends
26
+ config['chains'][number]['id'] = config['chains'][number]['id'],
27
+ chains extends readonly Chain[] = SelectChains<config, chainId>,
28
+ > = {
29
+ [key in keyof chains]: Compute<
30
+ Omit<
31
+ ensjs_TransferNameParameters<contract, chains[key], Account, any>,
32
+ 'chain'
33
+ > &
34
+ ChainIdParameter<config, chainId> &
35
+ ConnectorParameter
36
+ >
37
+ }[number]
38
+
39
+ export type TransferNameReturnType = ensjs_TransferNameReturnType
40
+
41
+ export type TransferNameErrorType = ensjs_TransferNameErrorType
42
+
43
+ export async function transferName<
44
+ contract extends TransferNameSupportedContract,
45
+ chains extends readonly [Chain, ...Chain[]],
46
+ >(
47
+ config: RequireConfigContracts<
48
+ chains,
49
+ 'ensRegistry' | 'ensNameWrapper' | 'ensBaseRegistrarImplementation'
50
+ >,
51
+ parameters: TransferNameParameters<contract, ExcludeTE<typeof config>>,
52
+ ): Promise<TransferNameReturnType> {
53
+ ASSERT_NO_TYPE_ERROR(config)
54
+
55
+ const { account, chainId, connector, ...rest } = parameters
56
+
57
+ let client: Client<any, Chain>
58
+ if (typeof account === 'object' && account?.type === 'local')
59
+ client = config.getClient({ chainId })
60
+ else
61
+ client = await getConnectorClient(config, {
62
+ account: account ?? undefined,
63
+ chainId,
64
+ connector,
65
+ })
66
+
67
+ const action = getAction(client, ensjs_transferName, 'transferName')
68
+ return await action({
69
+ ...(rest as any),
70
+ ...(account ? { account } : {}),
71
+ chain: chainId ? { id: chainId } : null,
72
+ })
73
+ }
package/src/example.ts ADDED
@@ -0,0 +1,39 @@
1
+ // import { extendChainWithEns } from '@ensdomains/ensjs/chain'
2
+ // import { Config, createConfig, http } from '@wagmi/core'
3
+ // import { Chain, mainnet, Prettify } from 'viem/chains'
4
+ // import { RequireConfigContracts, RequireConfigContracts2 } from './utils/chain'
5
+ // import { ASSERT_NO_TYPE_ERROR, EXCLUDE_TYPE_ERROR, ExcludeTE } from '@ensdomains/ensjs/internal'
6
+
7
+ // const myConfig = createConfig({
8
+ // chains: [mainnet],
9
+ // transports: {
10
+ // [mainnet.id]: http(),
11
+ // },
12
+ // })
13
+
14
+ // const myConfigWithEns = createConfig({
15
+ // chains: [extendChainWithEns(mainnet)],
16
+ // transports: {
17
+ // [mainnet.id]: http(),
18
+ // },
19
+ // })
20
+
21
+ // const myAction = <chains extends readonly [Chain, ...Chain[]]>(config: RequireConfigContracts<chains, 'ensBaseRegistrarImplementation'>): ExcludeTE<typeof config> => {
22
+ // const config_ = config as ExcludeTE<typeof config> & {}
23
+
24
+ // return {} as any
25
+ // }
26
+
27
+ // const sdads = myAction(myConfig)
28
+ // const asdsad = myAction(myConfigWithEns)
29
+
30
+ // const myAction2 = <config extends Config>(config: RequireConfigContracts2<config, 'ensBaseRegistrarImplementation'>): ExcludeTE<typeof config> => {
31
+ // const dasdas = EXCLUDE_TYPE_ERROR(config)
32
+
33
+ // type asdasd = Prettify<typeof config>
34
+
35
+ // return {} as any
36
+ // }
37
+
38
+ // const asd = myAction2(myConfig)
39
+ // const jksdf = myAction2(myConfigWithEns)
@@ -0,0 +1,61 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { QueryOptions } 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 GetAbiRecordErrorType,
15
+ type GetAbiRecordParameters,
16
+ type GetAbiRecordReturnType,
17
+ getAbiRecord,
18
+ } from '../../actions/public/getAbiRecord.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type GetAbiRecordOptions<config extends Config> = Compute<
23
+ ExactPartial<GetAbiRecordParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function getAbiRecordQueryOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<chains, 'ensUniversalResolver'>,
30
+ options: GetAbiRecordOptions<ExcludeTE<typeof config>> = {},
31
+ ) {
32
+ ASSERT_NO_TYPE_ERROR(config)
33
+
34
+ return {
35
+ async queryFn({ queryKey }) {
36
+ const { name, scopeKey: _, ...parameters } = queryKey[1]
37
+ if (!name) throw new Error('name is required')
38
+ return getAbiRecord<chains>(config, { ...parameters, name })
39
+ },
40
+ queryKey: getAbiRecordQueryKey(options),
41
+ } as const satisfies QueryOptions<
42
+ GetAbiRecordQueryFnData,
43
+ GetAbiRecordErrorType,
44
+ GetAbiRecordData,
45
+ GetAbiRecordQueryKey<typeof config>
46
+ >
47
+ }
48
+
49
+ export type GetAbiRecordQueryFnData = GetAbiRecordReturnType
50
+
51
+ export type GetAbiRecordData = GetAbiRecordQueryFnData
52
+
53
+ export function getAbiRecordQueryKey<config extends Config>(
54
+ options: GetAbiRecordOptions<config> = {},
55
+ ) {
56
+ return ['ensjs_abiRecord', filterQueryOptions(options)] as const
57
+ }
58
+
59
+ export type GetAbiRecordQueryKey<config extends Config> = ReturnType<
60
+ typeof getAbiRecordQueryKey<config>
61
+ >
@@ -0,0 +1,61 @@
1
+ import {
2
+ ASSERT_NO_TYPE_ERROR,
3
+ type ExcludeTE,
4
+ } from '@ensdomains/ensjs/internal'
5
+ import type { QueryOptions } 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 GetAddressRecordErrorType,
15
+ type GetAddressRecordParameters,
16
+ type GetAddressRecordReturnType,
17
+ getAddressRecord,
18
+ } from '../../actions/public/getAddressRecord.js'
19
+ import type { RequireConfigContracts } from '../../utils/chain.js'
20
+ import { filterQueryOptions } from '../utils.js'
21
+
22
+ export type GetAddressRecordOptions<config extends Config> = Compute<
23
+ ExactPartial<GetAddressRecordParameters<config>> & ScopeKeyParameter
24
+ >
25
+
26
+ export function getAddressRecordQueryOptions<
27
+ chains extends readonly [Chain, ...Chain[]],
28
+ >(
29
+ config: RequireConfigContracts<chains, 'ensUniversalResolver'>,
30
+ options: GetAddressRecordOptions<ExcludeTE<typeof config>> = {},
31
+ ) {
32
+ ASSERT_NO_TYPE_ERROR(config)
33
+
34
+ return {
35
+ async queryFn({ queryKey }) {
36
+ const { name, scopeKey: _, ...parameters } = queryKey[1]
37
+ if (!name) throw new Error('name is required')
38
+ return getAddressRecord<chains>(config, { ...parameters, name })
39
+ },
40
+ queryKey: getAddressRecordQueryKey(options),
41
+ } as const satisfies QueryOptions<
42
+ GetAddressRecordQueryFnData,
43
+ GetAddressRecordErrorType,
44
+ GetAddressRecordData,
45
+ GetAddressRecordQueryKey<typeof config>
46
+ >
47
+ }
48
+
49
+ export type GetAddressRecordQueryFnData = GetAddressRecordReturnType
50
+
51
+ export type GetAddressRecordData = GetAddressRecordQueryFnData
52
+
53
+ export function getAddressRecordQueryKey<config extends Config>(
54
+ options: GetAddressRecordOptions<config> = {},
55
+ ) {
56
+ return ['ensjs_addressRecord', filterQueryOptions(options)] as const
57
+ }
58
+
59
+ export type GetAddressRecordQueryKey<config extends Config> = ReturnType<
60
+ typeof getAddressRecordQueryKey<config>
61
+ >