@ensnode/ensnode-react 0.34.0
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.
- package/LICENSE +21 -0
- package/README.md +329 -0
- package/dist/index.cjs +252 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +203 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.js +231 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NameHash
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# @ensnode/ensnode-react
|
|
2
|
+
|
|
3
|
+
React hooks and providers for the ENSNode API. This package provides a React-friendly interface to the ENSNode SDK with automatic caching, loading states, and error handling. **TanStack Query is handled automatically** - no setup required unless you want custom configuration.
|
|
4
|
+
|
|
5
|
+
Learn more about [ENSNode](https://ensnode.io/) from [the ENSNode docs](https://ensnode.io/docs/).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @ensnode/ensnode-react @ensnode/ensnode-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Note: `@tanstack/react-query` is a peer dependency but you don't need to interact with it directly unless you want advanced query customization.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Setup the Provider
|
|
18
|
+
|
|
19
|
+
Wrap your app with the `ENSNodeProvider`:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { ENSNodeProvider, createConfig } from "@ensnode/ensnode-react";
|
|
23
|
+
|
|
24
|
+
const config = createConfig({ url: "https://api.alpha.ensnode.io" });
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<ENSNodeProvider config={config}>
|
|
29
|
+
<YourApp />
|
|
30
|
+
</ENSNodeProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
That's it! No need to wrap with `QueryClientProvider` or create a `QueryClient` - it's all handled automatically. Each ENSNode endpoint gets its own isolated cache for proper data separation.
|
|
36
|
+
|
|
37
|
+
### 2. Use the Hooks
|
|
38
|
+
|
|
39
|
+
#### Records Resolution — `useRecords`
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { useRecords } from "@ensnode/ensnode-react";
|
|
43
|
+
|
|
44
|
+
function DisplayNameRecords() {
|
|
45
|
+
const { data, isLoading, error } = useRecords({
|
|
46
|
+
name: "vitalik.eth",
|
|
47
|
+
selection: {
|
|
48
|
+
addresses: [60], // ETH CoinType
|
|
49
|
+
texts: ["avatar", "com.twitter"],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (isLoading) return <div>Loading...</div>;
|
|
54
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div>
|
|
58
|
+
<h3>Resolved Records for vitalik.eth</h3>
|
|
59
|
+
{data.records.addresses && (
|
|
60
|
+
<p>ETH Address: {data.records.addresses["60"]}</p>
|
|
61
|
+
)}
|
|
62
|
+
{data.records.texts && (
|
|
63
|
+
<div>
|
|
64
|
+
<p>Avatar: {data.records.texts.avatar}</p>
|
|
65
|
+
<p>Twitter: {data.records.texts["com.twitter"]}</p>
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Primary Name Resolution — `usePrimaryName`
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { mainnet } from 'viem/chains';
|
|
77
|
+
import { usePrimaryName } from "@ensnode/ensnode-react";
|
|
78
|
+
|
|
79
|
+
function DisplayPrimaryName() {
|
|
80
|
+
const { data, isLoading, error } = usePrimaryName({
|
|
81
|
+
address: "0x179A862703a4adfb29896552DF9e307980D19285",
|
|
82
|
+
chainId: mainnet.id,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (isLoading) return <div>Loading...</div>;
|
|
86
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div>
|
|
90
|
+
<h3>Primary Name (for Mainnet)</h3>
|
|
91
|
+
<p>{data.name ?? 'No Primary Name'}</p>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Primary Names Resolution — `usePrimaryNames`
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { mainnet } from 'viem/chains';
|
|
101
|
+
import { usePrimaryNames } from "@ensnode/ensnode-react";
|
|
102
|
+
|
|
103
|
+
function DisplayPrimaryNames() {
|
|
104
|
+
const { data, isLoading, error } = usePrimaryNames({
|
|
105
|
+
address: "0x179A862703a4adfb29896552DF9e307980D19285",
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (isLoading) return <div>Loading...</div>;
|
|
109
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div>
|
|
113
|
+
{Object.entries(data.names).map(([chainId, name]) => (
|
|
114
|
+
<div key={chainId}>
|
|
115
|
+
<h3>Primary Name (Chain Id: {chainId})</h3>
|
|
116
|
+
<p>{name}</p>
|
|
117
|
+
</div>
|
|
118
|
+
))}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## API Reference
|
|
125
|
+
|
|
126
|
+
### ENSNodeProvider
|
|
127
|
+
|
|
128
|
+
The provider component that supplies ENSNode configuration to all child components.
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
interface ENSNodeProviderProps {
|
|
132
|
+
config: ENSNodeConfig;
|
|
133
|
+
queryClient?: QueryClient;
|
|
134
|
+
queryClientOptions?: QueryClientOptions;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Props
|
|
139
|
+
|
|
140
|
+
- `config`: ENSNode configuration object
|
|
141
|
+
- `queryClient`: Optional TanStack Query client instance (requires manual QueryClientProvider setup)
|
|
142
|
+
- `queryClientOptions`: Optional Custom options for auto-created QueryClient (only used when queryClient is not provided)
|
|
143
|
+
|
|
144
|
+
### createConfig
|
|
145
|
+
|
|
146
|
+
Helper function to create ENSNode configuration with defaults.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
const config = createConfig({
|
|
150
|
+
url: "https://api.alpha.ensnode.io",
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `useRecords`
|
|
155
|
+
|
|
156
|
+
Hook that resolves records for an ENS name (Forward Resolution), via ENSNode, which implements Protocol Acceleration for indexed names.
|
|
157
|
+
|
|
158
|
+
#### Parameters
|
|
159
|
+
|
|
160
|
+
- `name`: The ENS Name whose records to resolve
|
|
161
|
+
- `selection`: Selection of Resolver records to resolve
|
|
162
|
+
- `addresses`: Array of coin types to resolve addresses for
|
|
163
|
+
- `texts`: Array of text record keys to resolve
|
|
164
|
+
- `trace`: (optional) Whether to include a trace in the response (default: false)
|
|
165
|
+
- `accelerate`: (optional) Whether to attempt Protocol Acceleration (default: false)
|
|
166
|
+
- `query`: (optional) TanStack Query options for customization
|
|
167
|
+
|
|
168
|
+
#### Example
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
const { data, isLoading, error, refetch } = useRecords({
|
|
172
|
+
name: "example.eth",
|
|
173
|
+
selection: {
|
|
174
|
+
addresses: [60], // ETH
|
|
175
|
+
texts: ["avatar", "description", "url"],
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `usePrimaryName`
|
|
181
|
+
|
|
182
|
+
Hook that resolves the primary name of the provided `address` on the specified `chainId`, via ENSNode, which implements Protocol Acceleration for indexed names. If the `address` specifies a valid [ENSIP-19 Default Name](https://docs.ens.domains/ensip/19/#default-primary-name), the Default Name will be returned. You _may_ query the Default EVM Chain Id (`0`) in order to determine the `address`'s Default Name directly.
|
|
183
|
+
|
|
184
|
+
#### Parameters
|
|
185
|
+
|
|
186
|
+
- `address`: The Address whose Primary Name to resolve
|
|
187
|
+
- `chainId`: The chain id within which to query the address' ENSIP-19 Multichain Primary Name
|
|
188
|
+
- `trace`: (optional) Whether to include a trace in the response (default: false)
|
|
189
|
+
- `accelerate`: (optional) Whether to attempt Protocol Acceleration (default: false)
|
|
190
|
+
- `query`: (optional) TanStack Query options for customization
|
|
191
|
+
|
|
192
|
+
#### Example
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
const { data, isLoading, error, refetch } = usePrimaryName({
|
|
196
|
+
address: "0x179A862703a4adfb29896552DF9e307980D19285",
|
|
197
|
+
chainId: 10, // Optimism
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### `usePrimaryNames`
|
|
202
|
+
|
|
203
|
+
Hook that resolves the primary names of the provided `address` on the specified chainIds, via ENSNode, which implements Protocol Acceleration for indexed names. If the `address` specifies a valid [ENSIP-19 Default Name](https://docs.ens.domains/ensip/19/#default-primary-name), the Default Name will be returned for all chainIds for which there is not a chain-specific Primary Name. To avoid misuse, you _may not_ query the Default EVM Chain Id (`0`) directly, and should rely on the aforementioned per-chain defaulting behavior.
|
|
204
|
+
|
|
205
|
+
#### Parameters
|
|
206
|
+
|
|
207
|
+
- `address`: The Address whose Primary Names to resolve
|
|
208
|
+
- `chainIds`: (optional) Array of chain ids to query the address' ENSIP-19 Multichain Primary Names (default: all ENSIP-19 supported chains)
|
|
209
|
+
- `trace`: (optional) Whether to include a trace in the response (default: false)
|
|
210
|
+
- `accelerate`: (optional) Whether to attempt Protocol Acceleration (default: false)
|
|
211
|
+
- `query`: (optional) TanStack Query options for customization
|
|
212
|
+
|
|
213
|
+
#### Example
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
const { data, isLoading, error, refetch } = usePrimaryNames({
|
|
217
|
+
address: "0x179A862703a4adfb29896552DF9e307980D19285",
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Advanced Usage
|
|
222
|
+
|
|
223
|
+
### Custom Query Configuration
|
|
224
|
+
|
|
225
|
+
The `ENSNodeProvider` automatically creates and manages a QueryClient for you. Cache keys include the ENSNode endpoint URL, so different endpoints (mainnet vs testnet) maintain separate caches. You can customize the QueryClient without importing TanStack Query:
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
// Simple setup - no TanStack Query knowledge needed
|
|
229
|
+
<ENSNodeProvider
|
|
230
|
+
config={config}
|
|
231
|
+
queryClientOptions={{
|
|
232
|
+
defaultOptions: {
|
|
233
|
+
queries: {
|
|
234
|
+
staleTime: 1000 * 60 * 10, // 10 minutes
|
|
235
|
+
gcTime: 1000 * 60 * 60, // 1 hour
|
|
236
|
+
retry: 5,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
<App />
|
|
242
|
+
</ENSNodeProvider>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Advanced: Bring Your Own QueryClient
|
|
246
|
+
|
|
247
|
+
If you need full control over TanStack Query, you can provide your own `QueryClient`:
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
251
|
+
|
|
252
|
+
const queryClient = new QueryClient({
|
|
253
|
+
defaultOptions: {
|
|
254
|
+
queries: {
|
|
255
|
+
staleTime: 1000 * 60 * 10, // 10 minutes
|
|
256
|
+
gcTime: 1000 * 60 * 60, // 1 hour
|
|
257
|
+
retry: 5,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
<QueryClientProvider client={queryClient}>
|
|
263
|
+
<ENSNodeProvider config={config} queryClient={queryClient}>
|
|
264
|
+
<App />
|
|
265
|
+
</ENSNodeProvider>
|
|
266
|
+
</QueryClientProvider>;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
TanStack Query v5+ is used internally. Hook return types are TanStack Query's `UseQueryResult` for full compatibility, but you don't need to interact with TanStack Query directly unless you want advanced customization.
|
|
270
|
+
|
|
271
|
+
### Conditional Queries
|
|
272
|
+
|
|
273
|
+
Queries only execute if all required variables are provided:
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
const [address, setAddress] = useState("");
|
|
277
|
+
|
|
278
|
+
// only executes when address is not null
|
|
279
|
+
const { data } = usePrimaryName({
|
|
280
|
+
address: address || null,
|
|
281
|
+
chainId: 1
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
You can also conditionally enable/disable queries based on your own logic:
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
const [showPrimaryName, setShowPrimaryName] = useState(false);
|
|
289
|
+
|
|
290
|
+
// will not execute until `showPrimaryName` is true
|
|
291
|
+
const { data } = usePrimaryName({
|
|
292
|
+
address: "0x179A862703a4adfb29896552DF9e307980D19285",
|
|
293
|
+
chainId: 1,
|
|
294
|
+
query: { enabled: showPrimaryName },
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Multichain Reverse Resolution
|
|
299
|
+
|
|
300
|
+
ENS supports [Multichain Primary Names](https://docs.ens.domains/ensip/19/), and ENSNode supports
|
|
301
|
+
resolving the Primary Name of an address within the context of a specific `chainId`.
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
function ShowMultichainPrimaryNames({ address }: { address: Address }) {
|
|
305
|
+
const mainnet = usePrimaryName({ address, chainId: 1 });
|
|
306
|
+
const optimism = usePrimaryName({ address, chainId: 10 });
|
|
307
|
+
const polygon = usePrimaryName({ address, chainId: 137 });
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<div>
|
|
311
|
+
<div>Mainnet: {mainnet.data?.records.name || "None"}</div>
|
|
312
|
+
<div>Optimism: {optimism.data?.records.name || "None"}</div>
|
|
313
|
+
<div>Polygon: {polygon.data?.records.name || "None"}</div>
|
|
314
|
+
</div>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Error Handling
|
|
320
|
+
|
|
321
|
+
Use the `error` and `isError` result parameters to handle error states in your application.
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
const { data, error, isError } = useRecords({ name: "vitalik.eth" });
|
|
325
|
+
|
|
326
|
+
if (isError) {
|
|
327
|
+
return <div>Failed to resolve: {error.message}</div>;
|
|
328
|
+
}
|
|
329
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ENSNodeContext: () => ENSNodeContext,
|
|
24
|
+
ENSNodeProvider: () => ENSNodeProvider,
|
|
25
|
+
createConfig: () => createConfig,
|
|
26
|
+
useENSIndexerConfig: () => useENSIndexerConfig,
|
|
27
|
+
useENSNodeConfig: () => useENSNodeConfig,
|
|
28
|
+
useIndexingStatus: () => useIndexingStatus,
|
|
29
|
+
usePrimaryName: () => usePrimaryName,
|
|
30
|
+
usePrimaryNames: () => usePrimaryNames,
|
|
31
|
+
useRecords: () => useRecords
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/provider.tsx
|
|
36
|
+
var import_ensnode_sdk = require("@ensnode/ensnode-sdk");
|
|
37
|
+
var import_react_query = require("@tanstack/react-query");
|
|
38
|
+
var import_react2 = require("react");
|
|
39
|
+
|
|
40
|
+
// src/context.ts
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var ENSNodeContext = (0, import_react.createContext)(void 0);
|
|
43
|
+
ENSNodeContext.displayName = "ENSNodeContext";
|
|
44
|
+
|
|
45
|
+
// src/provider.tsx
|
|
46
|
+
function ENSNodeInternalProvider({
|
|
47
|
+
children,
|
|
48
|
+
config
|
|
49
|
+
}) {
|
|
50
|
+
const memoizedConfig = (0, import_react2.useMemo)(() => config, [config]);
|
|
51
|
+
return (0, import_react2.createElement)(ENSNodeContext.Provider, { value: memoizedConfig }, children);
|
|
52
|
+
}
|
|
53
|
+
function ENSNodeProvider(parameters) {
|
|
54
|
+
const { children, config, queryClient, queryClientOptions } = parameters;
|
|
55
|
+
let hasExistingQueryClient = false;
|
|
56
|
+
try {
|
|
57
|
+
hasExistingQueryClient = Boolean((0, import_react_query.useQueryClient)());
|
|
58
|
+
} catch {
|
|
59
|
+
hasExistingQueryClient = false;
|
|
60
|
+
}
|
|
61
|
+
if (queryClient) {
|
|
62
|
+
if (!hasExistingQueryClient) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
"When providing a custom queryClient, you must wrap your app with QueryClientProvider. Either remove the queryClient prop to use auto-managed setup, or wrap with QueryClientProvider."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return (0, import_react2.createElement)(ENSNodeInternalProvider, { config, children });
|
|
68
|
+
}
|
|
69
|
+
if (hasExistingQueryClient) {
|
|
70
|
+
return (0, import_react2.createElement)(ENSNodeInternalProvider, { config, children });
|
|
71
|
+
}
|
|
72
|
+
const defaultQueryClient = (0, import_react2.useMemo)(
|
|
73
|
+
() => new import_react_query.QueryClient({
|
|
74
|
+
defaultOptions: {
|
|
75
|
+
queries: {
|
|
76
|
+
retry: 3,
|
|
77
|
+
staleTime: 1e3 * 60 * 5,
|
|
78
|
+
// 5 minutes
|
|
79
|
+
gcTime: 1e3 * 60 * 30
|
|
80
|
+
// 30 minutes
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
...queryClientOptions
|
|
84
|
+
}),
|
|
85
|
+
[queryClientOptions]
|
|
86
|
+
);
|
|
87
|
+
return (0, import_react2.createElement)(
|
|
88
|
+
import_react_query.QueryClientProvider,
|
|
89
|
+
{ client: defaultQueryClient },
|
|
90
|
+
(0, import_react2.createElement)(ENSNodeInternalProvider, { config, children })
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function createConfig(options) {
|
|
94
|
+
const url = options?.url ? new URL(options.url) : import_ensnode_sdk.ENSNodeClient.defaultOptions().url;
|
|
95
|
+
return {
|
|
96
|
+
client: {
|
|
97
|
+
...import_ensnode_sdk.ENSNodeClient.defaultOptions(),
|
|
98
|
+
url
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/hooks/useENSNodeConfig.ts
|
|
104
|
+
var import_react3 = require("react");
|
|
105
|
+
function useENSNodeConfig(config) {
|
|
106
|
+
const contextConfig = (0, import_react3.useContext)(ENSNodeContext);
|
|
107
|
+
const resolvedConfig = config ?? contextConfig;
|
|
108
|
+
if (!resolvedConfig) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
"useENSNodeConfig must be used within an ENSNodeProvider or you must pass a config parameter"
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return resolvedConfig;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/hooks/useRecords.ts
|
|
117
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
118
|
+
|
|
119
|
+
// src/utils/query.ts
|
|
120
|
+
var import_ensnode_sdk2 = require("@ensnode/ensnode-sdk");
|
|
121
|
+
var queryKeys = {
|
|
122
|
+
base: (url) => ["ensnode", url],
|
|
123
|
+
resolve: (url) => [...queryKeys.base(url), "resolve"],
|
|
124
|
+
records: (url, args) => [...queryKeys.resolve(url), "records", args],
|
|
125
|
+
primaryName: (url, args) => [...queryKeys.resolve(url), "primary-name", args],
|
|
126
|
+
primaryNames: (url, args) => [...queryKeys.resolve(url), "primary-names", args],
|
|
127
|
+
config: (url) => [...queryKeys.base(url), "config"],
|
|
128
|
+
indexingStatus: (url, args) => [...queryKeys.base(url), "config", args]
|
|
129
|
+
};
|
|
130
|
+
function createRecordsQueryOptions(config, args) {
|
|
131
|
+
return {
|
|
132
|
+
enabled: true,
|
|
133
|
+
queryKey: queryKeys.records(config.client.url.href, args),
|
|
134
|
+
queryFn: async () => {
|
|
135
|
+
const client = new import_ensnode_sdk2.ENSNodeClient(config.client);
|
|
136
|
+
return client.resolveRecords(args.name, args.selection, args);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function createPrimaryNameQueryOptions(config, args) {
|
|
141
|
+
return {
|
|
142
|
+
enabled: true,
|
|
143
|
+
queryKey: queryKeys.primaryName(config.client.url.href, args),
|
|
144
|
+
queryFn: async () => {
|
|
145
|
+
const client = new import_ensnode_sdk2.ENSNodeClient(config.client);
|
|
146
|
+
return client.resolvePrimaryName(args.address, args.chainId, args);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function createPrimaryNamesQueryOptions(config, args) {
|
|
151
|
+
return {
|
|
152
|
+
enabled: true,
|
|
153
|
+
queryKey: queryKeys.primaryNames(config.client.url.href, args),
|
|
154
|
+
queryFn: async () => {
|
|
155
|
+
const client = new import_ensnode_sdk2.ENSNodeClient(config.client);
|
|
156
|
+
return client.resolvePrimaryNames(args.address, args);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function createENSIndexerConfigQueryOptions(config) {
|
|
161
|
+
return {
|
|
162
|
+
enabled: true,
|
|
163
|
+
queryKey: queryKeys.config(config.client.url.href),
|
|
164
|
+
queryFn: async () => {
|
|
165
|
+
const client = new import_ensnode_sdk2.ENSNodeClient(config.client);
|
|
166
|
+
return client.config();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function createIndexingStatusQueryOptions(config, args) {
|
|
171
|
+
return {
|
|
172
|
+
enabled: true,
|
|
173
|
+
queryKey: queryKeys.indexingStatus(config.client.url.href, args),
|
|
174
|
+
queryFn: async () => {
|
|
175
|
+
const client = new import_ensnode_sdk2.ENSNodeClient(config.client);
|
|
176
|
+
return client.indexingStatus(args);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/hooks/useRecords.ts
|
|
182
|
+
function useRecords(parameters) {
|
|
183
|
+
const { config, query = {}, name, ...args } = parameters;
|
|
184
|
+
const _config = useENSNodeConfig(config);
|
|
185
|
+
const canEnable = name !== null;
|
|
186
|
+
const queryOptions = canEnable ? createRecordsQueryOptions(_config, { ...args, name }) : { enabled: false, queryKey: ["disabled"] };
|
|
187
|
+
const options = {
|
|
188
|
+
...queryOptions,
|
|
189
|
+
...query,
|
|
190
|
+
enabled: canEnable && (query.enabled ?? queryOptions.enabled)
|
|
191
|
+
};
|
|
192
|
+
return (0, import_react_query2.useQuery)(options);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/hooks/usePrimaryName.ts
|
|
196
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
197
|
+
function usePrimaryName(parameters) {
|
|
198
|
+
const { config, query = {}, address, ...args } = parameters;
|
|
199
|
+
const _config = useENSNodeConfig(config);
|
|
200
|
+
const canEnable = address !== null;
|
|
201
|
+
const queryOptions = canEnable ? createPrimaryNameQueryOptions(_config, { ...args, address }) : { enabled: false, queryKey: ["disabled"] };
|
|
202
|
+
const options = {
|
|
203
|
+
...queryOptions,
|
|
204
|
+
...query,
|
|
205
|
+
enabled: canEnable && (query.enabled ?? queryOptions.enabled)
|
|
206
|
+
};
|
|
207
|
+
return (0, import_react_query3.useQuery)(options);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/hooks/usePrimaryNames.ts
|
|
211
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
212
|
+
function usePrimaryNames(parameters) {
|
|
213
|
+
const { config, query = {}, address, ...args } = parameters;
|
|
214
|
+
const _config = useENSNodeConfig(config);
|
|
215
|
+
const canEnable = address !== null;
|
|
216
|
+
const queryOptions = canEnable ? createPrimaryNamesQueryOptions(_config, { ...args, address }) : { enabled: false, queryKey: ["disabled"] };
|
|
217
|
+
const options = {
|
|
218
|
+
...queryOptions,
|
|
219
|
+
...query,
|
|
220
|
+
enabled: canEnable && (query.enabled ?? queryOptions.enabled)
|
|
221
|
+
};
|
|
222
|
+
return (0, import_react_query4.useQuery)(options);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/hooks/useENSIndexerConfig.ts
|
|
226
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
227
|
+
function useENSIndexerConfig(parameters = {}) {
|
|
228
|
+
const { config, query = {} } = parameters;
|
|
229
|
+
const _config = useENSNodeConfig(config);
|
|
230
|
+
const queryOptions = createENSIndexerConfigQueryOptions(_config);
|
|
231
|
+
const options = {
|
|
232
|
+
...queryOptions,
|
|
233
|
+
...query,
|
|
234
|
+
enabled: query.enabled ?? queryOptions.enabled
|
|
235
|
+
};
|
|
236
|
+
return (0, import_react_query5.useQuery)(options);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/hooks/useIndexingStatus.ts
|
|
240
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
241
|
+
function useIndexingStatus(parameters = {}) {
|
|
242
|
+
const { config, query = {}, ...args } = parameters;
|
|
243
|
+
const _config = useENSNodeConfig(config);
|
|
244
|
+
const queryOptions = createIndexingStatusQueryOptions(_config, { ...args });
|
|
245
|
+
const options = {
|
|
246
|
+
...queryOptions,
|
|
247
|
+
...query,
|
|
248
|
+
enabled: query.enabled ?? queryOptions.enabled
|
|
249
|
+
};
|
|
250
|
+
return (0, import_react_query6.useQuery)(options);
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/provider.tsx","../src/context.ts","../src/hooks/useENSNodeConfig.ts","../src/hooks/useRecords.ts","../src/utils/query.ts","../src/hooks/usePrimaryName.ts","../src/hooks/usePrimaryNames.ts","../src/hooks/useENSIndexerConfig.ts","../src/hooks/useIndexingStatus.ts"],"sourcesContent":["export type { QueryClient } from \"@tanstack/react-query\";\n\nexport type { ResolverRecordsSelection } from \"@ensnode/ensnode-sdk\";\n\nexport * from \"./provider\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./types\";\n","\"use client\";\n\nimport { ENSNodeClient } from \"@ensnode/ensnode-sdk\";\nimport { QueryClient, QueryClientProvider, useQueryClient } from \"@tanstack/react-query\";\nimport { createElement, useMemo } from \"react\";\n\nimport { ENSNodeContext } from \"./context\";\nimport type { ENSNodeConfig } from \"./types\";\n\nexport interface ENSNodeProviderProps {\n /** ENSNode configuration */\n config: ENSNodeConfig;\n\n /**\n * Optional QueryClient instance. If provided, you must wrap your app with QueryClientProvider yourself.\n * If not provided, ENSNodeProvider will create and manage its own QueryClient internally.\n */\n queryClient?: QueryClient;\n\n /**\n * Custom query client options when auto-creating a QueryClient.\n * Only used when queryClient is not provided.\n */\n queryClientOptions?: ConstructorParameters<typeof QueryClient>[0];\n}\n\nfunction ENSNodeInternalProvider({\n children,\n config,\n}: {\n children: React.ReactNode;\n config: ENSNodeConfig;\n}) {\n // Memoize the config to prevent unnecessary re-renders\n const memoizedConfig = useMemo(() => config, [config]);\n\n return createElement(ENSNodeContext.Provider, { value: memoizedConfig }, children);\n}\n\nexport function ENSNodeProvider(parameters: React.PropsWithChildren<ENSNodeProviderProps>) {\n const { children, config, queryClient, queryClientOptions } = parameters;\n\n // Check if we're already inside a QueryClientProvider\n let hasExistingQueryClient = false;\n try {\n hasExistingQueryClient = Boolean(useQueryClient());\n } catch {\n // useQueryClient throws if not inside a QueryClientProvider\n hasExistingQueryClient = false;\n }\n\n // If user provided a queryClient, they must handle QueryClientProvider themselves\n if (queryClient) {\n if (!hasExistingQueryClient) {\n throw new Error(\n \"When providing a custom queryClient, you must wrap your app with QueryClientProvider. \" +\n \"Either remove the queryClient prop to use auto-managed setup, or wrap with QueryClientProvider.\",\n );\n }\n return createElement(ENSNodeInternalProvider, { config, children });\n }\n\n // If already inside a QueryClientProvider, just use that\n if (hasExistingQueryClient) {\n return createElement(ENSNodeInternalProvider, { config, children });\n }\n\n // Create our own QueryClient and QueryClientProvider\n const defaultQueryClient = useMemo(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n retry: 3,\n staleTime: 1000 * 60 * 5, // 5 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n },\n ...queryClientOptions,\n }),\n [queryClientOptions],\n );\n\n return createElement(\n QueryClientProvider,\n { client: defaultQueryClient },\n createElement(ENSNodeInternalProvider, { config, children }),\n );\n}\n\n/**\n * Helper function to create ENSNode configuration\n */\nexport function createConfig(options?: {\n url?: string | URL;\n}): ENSNodeConfig {\n const url = options?.url ? new URL(options.url) : ENSNodeClient.defaultOptions().url;\n\n return {\n client: {\n ...ENSNodeClient.defaultOptions(),\n url,\n },\n };\n}\n","import { createContext } from \"react\";\n\nimport type { ENSNodeConfig } from \"./types\";\n\n/**\n * React context for ENSNode configuration\n */\nexport const ENSNodeContext = createContext<ENSNodeConfig | undefined>(undefined);\n\n/**\n * Display name for debugging\n */\nENSNodeContext.displayName = \"ENSNodeContext\";\n","\"use client\";\n\nimport { useContext } from \"react\";\nimport { ENSNodeContext } from \"../context\";\nimport type { ENSNodeConfig } from \"../types\";\n\n/**\n * Hook to access the ENSNode configuration from context or parameters\n *\n * @param parameters - Optional config parameter that overrides context\n * @returns The ENSNode configuration\n * @throws Error if no config is available in context or parameters\n */\nexport function useENSNodeConfig<TConfig extends ENSNodeConfig = ENSNodeConfig>(\n config: TConfig | undefined,\n): TConfig {\n const contextConfig = useContext(ENSNodeContext);\n\n // Use provided config or fall back to context\n const resolvedConfig = config ?? contextConfig;\n\n if (!resolvedConfig) {\n throw new Error(\n \"useENSNodeConfig must be used within an ENSNodeProvider or you must pass a config parameter\",\n );\n }\n\n return resolvedConfig as TConfig;\n}\n","\"use client\";\n\nimport type { ResolverRecordsSelection } from \"@ensnode/ensnode-sdk\";\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport type { ConfigParameter, UseRecordsParameters } from \"../types\";\nimport { createRecordsQueryOptions } from \"../utils/query\";\nimport { useENSNodeConfig } from \"./useENSNodeConfig\";\n\n/**\n * Resolves records for an ENS name (Forward Resolution).\n *\n * @param parameters - Configuration for the ENS name resolution\n * @returns Query result with resolved records\n *\n * @example\n * ```typescript\n * import { useRecords } from \"@ensnode/ensnode-react\";\n *\n * function DisplayNameRecords() {\n * const { data, isLoading, error } = useRecords({\n * name: \"jesse.base.eth\",\n * selection: {\n * addresses: [60], // ETH CoinType\n * texts: [\"avatar\", \"com.twitter\"]\n * }\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h3>Resolved Records for vitalik.eth</h3>\n * {data.records.addresses && (\n * <p>ETH Address: {data.records.addresses[60]}</p>\n * )}\n * {data.records.texts && (\n * <div>\n * <p>Avatar: {data.records.texts.avatar}</p>\n * <p>Twitter: {data.records.texts[\"com.twitter\"]}</p>\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function useRecords<SELECTION extends ResolverRecordsSelection>(\n parameters: UseRecordsParameters<SELECTION> & ConfigParameter,\n) {\n const { config, query = {}, name, ...args } = parameters;\n const _config = useENSNodeConfig(config);\n\n const canEnable = name !== null;\n\n const queryOptions = canEnable\n ? createRecordsQueryOptions(_config, { ...args, name })\n : { enabled: false, queryKey: [\"disabled\"] as const };\n\n const options = {\n ...queryOptions,\n ...query,\n enabled: canEnable && (query.enabled ?? queryOptions.enabled),\n };\n\n return useQuery(options);\n}\n","\"use client\";\n\nimport {\n ENSNodeClient,\n IndexingStatusRequest,\n ResolvePrimaryNameRequest,\n ResolvePrimaryNamesRequest,\n ResolveRecordsRequest,\n ResolverRecordsSelection,\n} from \"@ensnode/ensnode-sdk\";\nimport type { ENSNodeConfig } from \"../types\";\n\n/**\n * Query keys for hooks. Simply keys by path and arguments.\n */\nexport const queryKeys = {\n base: (url: string) => [\"ensnode\", url] as const,\n\n resolve: (url: string) => [...queryKeys.base(url), \"resolve\"] as const,\n\n records: (url: string, args: ResolveRecordsRequest<any>) =>\n [...queryKeys.resolve(url), \"records\", args] as const,\n\n primaryName: (url: string, args: ResolvePrimaryNameRequest) =>\n [...queryKeys.resolve(url), \"primary-name\", args] as const,\n\n primaryNames: (url: string, args: ResolvePrimaryNamesRequest) =>\n [...queryKeys.resolve(url), \"primary-names\", args] as const,\n\n config: (url: string) => [...queryKeys.base(url), \"config\"] as const,\n\n indexingStatus: (url: string, args: IndexingStatusRequest) =>\n [...queryKeys.base(url), \"config\", args] as const,\n};\n\n/**\n * Creates query options for Records Resolution\n */\nexport function createRecordsQueryOptions<SELECTION extends ResolverRecordsSelection>(\n config: ENSNodeConfig,\n args: ResolveRecordsRequest<SELECTION>,\n) {\n return {\n enabled: true,\n queryKey: queryKeys.records(config.client.url.href, args),\n queryFn: async () => {\n const client = new ENSNodeClient(config.client);\n return client.resolveRecords(args.name, args.selection, args);\n },\n };\n}\n\n/**\n * Creates query options for Primary Name Resolution\n */\nexport function createPrimaryNameQueryOptions(\n config: ENSNodeConfig,\n args: ResolvePrimaryNameRequest,\n) {\n return {\n enabled: true,\n queryKey: queryKeys.primaryName(config.client.url.href, args),\n queryFn: async () => {\n const client = new ENSNodeClient(config.client);\n return client.resolvePrimaryName(args.address, args.chainId, args);\n },\n };\n}\n\n/**\n * Creates query options for Primary Name Resolution\n */\nexport function createPrimaryNamesQueryOptions(\n config: ENSNodeConfig,\n args: ResolvePrimaryNamesRequest,\n) {\n return {\n enabled: true,\n queryKey: queryKeys.primaryNames(config.client.url.href, args),\n queryFn: async () => {\n const client = new ENSNodeClient(config.client);\n return client.resolvePrimaryNames(args.address, args);\n },\n };\n}\n\n/**\n * Creates query options for ENSIndexer Config API\n */\nexport function createENSIndexerConfigQueryOptions(config: ENSNodeConfig) {\n return {\n enabled: true,\n queryKey: queryKeys.config(config.client.url.href),\n queryFn: async () => {\n const client = new ENSNodeClient(config.client);\n return client.config();\n },\n };\n}\n\n/**\n * Creates query options for ENSIndexer Indexing Status API\n */\nexport function createIndexingStatusQueryOptions(\n config: ENSNodeConfig,\n args: IndexingStatusRequest,\n) {\n return {\n enabled: true,\n queryKey: queryKeys.indexingStatus(config.client.url.href, args),\n queryFn: async () => {\n const client = new ENSNodeClient(config.client);\n return client.indexingStatus(args);\n },\n };\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { ConfigParameter, UsePrimaryNameParameters } from \"../types\";\nimport { createPrimaryNameQueryOptions } from \"../utils/query\";\nimport { useENSNodeConfig } from \"./useENSNodeConfig\";\n\n/**\n * Resolves the primary name of a specified address (Reverse Resolution).\n *\n * @param parameters - Configuration for the address resolution\n * @returns Query result with resolved primary name\n *\n * @example\n * ```typescript\n * import { usePrimaryName } from \"@ensnode/ensnode-react\";\n *\n * function DisplayPrimaryNameAndAvatar() {\n * const { data, isLoading, error } = usePrimaryName({\n * address: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n * chainId: 1, // Ethereum Mainnet\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h3>Primary Name (for Mainnet)</h3>\n * <p>{data.name ?? \"No Primary Name\"}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function usePrimaryName(parameters: UsePrimaryNameParameters & ConfigParameter) {\n const { config, query = {}, address, ...args } = parameters;\n const _config = useENSNodeConfig(config);\n\n const canEnable = address !== null;\n\n const queryOptions = canEnable\n ? createPrimaryNameQueryOptions(_config, { ...args, address })\n : { enabled: false, queryKey: [\"disabled\"] as const };\n\n const options = {\n ...queryOptions,\n ...query,\n enabled: canEnable && (query.enabled ?? queryOptions.enabled),\n };\n\n return useQuery(options);\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { ConfigParameter, UsePrimaryNamesParameters } from \"../types\";\nimport { createPrimaryNamesQueryOptions } from \"../utils/query\";\nimport { useENSNodeConfig } from \"./useENSNodeConfig\";\n\n/**\n * Resolves the primary names of a specified address across multiple chains.\n *\n * @param parameters - Configuration for the address resolution\n * @returns Query result with resolved primary names\n *\n * @example\n * ```typescript\n * import { usePrimaryNames } from \"@ensnode/ensnode-react\";\n *\n * function DisplayPrimaryNames() {\n * const { data, isLoading, error } = usePrimaryNames({\n * address: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * {Object.entries(data.names).map(([chainId, name]) => (\n * <div key={chainId}>\n * <h3>Primary Name (Chain Id: {chainId})</h3>\n * <p>{name}</p>\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function usePrimaryNames(parameters: UsePrimaryNamesParameters & ConfigParameter) {\n const { config, query = {}, address, ...args } = parameters;\n const _config = useENSNodeConfig(config);\n\n const canEnable = address !== null;\n\n const queryOptions = canEnable\n ? createPrimaryNamesQueryOptions(_config, { ...args, address })\n : { enabled: false, queryKey: [\"disabled\"] as const };\n\n const options = {\n ...queryOptions,\n ...query,\n enabled: canEnable && (query.enabled ?? queryOptions.enabled),\n };\n\n return useQuery(options);\n}\n","import { ConfigResponse } from \"@ensnode/ensnode-sdk\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { ConfigParameter, QueryParameter } from \"../types\";\nimport { createENSIndexerConfigQueryOptions } from \"../utils/query\";\nimport { useENSNodeConfig } from \"./useENSNodeConfig\";\n\ntype UseENSIndexerConfigParameters = QueryParameter<ConfigResponse>;\n\nexport function useENSIndexerConfig(\n parameters: ConfigParameter & UseENSIndexerConfigParameters = {},\n) {\n const { config, query = {} } = parameters;\n const _config = useENSNodeConfig(config);\n\n const queryOptions = createENSIndexerConfigQueryOptions(_config);\n\n const options = {\n ...queryOptions,\n ...query,\n enabled: query.enabled ?? queryOptions.enabled,\n };\n\n return useQuery(options);\n}\n","import { IndexingStatusRequest, IndexingStatusResponse } from \"@ensnode/ensnode-sdk\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { ConfigParameter, QueryParameter } from \"../types\";\nimport { createIndexingStatusQueryOptions } from \"../utils/query\";\nimport { useENSNodeConfig } from \"./useENSNodeConfig\";\n\ninterface UseIndexingStatusParameters\n extends IndexingStatusRequest,\n QueryParameter<IndexingStatusResponse> {}\n\nexport function useIndexingStatus(parameters: ConfigParameter & UseIndexingStatusParameters = {}) {\n const { config, query = {}, ...args } = parameters;\n const _config = useENSNodeConfig(config);\n\n const queryOptions = createIndexingStatusQueryOptions(_config, { ...args });\n\n const options = {\n ...queryOptions,\n ...query,\n enabled: query.enabled ?? queryOptions.enabled,\n };\n\n return useQuery(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,yBAA8B;AAC9B,yBAAiE;AACjE,IAAAA,gBAAuC;;;ACJvC,mBAA8B;AAOvB,IAAM,qBAAiB,4BAAyC,MAAS;AAKhF,eAAe,cAAc;;;ADc7B,SAAS,wBAAwB;AAAA,EAC/B;AAAA,EACA;AACF,GAGG;AAED,QAAM,qBAAiB,uBAAQ,MAAM,QAAQ,CAAC,MAAM,CAAC;AAErD,aAAO,6BAAc,eAAe,UAAU,EAAE,OAAO,eAAe,GAAG,QAAQ;AACnF;AAEO,SAAS,gBAAgB,YAA2D;AACzF,QAAM,EAAE,UAAU,QAAQ,aAAa,mBAAmB,IAA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AA,IACH,SAAS,MAAM,WAAW,aAAa;AAAA,EACzC;AAEA,aAAO,8BAAS,OAAO;AACzB;","names":["import_react","import_react","import_react_query","import_ensnode_sdk","import_react_query","import_react_query","import_react_query","import_react_query"]}
|