web3bio-profile-kit 0.1.3 → 0.1.4
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/dist/hooks/index.cjs +21 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useBaseQuery.cjs +129 -0
- package/dist/{types/hooks → hooks}/useBaseQuery.d.ts +1 -2
- package/dist/hooks/useBaseQuery.js +127 -0
- package/dist/hooks/useBatchNS.cjs +25 -0
- package/dist/{types/hooks → hooks}/useBatchNS.d.ts +1 -1
- package/dist/hooks/useBatchNS.js +23 -0
- package/dist/hooks/useBatchProfile.cjs +25 -0
- package/dist/{types/hooks → hooks}/useBatchProfile.d.ts +1 -1
- package/dist/hooks/useBatchProfile.js +23 -0
- package/dist/hooks/useDomain.cjs +28 -0
- package/dist/{types/hooks → hooks}/useDomain.d.ts +1 -1
- package/dist/hooks/useDomain.js +26 -0
- package/dist/hooks/useNS.cjs +28 -0
- package/dist/{types/hooks → hooks}/useNS.d.ts +1 -1
- package/dist/hooks/useNS.js +26 -0
- package/dist/hooks/useProfile.cjs +28 -0
- package/dist/{types/hooks → hooks}/useProfile.d.ts +1 -1
- package/dist/hooks/useProfile.js +26 -0
- package/dist/hooks/useUniversalNS.cjs +28 -0
- package/dist/{types/hooks → hooks}/useUniversalNS.d.ts +1 -1
- package/dist/hooks/useUniversalNS.js +26 -0
- package/dist/hooks/useUniversalProfile.cjs +28 -0
- package/dist/{types/hooks → hooks}/useUniversalProfile.d.ts +1 -1
- package/dist/hooks/useUniversalProfile.js +26 -0
- package/dist/index.cjs +71 -0
- package/dist/index.d.ts +3 -441
- package/dist/index.js +18 -2038
- package/dist/types/cointype.cjs +29 -0
- package/dist/types/cointype.d.ts +26 -0
- package/dist/types/cointype.js +29 -0
- package/dist/types/hook.cjs +38 -0
- package/dist/types/hook.d.ts +195 -0
- package/dist/types/hook.js +38 -0
- package/dist/types/index.cjs +38 -0
- package/dist/types/index.d.ts +5 -7
- package/dist/types/index.js +5 -0
- package/dist/types/network.cjs +41 -0
- package/dist/types/{utils/network.d.ts → network.d.ts} +9 -4
- package/dist/types/network.js +41 -0
- package/dist/types/platform.cjs +110 -0
- package/dist/types/{utils/platform.d.ts → platform.d.ts} +19 -5
- package/dist/types/platform.js +110 -0
- package/dist/types/source.cjs +44 -0
- package/dist/types/{utils/source.d.ts → source.d.ts} +11 -3
- package/dist/types/source.js +44 -0
- package/dist/utils/helpers.cjs +119 -0
- package/dist/{types/utils → utils}/helpers.d.ts +4 -3
- package/dist/utils/helpers.js +112 -0
- package/dist/utils/index.cjs +27 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/network.cjs +355 -0
- package/dist/utils/network.d.ts +4 -0
- package/dist/utils/network.js +353 -0
- package/dist/utils/platform.cjs +983 -0
- package/dist/utils/platform.d.ts +18 -0
- package/dist/utils/platform.js +979 -0
- package/dist/utils/regex.cjs +34 -0
- package/dist/utils/regex.d.ts +30 -0
- package/dist/utils/regex.js +32 -0
- package/dist/utils/source.cjs +144 -0
- package/dist/utils/source.d.ts +2 -0
- package/dist/utils/source.js +142 -0
- package/package.json +32 -12
- package/dist/index.esm.js +0 -2023
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/utils/cointype.d.ts +0 -22
- package/dist/types/utils/constants.d.ts +0 -36
- package/dist/types/utils/types.d.ts +0 -74
- /package/dist/{types/hooks → hooks}/index.d.ts +0 -0
- /package/dist/{types/setupTests.d.ts → setupTests.d.ts} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useProfile = require('./useProfile.cjs');
|
|
4
|
+
var useNS = require('./useNS.cjs');
|
|
5
|
+
var useUniversalProfile = require('./useUniversalProfile.cjs');
|
|
6
|
+
var useUniversalNS = require('./useUniversalNS.cjs');
|
|
7
|
+
var useBatchProfile = require('./useBatchProfile.cjs');
|
|
8
|
+
var useBatchNS = require('./useBatchNS.cjs');
|
|
9
|
+
var useDomain = require('./useDomain.cjs');
|
|
10
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.useProfile = useProfile.useProfile;
|
|
15
|
+
exports.useNS = useNS.useNS;
|
|
16
|
+
exports.useUniversalProfile = useUniversalProfile.useUniversalProfile;
|
|
17
|
+
exports.useUniversalNS = useUniversalNS.useUniversalNS;
|
|
18
|
+
exports.useBatchProfile = useBatchProfile.useBatchProfile;
|
|
19
|
+
exports.useBatchNS = useBatchNS.useBatchNS;
|
|
20
|
+
exports.useDomain = useDomain.useDomain;
|
|
21
|
+
exports.useBaseQuery = useBaseQuery.useBaseQuery;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useProfile } from './useProfile.js';
|
|
2
|
+
export { useNS } from './useNS.js';
|
|
3
|
+
export { useUniversalProfile } from './useUniversalProfile.js';
|
|
4
|
+
export { useUniversalNS } from './useUniversalNS.js';
|
|
5
|
+
export { useBatchProfile } from './useBatchProfile.js';
|
|
6
|
+
export { useBatchNS } from './useBatchNS.js';
|
|
7
|
+
export { useDomain } from './useDomain.js';
|
|
8
|
+
export { useBaseQuery } from './useBaseQuery.js';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var helpers = require('../utils/helpers.cjs');
|
|
10
|
+
require('../utils/network.cjs');
|
|
11
|
+
require('../utils/platform.cjs');
|
|
12
|
+
require('../utils/source.cjs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Constructs the API URL based on query parameters
|
|
16
|
+
*/
|
|
17
|
+
const buildApiUrl = (identity, endpoint, universal) => {
|
|
18
|
+
// Handle batch requests
|
|
19
|
+
if (Array.isArray(identity)) {
|
|
20
|
+
return `${helpers.API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;
|
|
21
|
+
}
|
|
22
|
+
// Handle universal queries
|
|
23
|
+
if (universal) {
|
|
24
|
+
return `${helpers.API_ENDPOINT}/${endpoint}/${identity}`;
|
|
25
|
+
}
|
|
26
|
+
// Handle platform-specific queries
|
|
27
|
+
const resolvedId = helpers.resolveIdentity(identity);
|
|
28
|
+
if (!resolvedId)
|
|
29
|
+
return null;
|
|
30
|
+
// Domain endpoint uses resolved ID directly
|
|
31
|
+
if (endpoint === hook.QueryEndpoint.DOMAIN) {
|
|
32
|
+
return `${helpers.API_ENDPOINT}/${endpoint}/${resolvedId}`;
|
|
33
|
+
}
|
|
34
|
+
// Other endpoints need platform/handle split
|
|
35
|
+
const [platform, handle] = resolvedId.split(",");
|
|
36
|
+
return `${helpers.API_ENDPOINT}/${endpoint}/${platform}/${handle}`;
|
|
37
|
+
};
|
|
38
|
+
// Generate a stable cache key for this request
|
|
39
|
+
const getCacheKey = (identity, endpoint, universal) => {
|
|
40
|
+
return JSON.stringify({
|
|
41
|
+
identity,
|
|
42
|
+
endpoint,
|
|
43
|
+
universal,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
// Create a cache to store results across component instances and re-renders
|
|
47
|
+
const globalRequestCache = new Map();
|
|
48
|
+
/**
|
|
49
|
+
* Core hook for querying Web3.bio Profile API
|
|
50
|
+
*/
|
|
51
|
+
function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
52
|
+
const { apiKey: userApiKey, enabled = true } = options;
|
|
53
|
+
const apiKey = helpers.getApiKey(userApiKey);
|
|
54
|
+
const [data, setData] = react.useState(() => {
|
|
55
|
+
// Initialize state from cache if available
|
|
56
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
57
|
+
return globalRequestCache.get(cacheKey) || null;
|
|
58
|
+
});
|
|
59
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
60
|
+
const [error, setError] = react.useState(null);
|
|
61
|
+
// Use ref to track in-flight requests and prevent race conditions
|
|
62
|
+
const requestIdRef = react.useRef(0);
|
|
63
|
+
const prevParamsRef = react.useRef("");
|
|
64
|
+
// Current request parameters as a string for comparison
|
|
65
|
+
const currentParams = JSON.stringify({
|
|
66
|
+
identity,
|
|
67
|
+
endpoint,
|
|
68
|
+
universal,
|
|
69
|
+
});
|
|
70
|
+
react.useEffect(() => {
|
|
71
|
+
// Don't run the query if disabled or no identity
|
|
72
|
+
if (!enabled || !identity)
|
|
73
|
+
return;
|
|
74
|
+
// Skip if parameters haven't changed
|
|
75
|
+
if (currentParams === prevParamsRef.current && data !== null) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Update previous parameters
|
|
79
|
+
prevParamsRef.current = currentParams;
|
|
80
|
+
// Generate cache key
|
|
81
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
82
|
+
// Check if we already have cached data
|
|
83
|
+
const cachedData = globalRequestCache.get(cacheKey);
|
|
84
|
+
if (cachedData) {
|
|
85
|
+
setData(cachedData);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Increment request ID to track the latest request
|
|
89
|
+
const requestId = ++requestIdRef.current;
|
|
90
|
+
setIsLoading(true);
|
|
91
|
+
setError(null);
|
|
92
|
+
const fetchData = async () => {
|
|
93
|
+
try {
|
|
94
|
+
const url = buildApiUrl(identity, endpoint, universal);
|
|
95
|
+
if (!url) {
|
|
96
|
+
throw new Error(hook.ErrorMessages.INVALID_IDENTITY);
|
|
97
|
+
}
|
|
98
|
+
const headers = apiKey ? { "x-api-key": apiKey } : {};
|
|
99
|
+
const fetchOptions = {
|
|
100
|
+
method: "GET",
|
|
101
|
+
headers,
|
|
102
|
+
};
|
|
103
|
+
const response = await fetch(url, fetchOptions);
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
throw new Error(`API error: ${response.status}`);
|
|
106
|
+
}
|
|
107
|
+
const responseData = await response.json();
|
|
108
|
+
if (responseData === null || responseData === void 0 ? void 0 : responseData.error) {
|
|
109
|
+
throw new Error(responseData.error);
|
|
110
|
+
}
|
|
111
|
+
if (requestId === requestIdRef.current) {
|
|
112
|
+
globalRequestCache.set(cacheKey, responseData);
|
|
113
|
+
setData(responseData);
|
|
114
|
+
setIsLoading(false);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (requestId === requestIdRef.current) {
|
|
119
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
120
|
+
setIsLoading(false);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
fetchData();
|
|
125
|
+
}, [currentParams, enabled]);
|
|
126
|
+
return { data, isLoading, error };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.useBaseQuery = useBaseQuery;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { QueryEndpoint } from "../utils/constants";
|
|
1
|
+
import { type IdentityString, type QueryOptions, type QueryResult, QueryEndpoint } from "../types";
|
|
3
2
|
/**
|
|
4
3
|
* Core hook for querying Web3.bio Profile API
|
|
5
4
|
*/
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { ErrorMessages, QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useState, useRef, useEffect } from 'react';
|
|
7
|
+
import { getApiKey, API_ENDPOINT, resolveIdentity } from '../utils/helpers.js';
|
|
8
|
+
import '../utils/network.js';
|
|
9
|
+
import '../utils/platform.js';
|
|
10
|
+
import '../utils/source.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructs the API URL based on query parameters
|
|
14
|
+
*/
|
|
15
|
+
const buildApiUrl = (identity, endpoint, universal) => {
|
|
16
|
+
// Handle batch requests
|
|
17
|
+
if (Array.isArray(identity)) {
|
|
18
|
+
return `${API_ENDPOINT}/${endpoint}/batch/${encodeURIComponent(JSON.stringify(identity))}`;
|
|
19
|
+
}
|
|
20
|
+
// Handle universal queries
|
|
21
|
+
if (universal) {
|
|
22
|
+
return `${API_ENDPOINT}/${endpoint}/${identity}`;
|
|
23
|
+
}
|
|
24
|
+
// Handle platform-specific queries
|
|
25
|
+
const resolvedId = resolveIdentity(identity);
|
|
26
|
+
if (!resolvedId)
|
|
27
|
+
return null;
|
|
28
|
+
// Domain endpoint uses resolved ID directly
|
|
29
|
+
if (endpoint === QueryEndpoint.DOMAIN) {
|
|
30
|
+
return `${API_ENDPOINT}/${endpoint}/${resolvedId}`;
|
|
31
|
+
}
|
|
32
|
+
// Other endpoints need platform/handle split
|
|
33
|
+
const [platform, handle] = resolvedId.split(",");
|
|
34
|
+
return `${API_ENDPOINT}/${endpoint}/${platform}/${handle}`;
|
|
35
|
+
};
|
|
36
|
+
// Generate a stable cache key for this request
|
|
37
|
+
const getCacheKey = (identity, endpoint, universal) => {
|
|
38
|
+
return JSON.stringify({
|
|
39
|
+
identity,
|
|
40
|
+
endpoint,
|
|
41
|
+
universal,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
// Create a cache to store results across component instances and re-renders
|
|
45
|
+
const globalRequestCache = new Map();
|
|
46
|
+
/**
|
|
47
|
+
* Core hook for querying Web3.bio Profile API
|
|
48
|
+
*/
|
|
49
|
+
function useBaseQuery(identity, endpoint, universal = false, options = {}) {
|
|
50
|
+
const { apiKey: userApiKey, enabled = true } = options;
|
|
51
|
+
const apiKey = getApiKey(userApiKey);
|
|
52
|
+
const [data, setData] = useState(() => {
|
|
53
|
+
// Initialize state from cache if available
|
|
54
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
55
|
+
return globalRequestCache.get(cacheKey) || null;
|
|
56
|
+
});
|
|
57
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
58
|
+
const [error, setError] = useState(null);
|
|
59
|
+
// Use ref to track in-flight requests and prevent race conditions
|
|
60
|
+
const requestIdRef = useRef(0);
|
|
61
|
+
const prevParamsRef = useRef("");
|
|
62
|
+
// Current request parameters as a string for comparison
|
|
63
|
+
const currentParams = JSON.stringify({
|
|
64
|
+
identity,
|
|
65
|
+
endpoint,
|
|
66
|
+
universal,
|
|
67
|
+
});
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
// Don't run the query if disabled or no identity
|
|
70
|
+
if (!enabled || !identity)
|
|
71
|
+
return;
|
|
72
|
+
// Skip if parameters haven't changed
|
|
73
|
+
if (currentParams === prevParamsRef.current && data !== null) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Update previous parameters
|
|
77
|
+
prevParamsRef.current = currentParams;
|
|
78
|
+
// Generate cache key
|
|
79
|
+
const cacheKey = getCacheKey(identity, endpoint, universal);
|
|
80
|
+
// Check if we already have cached data
|
|
81
|
+
const cachedData = globalRequestCache.get(cacheKey);
|
|
82
|
+
if (cachedData) {
|
|
83
|
+
setData(cachedData);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Increment request ID to track the latest request
|
|
87
|
+
const requestId = ++requestIdRef.current;
|
|
88
|
+
setIsLoading(true);
|
|
89
|
+
setError(null);
|
|
90
|
+
const fetchData = async () => {
|
|
91
|
+
try {
|
|
92
|
+
const url = buildApiUrl(identity, endpoint, universal);
|
|
93
|
+
if (!url) {
|
|
94
|
+
throw new Error(ErrorMessages.INVALID_IDENTITY);
|
|
95
|
+
}
|
|
96
|
+
const headers = apiKey ? { "x-api-key": apiKey } : {};
|
|
97
|
+
const fetchOptions = {
|
|
98
|
+
method: "GET",
|
|
99
|
+
headers,
|
|
100
|
+
};
|
|
101
|
+
const response = await fetch(url, fetchOptions);
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
throw new Error(`API error: ${response.status}`);
|
|
104
|
+
}
|
|
105
|
+
const responseData = await response.json();
|
|
106
|
+
if (responseData === null || responseData === void 0 ? void 0 : responseData.error) {
|
|
107
|
+
throw new Error(responseData.error);
|
|
108
|
+
}
|
|
109
|
+
if (requestId === requestIdRef.current) {
|
|
110
|
+
globalRequestCache.set(cacheKey, responseData);
|
|
111
|
+
setData(responseData);
|
|
112
|
+
setIsLoading(false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
if (requestId === requestIdRef.current) {
|
|
117
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
118
|
+
setIsLoading(false);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
fetchData();
|
|
123
|
+
}, [currentParams, enabled]);
|
|
124
|
+
return { data, isLoading, error };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { useBaseQuery };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio profile data using batch(NS) identity lookup
|
|
12
|
+
*
|
|
13
|
+
* @param identity - array of Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by any identity type with batch lookup
|
|
19
|
+
* const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
20
|
+
*/
|
|
21
|
+
function useBatchNS(identity, options = {}) {
|
|
22
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.NS, false, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.useBatchNS = useBatchNS;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio profile data using batch(NS) identity lookup
|
|
10
|
+
*
|
|
11
|
+
* @param identity - array of Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by any identity type with batch lookup
|
|
17
|
+
* const { data } = useBatchNS(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
18
|
+
*/
|
|
19
|
+
function useBatchNS(identity, options = {}) {
|
|
20
|
+
return useBaseQuery(identity, QueryEndpoint.NS, false, options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useBatchNS };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio profile data using batch identity lookup
|
|
12
|
+
*
|
|
13
|
+
* @param identity - array of Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by any identity type with batch lookup
|
|
19
|
+
* const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
20
|
+
*/
|
|
21
|
+
function useBatchProfile(identity, options = {}) {
|
|
22
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.PROFILE, false, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.useBatchProfile = useBatchProfile;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio profile data using batch identity lookup
|
|
10
|
+
*
|
|
11
|
+
* @param identity - array of Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by any identity type with batch lookup
|
|
17
|
+
* const { data } = useBatchProfile(["dwr.farcaster","ens,vitalik.eth","sujiyan.eth","stani.lens"]);
|
|
18
|
+
*/
|
|
19
|
+
function useBatchProfile(identity, options = {}) {
|
|
20
|
+
return useBaseQuery(identity, QueryEndpoint.PROFILE, false, options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useBatchProfile };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio domain data by identity
|
|
12
|
+
*
|
|
13
|
+
* @param identity - Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing domain data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by ENS name
|
|
19
|
+
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
20
|
+
*
|
|
21
|
+
* // Query by domain name with platform
|
|
22
|
+
* const { data } = useDomain("ens,vitalik.eth");
|
|
23
|
+
*/
|
|
24
|
+
function useDomain(identity, options = {}) {
|
|
25
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.DOMAIN, false, options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.useDomain = useDomain;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio domain data by identity
|
|
10
|
+
*
|
|
11
|
+
* @param identity - Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing domain data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by ENS name
|
|
17
|
+
* const { data, isLoading, error } = useDomain("vitalik.eth");
|
|
18
|
+
*
|
|
19
|
+
* // Query by domain name with platform
|
|
20
|
+
* const { data } = useDomain("ens,vitalik.eth");
|
|
21
|
+
*/
|
|
22
|
+
function useDomain(identity, options = {}) {
|
|
23
|
+
return useBaseQuery(identity, QueryEndpoint.DOMAIN, false, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useDomain };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio name service (NS) data by identity
|
|
12
|
+
*
|
|
13
|
+
* @param identity - Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing NS data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by ENS name
|
|
19
|
+
* const { data, isLoading, error } = useNS("vitalik.eth");
|
|
20
|
+
*
|
|
21
|
+
* // Query by Ethereum address
|
|
22
|
+
* const { data } = useNS("0x123...");
|
|
23
|
+
*/
|
|
24
|
+
function useNS(identity, options = {}) {
|
|
25
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.NS, false, options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.useNS = useNS;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio name service (NS) data by identity
|
|
10
|
+
*
|
|
11
|
+
* @param identity - Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing NS data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by ENS name
|
|
17
|
+
* const { data, isLoading, error } = useNS("vitalik.eth");
|
|
18
|
+
*
|
|
19
|
+
* // Query by Ethereum address
|
|
20
|
+
* const { data } = useNS("0x123...");
|
|
21
|
+
*/
|
|
22
|
+
function useNS(identity, options = {}) {
|
|
23
|
+
return useBaseQuery(identity, QueryEndpoint.NS, false, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useNS };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio profile data by identity
|
|
12
|
+
*
|
|
13
|
+
* @param identity - Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by ENS name
|
|
19
|
+
* const { data, isLoading, error } = useProfile("vitalik.eth");
|
|
20
|
+
*
|
|
21
|
+
* // Query with platform specification
|
|
22
|
+
* const { data } = useProfile("farcaster,dwr");
|
|
23
|
+
*/
|
|
24
|
+
function useProfile(identity, options = {}) {
|
|
25
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.PROFILE, false, options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.useProfile = useProfile;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio profile data by identity
|
|
10
|
+
*
|
|
11
|
+
* @param identity - Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing profile data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by ENS name
|
|
17
|
+
* const { data, isLoading, error } = useProfile("vitalik.eth");
|
|
18
|
+
*
|
|
19
|
+
* // Query with platform specification
|
|
20
|
+
* const { data } = useProfile("farcaster,dwr");
|
|
21
|
+
*/
|
|
22
|
+
function useProfile(identity, options = {}) {
|
|
23
|
+
return useBaseQuery(identity, QueryEndpoint.PROFILE, false, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useProfile };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/platform.cjs');
|
|
4
|
+
require('../types/network.cjs');
|
|
5
|
+
var hook = require('../types/hook.cjs');
|
|
6
|
+
require('../types/source.cjs');
|
|
7
|
+
require('../types/cointype.cjs');
|
|
8
|
+
var useBaseQuery = require('./useBaseQuery.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
12
|
+
*
|
|
13
|
+
* @param identity - Identity string
|
|
14
|
+
* @param options - Optional configuration options
|
|
15
|
+
* @returns Object containing NS data, loading state, and any errors
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Query by ENS name with universal lookup
|
|
19
|
+
* const { data, isLoading, error } = useUniversalNS("vitalik.eth");
|
|
20
|
+
*
|
|
21
|
+
* // Query by any identity type with universal lookup
|
|
22
|
+
* const { data } = useUniversalNS("dwr.farcaster");
|
|
23
|
+
*/
|
|
24
|
+
function useUniversalNS(identity, options = {}) {
|
|
25
|
+
return useBaseQuery.useBaseQuery(identity, hook.QueryEndpoint.NS, true, options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.useUniversalNS = useUniversalNS;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../types/platform.js';
|
|
2
|
+
import '../types/network.js';
|
|
3
|
+
import { QueryEndpoint } from '../types/hook.js';
|
|
4
|
+
import '../types/source.js';
|
|
5
|
+
import '../types/cointype.js';
|
|
6
|
+
import { useBaseQuery } from './useBaseQuery.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to query Web3.bio name service (NS) data using universal identity lookup
|
|
10
|
+
*
|
|
11
|
+
* @param identity - Identity string
|
|
12
|
+
* @param options - Optional configuration options
|
|
13
|
+
* @returns Object containing NS data, loading state, and any errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Query by ENS name with universal lookup
|
|
17
|
+
* const { data, isLoading, error } = useUniversalNS("vitalik.eth");
|
|
18
|
+
*
|
|
19
|
+
* // Query by any identity type with universal lookup
|
|
20
|
+
* const { data } = useUniversalNS("dwr.farcaster");
|
|
21
|
+
*/
|
|
22
|
+
function useUniversalNS(identity, options = {}) {
|
|
23
|
+
return useBaseQuery(identity, QueryEndpoint.NS, true, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useUniversalNS };
|