-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathwhoisResolver.slice.ts
More file actions
37 lines (33 loc) · 1.1 KB
/
whoisResolver.slice.ts
File metadata and controls
37 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query/react'
export interface WhoisResponse {
TOREX: { handle: string; avatarUrl?: string } | null
ENS: { handle: string; avatarUrl?: string } | null
Farcaster: { handle: string; avatarUrl?: string } | null
AlfaFrens: { handle: string; avatarUrl?: string } | null
Lens: { handle: string; avatarUrl?: string } | null
recommendedName: string | null
recommendedAvatar: string | null
}
export const whoisApi = createApi({
reducerPath: 'whois',
baseQuery: fakeBaseQuery(),
endpoints: (builder) => ({
resolveAddress: builder.query<WhoisResponse | null, string>({
queryFn: async (address) => {
try {
const response = await fetch(
`https://whois.superfluid.finance/api/resolve/${address}`
)
if (!response.ok) {
return { data: null }
}
const data = await response.json()
return { data }
} catch (error) {
console.error('Whois API error:', error)
return { data: null }
}
}
})
})
})