@ensnode/ensnode-react 0.35.0 → 1.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.
- package/README.md +7 -3
- package/dist/index.cjs +239 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +408 -82
- package/dist/index.d.ts +408 -82
- package/dist/index.js +252 -117
- package/dist/index.js.map +1 -1
- package/package.json +6 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { QueryObserverOptions, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { QueryObserverOptions, DefaultError, QueryKey, DefinedInitialDataOptions, QueryClient, DefinedUseQueryResult, UndefinedInitialDataOptions, UseQueryResult, UseQueryOptions } from '@tanstack/react-query';
|
|
3
3
|
export { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
import * as _ensnode_ensnode_sdk from '@ensnode/ensnode-sdk';
|
|
5
|
-
import { ClientOptions,
|
|
5
|
+
import { ClientOptions, ResolvePrimaryNameRequest, ResolvePrimaryNameResponse, ResolvePrimaryNamesRequest, ResolvePrimaryNamesResponse, ResolverRecordsSelection, ResolveRecordsRequest, ResolveRecordsResponse, ConfigResponse, IndexingStatusRequest, IndexingStatusResponse, RegistrarActionsRequest, RegistrarActionsResponse, UnresolvedIdentity, ENSNamespaceId, Identity } from '@ensnode/ensnode-sdk';
|
|
6
6
|
export { ResolverRecordsSelection } from '@ensnode/ensnode-sdk';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Configuration options for the ENSNode provider
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface ENSNodeSDKConfig {
|
|
13
13
|
/** The ENSNode API client configuration */
|
|
14
14
|
client: ClientOptions;
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ interface QueryParameter<TData = unknown, TError = Error> {
|
|
|
22
22
|
/**
|
|
23
23
|
* Configuration parameter for hooks that need access to config
|
|
24
24
|
*/
|
|
25
|
-
interface
|
|
25
|
+
interface WithSDKConfigParameter<TConfig extends ENSNodeSDKConfig = ENSNodeSDKConfig> {
|
|
26
26
|
config?: TConfig | undefined;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -50,88 +50,26 @@ interface UsePrimaryNamesParameters extends Omit<ResolvePrimaryNamesRequest, "ad
|
|
|
50
50
|
address: ResolvePrimaryNamesRequest["address"] | null;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
interface ENSNodeProviderProps {
|
|
54
|
-
/** ENSNode configuration */
|
|
55
|
-
config: ENSNodeConfig;
|
|
56
|
-
/**
|
|
57
|
-
* Optional QueryClient instance. If provided, you must wrap your app with QueryClientProvider yourself.
|
|
58
|
-
* If not provided, ENSNodeProvider will create and manage its own QueryClient internally.
|
|
59
|
-
*/
|
|
60
|
-
queryClient?: QueryClient;
|
|
61
|
-
/**
|
|
62
|
-
* Custom query client options when auto-creating a QueryClient.
|
|
63
|
-
* Only used when queryClient is not provided.
|
|
64
|
-
*/
|
|
65
|
-
queryClientOptions?: ConstructorParameters<typeof QueryClient>[0];
|
|
66
|
-
}
|
|
67
|
-
declare function ENSNodeProvider(parameters: React.PropsWithChildren<ENSNodeProviderProps>): react.FunctionComponentElement<{
|
|
68
|
-
children: React.ReactNode;
|
|
69
|
-
config: ENSNodeConfig;
|
|
70
|
-
}> | react.FunctionComponentElement<_tanstack_react_query.QueryClientProviderProps>;
|
|
71
|
-
/**
|
|
72
|
-
* Helper function to create ENSNode configuration
|
|
73
|
-
*/
|
|
74
|
-
declare function createConfig(options?: {
|
|
75
|
-
url?: string | URL;
|
|
76
|
-
}): ENSNodeConfig;
|
|
77
|
-
|
|
78
53
|
/**
|
|
79
54
|
* React context for ENSNode configuration
|
|
80
55
|
*/
|
|
81
|
-
declare const ENSNodeContext: react.Context<
|
|
56
|
+
declare const ENSNodeContext: react.Context<ENSNodeSDKConfig | undefined>;
|
|
57
|
+
|
|
58
|
+
type UseENSNodeConfigParameters = QueryParameter<ConfigResponse>;
|
|
59
|
+
declare function useENSNodeConfig(parameters?: WithSDKConfigParameter & UseENSNodeConfigParameters): _tanstack_react_query.UseQueryResult<_ensnode_ensnode_sdk.ENSApiPublicConfig, Error>;
|
|
82
60
|
|
|
83
61
|
/**
|
|
84
|
-
* Hook to access the
|
|
62
|
+
* Hook to access the ENSNodeSDKConfig from context or parameters.
|
|
85
63
|
*
|
|
86
64
|
* @param parameters - Optional config parameter that overrides context
|
|
87
65
|
* @returns The ENSNode configuration
|
|
88
66
|
* @throws Error if no config is available in context or parameters
|
|
89
67
|
*/
|
|
90
|
-
declare function
|
|
68
|
+
declare function useENSNodeSDKConfig<TConfig extends ENSNodeSDKConfig = ENSNodeSDKConfig>(config: TConfig | undefined): TConfig;
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* The returned `name` field, if set, is guaranteed to be a normalized name.
|
|
96
|
-
* If the name record returned by the resolver is not normalized, `null` is returned as if no name record was set.
|
|
97
|
-
*
|
|
98
|
-
* @param parameters - Configuration for the ENS name resolution
|
|
99
|
-
* @returns Query result with resolved records
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* import { useRecords } from "@ensnode/ensnode-react";
|
|
104
|
-
*
|
|
105
|
-
* function DisplayNameRecords() {
|
|
106
|
-
* const { data, isLoading, error } = useRecords({
|
|
107
|
-
* name: "jesse.base.eth",
|
|
108
|
-
* selection: {
|
|
109
|
-
* addresses: [60], // ETH CoinType
|
|
110
|
-
* texts: ["avatar", "com.twitter"]
|
|
111
|
-
* }
|
|
112
|
-
* });
|
|
113
|
-
*
|
|
114
|
-
* if (isLoading) return <div>Loading...</div>;
|
|
115
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
116
|
-
*
|
|
117
|
-
* return (
|
|
118
|
-
* <div>
|
|
119
|
-
* <h3>Resolved Records for vitalik.eth</h3>
|
|
120
|
-
* {data.records.addresses && (
|
|
121
|
-
* <p>ETH Address: {data.records.addresses[60]}</p>
|
|
122
|
-
* )}
|
|
123
|
-
* {data.records.texts && (
|
|
124
|
-
* <div>
|
|
125
|
-
* <p>Avatar: {data.records.texts.avatar}</p>
|
|
126
|
-
* <p>Twitter: {data.records.texts["com.twitter"]}</p>
|
|
127
|
-
* </div>
|
|
128
|
-
* )}
|
|
129
|
-
* </div>
|
|
130
|
-
* );
|
|
131
|
-
* }
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
declare function useRecords<SELECTION extends ResolverRecordsSelection>(parameters: UseRecordsParameters<SELECTION> & ConfigParameter): _tanstack_react_query.UseQueryResult<_ensnode_ensnode_sdk.ResolveRecordsResponse<SELECTION>, Error>;
|
|
70
|
+
interface UseIndexingStatusParameters extends IndexingStatusRequest, QueryParameter<IndexingStatusResponse> {
|
|
71
|
+
}
|
|
72
|
+
declare function useIndexingStatus(parameters?: WithSDKConfigParameter & UseIndexingStatusParameters): _tanstack_react_query.UseQueryResult<IndexingStatusResponse, Error>;
|
|
135
73
|
|
|
136
74
|
/**
|
|
137
75
|
* Resolves the primary name of a specified address (Reverse Resolution).
|
|
@@ -150,6 +88,7 @@ declare function useRecords<SELECTION extends ResolverRecordsSelection>(paramete
|
|
|
150
88
|
* const { data, isLoading, error } = usePrimaryName({
|
|
151
89
|
* address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
|
|
152
90
|
* chainId: 1, // Ethereum Mainnet
|
|
91
|
+
* accelerate: true, // Attempt Protocol Acceleration
|
|
153
92
|
* });
|
|
154
93
|
*
|
|
155
94
|
* if (isLoading) return <div>Loading...</div>;
|
|
@@ -164,7 +103,7 @@ declare function useRecords<SELECTION extends ResolverRecordsSelection>(paramete
|
|
|
164
103
|
* }
|
|
165
104
|
* ```
|
|
166
105
|
*/
|
|
167
|
-
declare function usePrimaryName(parameters: UsePrimaryNameParameters &
|
|
106
|
+
declare function usePrimaryName(parameters: UsePrimaryNameParameters & WithSDKConfigParameter): _tanstack_react_query.UseQueryResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>;
|
|
168
107
|
|
|
169
108
|
/**
|
|
170
109
|
* Resolves the primary names of a specified address across multiple chains.
|
|
@@ -200,13 +139,400 @@ declare function usePrimaryName(parameters: UsePrimaryNameParameters & ConfigPar
|
|
|
200
139
|
* }
|
|
201
140
|
* ```
|
|
202
141
|
*/
|
|
203
|
-
declare function usePrimaryNames(parameters: UsePrimaryNamesParameters &
|
|
142
|
+
declare function usePrimaryNames(parameters: UsePrimaryNamesParameters & WithSDKConfigParameter): _tanstack_react_query.UseQueryResult<_ensnode_ensnode_sdk.ResolvePrimaryNamesResponse, Error>;
|
|
204
143
|
|
|
205
|
-
|
|
206
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Resolves records for an ENS name (Forward Resolution).
|
|
146
|
+
*
|
|
147
|
+
* The returned `name` field, if set, is guaranteed to be a normalized name.
|
|
148
|
+
* If the name record returned by the resolver is not normalized, `null` is returned as if no name record was set.
|
|
149
|
+
*
|
|
150
|
+
* @param parameters - Configuration for the ENS name resolution
|
|
151
|
+
* @returns Query result with resolved records
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* import { useRecords } from "@ensnode/ensnode-react";
|
|
156
|
+
*
|
|
157
|
+
* function DisplayNameRecords() {
|
|
158
|
+
* const { data, isLoading, error } = useRecords({
|
|
159
|
+
* name: "jesse.base.eth",
|
|
160
|
+
* selection: {
|
|
161
|
+
* addresses: [60], // ETH CoinType
|
|
162
|
+
* texts: ["avatar", "com.twitter"]
|
|
163
|
+
* }
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
167
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
168
|
+
*
|
|
169
|
+
* return (
|
|
170
|
+
* <div>
|
|
171
|
+
* <h3>Resolved Records for vitalik.eth</h3>
|
|
172
|
+
* {data.records.addresses && (
|
|
173
|
+
* <p>ETH Address: {data.records.addresses[60]}</p>
|
|
174
|
+
* )}
|
|
175
|
+
* {data.records.texts && (
|
|
176
|
+
* <div>
|
|
177
|
+
* <p>Avatar: {data.records.texts.avatar}</p>
|
|
178
|
+
* <p>Twitter: {data.records.texts["com.twitter"]}</p>
|
|
179
|
+
* </div>
|
|
180
|
+
* )}
|
|
181
|
+
* </div>
|
|
182
|
+
* );
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function useRecords<SELECTION extends ResolverRecordsSelection>(parameters: UseRecordsParameters<SELECTION> & WithSDKConfigParameter): _tanstack_react_query.UseQueryResult<_ensnode_ensnode_sdk.ResolveRecordsResponse<SELECTION>, Error>;
|
|
207
187
|
|
|
208
|
-
interface
|
|
188
|
+
interface UseRegistrarActionsParameters extends RegistrarActionsRequest, QueryParameter<RegistrarActionsResponse> {
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Use Registrar Actions hook
|
|
192
|
+
*
|
|
193
|
+
* Query ENSNode Registrar Actions API.
|
|
194
|
+
*/
|
|
195
|
+
declare function useRegistrarActions(parameters?: WithSDKConfigParameter & UseRegistrarActionsParameters): _tanstack_react_query.UseQueryResult<RegistrarActionsResponse, Error>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Parameters for the useResolvedIdentity hook.
|
|
199
|
+
*/
|
|
200
|
+
interface UseResolvedIdentityParameters {
|
|
201
|
+
identity: UnresolvedIdentity;
|
|
202
|
+
namespaceId: ENSNamespaceId;
|
|
203
|
+
accelerate?: boolean;
|
|
209
204
|
}
|
|
210
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Hook to perform ENSIP-19 primary name resolution to resolve an
|
|
207
|
+
* {@link UnresolvedIdentity} into a {@link ResolvedIdentity}.
|
|
208
|
+
*
|
|
209
|
+
* @param parameters - Configuration object for the hook
|
|
210
|
+
* @param parameters.identity - An {@link UnresolvedIdentity} containing the {@link DefaultableChainId}
|
|
211
|
+
* and {@link Address} to resolve.
|
|
212
|
+
* @param parameters.namespaceId - The {@link ENSNamespaceId} that `identity.chainId` should be interpreted
|
|
213
|
+
* through (via {@link getResolvePrimaryNameChainIdParam}) to determine the literal
|
|
214
|
+
* chainId that should be used for ENSIP-19 primary name resolution.
|
|
215
|
+
* @param parameters.accelerate - Whether to attempt Protocol Acceleration (default: false)
|
|
216
|
+
* when resolving the primary name.
|
|
217
|
+
*
|
|
218
|
+
* @returns An object containing:
|
|
219
|
+
* - `identity`: An {@link Identity} with one of four possible {@link ResolutionStatusIds}:
|
|
220
|
+
* - {@link ResolutionStatusIds.Unresolved}: While the query is pending (loading state).
|
|
221
|
+
* - {@link ResolutionStatusIds.Unknown}: If an error occurs during resolution.
|
|
222
|
+
* - {@link ResolutionStatusIds.Unnamed}: If the resolution found no primary name.
|
|
223
|
+
* - {@link ResolutionStatusIds.Named}: If a primary name is successfully resolved.
|
|
224
|
+
* - All other properties from the underlying {@link usePrimaryName} query (e.g., `isLoading`, `error`, `refetch`, etc.)
|
|
225
|
+
*/
|
|
226
|
+
declare function useResolvedIdentity(parameters: UseResolvedIdentityParameters): {
|
|
227
|
+
identity: Identity;
|
|
228
|
+
error: Error;
|
|
229
|
+
isError: true;
|
|
230
|
+
isPending: false;
|
|
231
|
+
isLoading: false;
|
|
232
|
+
isLoadingError: false;
|
|
233
|
+
isRefetchError: true;
|
|
234
|
+
isSuccess: false;
|
|
235
|
+
isPlaceholderData: false;
|
|
236
|
+
dataUpdatedAt: number;
|
|
237
|
+
errorUpdatedAt: number;
|
|
238
|
+
failureCount: number;
|
|
239
|
+
failureReason: Error | null;
|
|
240
|
+
errorUpdateCount: number;
|
|
241
|
+
isFetched: boolean;
|
|
242
|
+
isFetchedAfterMount: boolean;
|
|
243
|
+
isFetching: boolean;
|
|
244
|
+
isInitialLoading: boolean;
|
|
245
|
+
isPaused: boolean;
|
|
246
|
+
isRefetching: boolean;
|
|
247
|
+
isStale: boolean;
|
|
248
|
+
isEnabled: boolean;
|
|
249
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
250
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
251
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
252
|
+
} | {
|
|
253
|
+
identity: Identity;
|
|
254
|
+
error: null;
|
|
255
|
+
isError: false;
|
|
256
|
+
isPending: false;
|
|
257
|
+
isLoading: false;
|
|
258
|
+
isLoadingError: false;
|
|
259
|
+
isRefetchError: false;
|
|
260
|
+
isSuccess: true;
|
|
261
|
+
isPlaceholderData: false;
|
|
262
|
+
dataUpdatedAt: number;
|
|
263
|
+
errorUpdatedAt: number;
|
|
264
|
+
failureCount: number;
|
|
265
|
+
failureReason: Error | null;
|
|
266
|
+
errorUpdateCount: number;
|
|
267
|
+
isFetched: boolean;
|
|
268
|
+
isFetchedAfterMount: boolean;
|
|
269
|
+
isFetching: boolean;
|
|
270
|
+
isInitialLoading: boolean;
|
|
271
|
+
isPaused: boolean;
|
|
272
|
+
isRefetching: boolean;
|
|
273
|
+
isStale: boolean;
|
|
274
|
+
isEnabled: boolean;
|
|
275
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
276
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
277
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
278
|
+
} | {
|
|
279
|
+
identity: Identity;
|
|
280
|
+
error: Error;
|
|
281
|
+
isError: true;
|
|
282
|
+
isPending: false;
|
|
283
|
+
isLoading: false;
|
|
284
|
+
isLoadingError: true;
|
|
285
|
+
isRefetchError: false;
|
|
286
|
+
isSuccess: false;
|
|
287
|
+
isPlaceholderData: false;
|
|
288
|
+
dataUpdatedAt: number;
|
|
289
|
+
errorUpdatedAt: number;
|
|
290
|
+
failureCount: number;
|
|
291
|
+
failureReason: Error | null;
|
|
292
|
+
errorUpdateCount: number;
|
|
293
|
+
isFetched: boolean;
|
|
294
|
+
isFetchedAfterMount: boolean;
|
|
295
|
+
isFetching: boolean;
|
|
296
|
+
isInitialLoading: boolean;
|
|
297
|
+
isPaused: boolean;
|
|
298
|
+
isRefetching: boolean;
|
|
299
|
+
isStale: boolean;
|
|
300
|
+
isEnabled: boolean;
|
|
301
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
302
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
303
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
304
|
+
} | {
|
|
305
|
+
identity: Identity;
|
|
306
|
+
error: null;
|
|
307
|
+
isError: false;
|
|
308
|
+
isPending: true;
|
|
309
|
+
isLoading: true;
|
|
310
|
+
isLoadingError: false;
|
|
311
|
+
isRefetchError: false;
|
|
312
|
+
isSuccess: false;
|
|
313
|
+
isPlaceholderData: false;
|
|
314
|
+
dataUpdatedAt: number;
|
|
315
|
+
errorUpdatedAt: number;
|
|
316
|
+
failureCount: number;
|
|
317
|
+
failureReason: Error | null;
|
|
318
|
+
errorUpdateCount: number;
|
|
319
|
+
isFetched: boolean;
|
|
320
|
+
isFetchedAfterMount: boolean;
|
|
321
|
+
isFetching: boolean;
|
|
322
|
+
isInitialLoading: boolean;
|
|
323
|
+
isPaused: boolean;
|
|
324
|
+
isRefetching: boolean;
|
|
325
|
+
isStale: boolean;
|
|
326
|
+
isEnabled: boolean;
|
|
327
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
328
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
329
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
330
|
+
} | {
|
|
331
|
+
identity: Identity;
|
|
332
|
+
error: null;
|
|
333
|
+
isError: false;
|
|
334
|
+
isPending: true;
|
|
335
|
+
isLoadingError: false;
|
|
336
|
+
isRefetchError: false;
|
|
337
|
+
isSuccess: false;
|
|
338
|
+
isPlaceholderData: false;
|
|
339
|
+
dataUpdatedAt: number;
|
|
340
|
+
errorUpdatedAt: number;
|
|
341
|
+
failureCount: number;
|
|
342
|
+
failureReason: Error | null;
|
|
343
|
+
errorUpdateCount: number;
|
|
344
|
+
isFetched: boolean;
|
|
345
|
+
isFetchedAfterMount: boolean;
|
|
346
|
+
isFetching: boolean;
|
|
347
|
+
isLoading: boolean;
|
|
348
|
+
isInitialLoading: boolean;
|
|
349
|
+
isPaused: boolean;
|
|
350
|
+
isRefetching: boolean;
|
|
351
|
+
isStale: boolean;
|
|
352
|
+
isEnabled: boolean;
|
|
353
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
354
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
355
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
356
|
+
} | {
|
|
357
|
+
identity: Identity;
|
|
358
|
+
isError: false;
|
|
359
|
+
error: null;
|
|
360
|
+
isPending: false;
|
|
361
|
+
isLoading: false;
|
|
362
|
+
isLoadingError: false;
|
|
363
|
+
isRefetchError: false;
|
|
364
|
+
isSuccess: true;
|
|
365
|
+
isPlaceholderData: true;
|
|
366
|
+
dataUpdatedAt: number;
|
|
367
|
+
errorUpdatedAt: number;
|
|
368
|
+
failureCount: number;
|
|
369
|
+
failureReason: Error | null;
|
|
370
|
+
errorUpdateCount: number;
|
|
371
|
+
isFetched: boolean;
|
|
372
|
+
isFetchedAfterMount: boolean;
|
|
373
|
+
isFetching: boolean;
|
|
374
|
+
isInitialLoading: boolean;
|
|
375
|
+
isPaused: boolean;
|
|
376
|
+
isRefetching: boolean;
|
|
377
|
+
isStale: boolean;
|
|
378
|
+
isEnabled: boolean;
|
|
379
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse, Error>>;
|
|
380
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
381
|
+
promise: Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Use Stale-While-Revalidate Query
|
|
386
|
+
*
|
|
387
|
+
* This hooks is a proxy for {@link useQuery} with addition of the following
|
|
388
|
+
* semantics:
|
|
389
|
+
* - if the query has been resolved successfully just once,
|
|
390
|
+
* the query result will always be success with data being the previously
|
|
391
|
+
* cached result,
|
|
392
|
+
* - the cached result can never go stale, or be garbage collected
|
|
393
|
+
* - the cached result can be only overridden by the current result when
|
|
394
|
+
* the query is successfully re-fetched (in other words,
|
|
395
|
+
* the `options.queryFn` returns a resolved promise).
|
|
396
|
+
*
|
|
397
|
+
* Please note how there can be any number of failed queries before one
|
|
398
|
+
* succeeds. In such case, no successful result has ever been cached and
|
|
399
|
+
* the query fails (`isError: true`, `error` is available) until
|
|
400
|
+
* the first successful resolution (`isSuccess: true`, `data` is available).
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* const swrQuery = useSwrQuery({
|
|
405
|
+
* queryKey: ['data'],
|
|
406
|
+
* queryFn: fetchData,
|
|
407
|
+
* });
|
|
408
|
+
*
|
|
409
|
+
* if (swrQuery.isPending) {
|
|
410
|
+
* // Show loading state while there's no cached successful result and
|
|
411
|
+
* // no query attempt was finished yet.
|
|
412
|
+
* return <>Loading...</>;
|
|
413
|
+
* }
|
|
414
|
+
*
|
|
415
|
+
* if (swrQuery.isError) {
|
|
416
|
+
* // Show error state when query attempt fails and
|
|
417
|
+
* // no cached successful result is available.
|
|
418
|
+
* return <>Error: {swrQuery.error.message}</>;
|
|
419
|
+
* }
|
|
420
|
+
*
|
|
421
|
+
* // Otherwise, show data when the cached successful result is available.
|
|
422
|
+
* return <>Data: {JSON.stringify(swrQuery.data)}</>;
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
declare function useSwrQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): DefinedUseQueryResult<NoInfer<TData>, TError>;
|
|
426
|
+
declare function useSwrQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<NoInfer<TData>, TError>;
|
|
427
|
+
declare function useSwrQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<NoInfer<TData>, TError>;
|
|
428
|
+
|
|
429
|
+
interface ENSNodeProviderProps {
|
|
430
|
+
/** ENSNode configuration */
|
|
431
|
+
config: ENSNodeSDKConfig;
|
|
432
|
+
/**
|
|
433
|
+
* Optional QueryClient instance. If provided, you must wrap your app with QueryClientProvider yourself.
|
|
434
|
+
* If not provided, ENSNodeProvider will create and manage its own QueryClient internally.
|
|
435
|
+
*/
|
|
436
|
+
queryClient?: QueryClient;
|
|
437
|
+
/**
|
|
438
|
+
* Custom query client options when auto-creating a QueryClient.
|
|
439
|
+
* Only used when queryClient is not provided.
|
|
440
|
+
*/
|
|
441
|
+
queryClientOptions?: ConstructorParameters<typeof QueryClient>[0];
|
|
442
|
+
}
|
|
443
|
+
declare function ENSNodeProvider(parameters: React.PropsWithChildren<ENSNodeProviderProps>): react.FunctionComponentElement<{
|
|
444
|
+
children?: React.ReactNode;
|
|
445
|
+
config: ENSNodeSDKConfig;
|
|
446
|
+
}> | react.FunctionComponentElement<_tanstack_react_query.QueryClientProviderProps>;
|
|
447
|
+
/**
|
|
448
|
+
* Helper function to create ENSNode configuration
|
|
449
|
+
*/
|
|
450
|
+
declare function createConfig(options?: {
|
|
451
|
+
url?: string | URL;
|
|
452
|
+
}): ENSNodeSDKConfig;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Immutable query options for data that is assumed to be immutable and should only be fetched once per full page refresh per unique key.
|
|
456
|
+
* Similar to SWR's immutable: true API.
|
|
457
|
+
*
|
|
458
|
+
* Use this for data that is assumed not to change (e.g., records for a specific name) until the next full page refresh.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```tsx
|
|
462
|
+
* useRecords({
|
|
463
|
+
* name: "vitalik.eth",
|
|
464
|
+
* selection: { texts: ["avatar"] },
|
|
465
|
+
* query: ASSUME_IMMUTABLE_QUERY
|
|
466
|
+
* })
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
declare const ASSUME_IMMUTABLE_QUERY: {
|
|
470
|
+
readonly staleTime: number;
|
|
471
|
+
readonly gcTime: number;
|
|
472
|
+
readonly refetchOnWindowFocus: false;
|
|
473
|
+
readonly refetchOnReconnect: false;
|
|
474
|
+
readonly refetchOnMount: false;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Query keys for hooks. Simply keys by path and arguments.
|
|
478
|
+
*/
|
|
479
|
+
declare const queryKeys: {
|
|
480
|
+
base: (url: string) => readonly ["ensnode", string];
|
|
481
|
+
resolve: (url: string) => readonly ["ensnode", string, "resolve"];
|
|
482
|
+
records: (url: string, args: ResolveRecordsRequest<any>) => readonly ["ensnode", string, "resolve", "records", ResolveRecordsRequest<any>];
|
|
483
|
+
primaryName: (url: string, args: ResolvePrimaryNameRequest) => readonly ["ensnode", string, "resolve", "primary-name", ResolvePrimaryNameRequest];
|
|
484
|
+
primaryNames: (url: string, args: ResolvePrimaryNamesRequest) => readonly ["ensnode", string, "resolve", "primary-names", ResolvePrimaryNamesRequest];
|
|
485
|
+
config: (url: string) => readonly ["ensnode", string, "config"];
|
|
486
|
+
indexingStatus: (url: string) => readonly ["ensnode", string, "indexing-status"];
|
|
487
|
+
registrarActions: (url: string, args: RegistrarActionsRequest) => readonly ["ensnode", string, "registrar-actions", RegistrarActionsRequest];
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Creates query options for Records Resolution
|
|
491
|
+
*/
|
|
492
|
+
declare function createRecordsQueryOptions<SELECTION extends ResolverRecordsSelection>(config: ENSNodeSDKConfig, args: ResolveRecordsRequest<SELECTION>): {
|
|
493
|
+
enabled: boolean;
|
|
494
|
+
queryKey: readonly ["ensnode", string, "resolve", "records", ResolveRecordsRequest<any>];
|
|
495
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.ResolveRecordsResponse<SELECTION>>;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Creates query options for Primary Name Resolution
|
|
499
|
+
*/
|
|
500
|
+
declare function createPrimaryNameQueryOptions(config: ENSNodeSDKConfig, args: ResolvePrimaryNameRequest): {
|
|
501
|
+
enabled: boolean;
|
|
502
|
+
queryKey: readonly ["ensnode", string, "resolve", "primary-name", ResolvePrimaryNameRequest];
|
|
503
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.ResolvePrimaryNameResponse>;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Creates query options for Primary Name Resolution
|
|
507
|
+
*/
|
|
508
|
+
declare function createPrimaryNamesQueryOptions(config: ENSNodeSDKConfig, args: ResolvePrimaryNamesRequest): {
|
|
509
|
+
enabled: boolean;
|
|
510
|
+
queryKey: readonly ["ensnode", string, "resolve", "primary-names", ResolvePrimaryNamesRequest];
|
|
511
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.ResolvePrimaryNamesResponse>;
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Creates query options for ENSNode Config API
|
|
515
|
+
*/
|
|
516
|
+
declare function createConfigQueryOptions(config: ENSNodeSDKConfig): {
|
|
517
|
+
enabled: boolean;
|
|
518
|
+
queryKey: readonly ["ensnode", string, "config"];
|
|
519
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.ENSApiPublicConfig>;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Creates query options for ENSNode Indexing Status API
|
|
523
|
+
*/
|
|
524
|
+
declare function createIndexingStatusQueryOptions(config: ENSNodeSDKConfig): {
|
|
525
|
+
enabled: boolean;
|
|
526
|
+
queryKey: readonly ["ensnode", string, "indexing-status"];
|
|
527
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.IndexingStatusResponse>;
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Creates query options for ENSNode Registrar Actions API
|
|
531
|
+
*/
|
|
532
|
+
declare function createRegistrarActionsQueryOptions(config: ENSNodeSDKConfig, args: RegistrarActionsRequest): {
|
|
533
|
+
enabled: boolean;
|
|
534
|
+
queryKey: readonly ["ensnode", string, "registrar-actions", RegistrarActionsRequest];
|
|
535
|
+
queryFn: () => Promise<_ensnode_ensnode_sdk.RegistrarActionsResponse>;
|
|
536
|
+
};
|
|
211
537
|
|
|
212
|
-
export {
|
|
538
|
+
export { ASSUME_IMMUTABLE_QUERY, ENSNodeContext, ENSNodeProvider, type ENSNodeProviderProps, type ENSNodeSDKConfig, type QueryParameter, type UsePrimaryNameParameters, type UsePrimaryNamesParameters, type UseRecordsParameters, type UseResolvedIdentityParameters, type WithSDKConfigParameter, createConfig, createConfigQueryOptions, createIndexingStatusQueryOptions, createPrimaryNameQueryOptions, createPrimaryNamesQueryOptions, createRecordsQueryOptions, createRegistrarActionsQueryOptions, queryKeys, useENSNodeConfig, useENSNodeSDKConfig, useIndexingStatus, usePrimaryName, usePrimaryNames, useRecords, useRegistrarActions, useResolvedIdentity, useSwrQuery };
|