Skip to content

Commit

Permalink
Introduce resolver interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Sep 4, 2024
1 parent 0032683 commit b8b0149
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react/src/hooks/useEnsResolverInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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[]}
*/
Expand All @@ -29,8 +32,10 @@ export const useEnsResolverInterfaces = <Interfaces extends readonly Hex[]>(
): UseQueryResult<UseEnsResolverInterfacesReturnType<Interfaces>> => {
const {
resolver,
// default ['addr(node, coinType)', 'wildcard']
interfaces = ['0xf1cb7e06', '0x9061b923'],
interfaces = [
resolverInterfaces.addrMulticoin,
resolverInterfaces.wildcard,
],
client,
queryClient = fallbackQueryClient,
} = data
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './hooks.js'
export { resolverInterfaces } from './interfaces.js'
export type { ParamWithClients } from './client.js'
35 changes: 35 additions & 0 deletions packages/react/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b8b0149

Please sign in to comment.