From b8b01490caecd7c30106294da7d517cc4736a37c Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 4 Sep 2024 22:24:49 +0000 Subject: [PATCH] Introduce resolver interfaces --- .../src/hooks/useEnsResolverInterfaces.ts | 9 +++-- packages/react/src/index.ts | 2 ++ packages/react/src/interfaces.ts | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/react/src/interfaces.ts diff --git a/packages/react/src/hooks/useEnsResolverInterfaces.ts b/packages/react/src/hooks/useEnsResolverInterfaces.ts index d1151f43..802792ae 100644 --- a/packages/react/src/hooks/useEnsResolverInterfaces.ts +++ b/packages/react/src/hooks/useEnsResolverInterfaces.ts @@ -3,6 +3,7 @@ import type { Address, Hex } from 'viem' import { getSupportedInterfaces } from '@ensdomains/ensjs/public' import type { ParamWithClients } from '../client.js' import { fallbackQueryClient } from '../query.js' +import { resolverInterfaces } from '../interfaces.js' export type UseEnsResolverInterfacesParams< Interfaces extends readonly Hex[] = [Hex, Hex], @@ -21,6 +22,8 @@ export type UseEnsResolverInterfacesReturnType< * Returns a wether or not the interfaces are supported by the resolver * You can find a list of interfaces at https://docs.ens.domains/resolvers/interfaces * + * You can use the {@link resolverInterfaces} shorthand, or manually specify a Hex value + * * @param data - {@link UseEnsResolverInterfacesParams} * @returns - {@link boolean[]} */ @@ -29,8 +32,10 @@ export const useEnsResolverInterfaces = ( ): UseQueryResult> => { const { resolver, - // default ['addr(node, coinType)', 'wildcard'] - interfaces = ['0xf1cb7e06', '0x9061b923'], + interfaces = [ + resolverInterfaces.addrMulticoin, + resolverInterfaces.wildcard, + ], client, queryClient = fallbackQueryClient, } = data diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index 3462bf41..26593bd8 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -1 +1,3 @@ export * from './hooks.js' +export { resolverInterfaces } from './interfaces.js' +export type { ParamWithClients } from './client.js' diff --git a/packages/react/src/interfaces.ts b/packages/react/src/interfaces.ts new file mode 100644 index 00000000..42035885 --- /dev/null +++ b/packages/react/src/interfaces.ts @@ -0,0 +1,35 @@ +export const resolverInterfaces = { + /** + * Addr addr(bytes32 node, uint256 coinType) + * Legacy please use addrMulticoin + */ + addr: '0x3b3b57de', + /** + * Addr Multicoin addr(bytes32 node, uint256 coinType) + */ + addrMulticoin: '0xf1cb7e06', + /** + * Content Hash contenthash(bytes32 node) + */ + contentHash: '0xbc1c58d1', + /** + * Text text(bytes32 node, string key) + */ + text: '0x59d1d43c', + /** + * ABI abi(bytes32 node, uint256 contentType) + */ + abi: '0x2203ab56', + /** + * Public Key pubkey(bytes32 node) + */ + pubkey: '0xc8690233', + /** + * Reverse Name name(bytes32 node) + */ + name: '0x691f3431', + /** + * Wildcard + */ + wildcard: '0x9061b923', +} as const