@b3dotfun/sdk 0.1.0 → 0.1.1-alpha.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/dist/cjs/anyspend/react/components/AnySpend.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +22 -14
- package/dist/cjs/anyspend/react/components/QRDeposit.js +31 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -2
- package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +6 -16
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +15 -4
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +25 -0
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/cjs/anyspend/react/hooks/useWatchTransfer.js +75 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -2
- package/dist/cjs/anyspend/utils/address.d.ts +5 -0
- package/dist/cjs/anyspend/utils/address.js +8 -0
- package/dist/cjs/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +4 -14
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +37 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +3 -31
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +4 -31
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +2 -21
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -1
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +163 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.js +5 -0
- package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +6 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +5 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +5 -2
- package/dist/cjs/global-account/react/hooks/useProfile.js +4 -23
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +43 -11
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +190 -0
- package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
- package/dist/cjs/global-account/react/stores/index.js +1 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +63 -1
- package/dist/cjs/global-account/react/stores/useModalStore.js +3 -0
- package/dist/cjs/global-account/react/utils/profileApi.d.ts +13 -0
- package/dist/cjs/global-account/react/utils/profileApi.js +29 -0
- package/dist/cjs/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/cjs/global-account/react/utils/simdune.js +21 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +23 -15
- package/dist/esm/anyspend/react/components/QRDeposit.js +32 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +10 -3
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +7 -17
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +16 -5
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +22 -0
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/esm/anyspend/react/hooks/useWatchTransfer.js +72 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -2
- package/dist/esm/anyspend/utils/address.d.ts +5 -0
- package/dist/esm/anyspend/utils/address.js +7 -0
- package/dist/esm/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -15
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +33 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -31
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +3 -30
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +1 -20
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -2
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +160 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.js +1 -0
- package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +5 -2
- package/dist/esm/global-account/react/hooks/useProfile.js +1 -20
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useSimBalance.js +42 -11
- package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/esm/global-account/react/hooks/useSimCollectibles.js +187 -0
- package/dist/esm/global-account/react/stores/index.d.ts +0 -1
- package/dist/esm/global-account/react/stores/index.js +0 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +63 -1
- package/dist/esm/global-account/react/stores/useModalStore.js +3 -0
- package/dist/esm/global-account/react/utils/profileApi.d.ts +13 -0
- package/dist/esm/global-account/react/utils/profileApi.js +25 -0
- package/dist/esm/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/esm/global-account/react/utils/simdune.js +17 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/types/anyspend/utils/address.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +1 -12
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
- package/dist/types/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/types/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +7 -0
- package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/types/global-account/react/stores/index.d.ts +0 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +63 -1
- package/dist/types/global-account/react/utils/profileApi.d.ts +13 -0
- package/dist/types/global-account/react/utils/simdune.d.ts +7 -0
- package/package.json +6 -1
- package/src/anyspend/react/components/AnySpend.tsx +1 -0
- package/src/anyspend/react/components/AnySpendDeposit.tsx +60 -42
- package/src/anyspend/react/components/QRDeposit.tsx +57 -5
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +13 -3
- package/src/anyspend/react/components/common/GasIndicator.tsx +11 -30
- package/src/anyspend/react/components/common/TokenBalance.tsx +17 -5
- package/src/anyspend/react/components/common/TransferResultScreen.tsx +107 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useWatchTransfer.ts +114 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +2 -5
- package/src/anyspend/utils/address.ts +13 -0
- package/src/global-account/react/components/AccountAssets/AccountAssets.tsx +25 -13
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -17
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +84 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +28 -36
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +24 -39
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/B3Provider/useB3Config.ts +1 -21
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +4 -4
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -2
- package/src/global-account/react/components/SingleUserSearchSelector/README.md +266 -0
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +330 -0
- package/src/global-account/react/components/SingleUserSearchSelector/index.ts +2 -0
- package/src/global-account/react/components/index.ts +7 -0
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAuthentication.ts +6 -2
- package/src/global-account/react/hooks/useProfile.ts +1 -32
- package/src/global-account/react/hooks/useSimBalance.ts +49 -12
- package/src/global-account/react/hooks/useSimCollectibles.ts +238 -0
- package/src/global-account/react/stores/index.ts +0 -1
- package/src/global-account/react/stores/useModalStore.ts +67 -1
- package/src/global-account/react/utils/profileApi.ts +38 -0
- package/src/global-account/react/utils/simdune.ts +20 -0
- package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/cjs/global-account/react/stores/configStore.js +0 -30
- package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/esm/global-account/react/stores/configStore.js +0 -27
- package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
- package/src/global-account/react/stores/configStore.ts +0 -51
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SingleUserSearchSelector = SingleUserSearchSelector;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const utils_1 = require("../../../../shared/utils");
|
|
7
|
+
const lucide_react_1 = require("lucide-react");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const profileApi_1 = require("../../utils/profileApi");
|
|
10
|
+
const IPFSMediaRenderer_1 = require("../IPFSMediaRenderer/IPFSMediaRenderer");
|
|
11
|
+
const input_1 = require("../ui/input");
|
|
12
|
+
/**
|
|
13
|
+
* SingleUserSearchSelector Component
|
|
14
|
+
*
|
|
15
|
+
* A specialized component for searching and selecting a single user profile.
|
|
16
|
+
* This component is designed specifically for single-user selection scenarios,
|
|
17
|
+
* not for multi-user or general profile browsing.
|
|
18
|
+
*
|
|
19
|
+
* Features:
|
|
20
|
+
* - Search by address or name
|
|
21
|
+
* - Filter results by profile type (b3-ens, thirdweb-*, ens-data, global-account)
|
|
22
|
+
* - Shows a single result in a dropdown
|
|
23
|
+
* - Callback with complete profile data on selection
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <SingleUserSearchSelector
|
|
28
|
+
* onSelectUser={(profile) => console.log('Selected:', profile)}
|
|
29
|
+
* profileTypeFilter={['b3-ens', 'global-account']}
|
|
30
|
+
* placeholder="Search by address or name..."
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function SingleUserSearchSelector({ onSelectUser, profileTypeFilter, placeholder = "Search by address, name, or ID...", className, showClearButton = true, showBadges = false, minSearchLength = 3, }) {
|
|
35
|
+
const [searchQuery, setSearchQuery] = (0, react_1.useState)("");
|
|
36
|
+
const [isSearching, setIsSearching] = (0, react_1.useState)(false);
|
|
37
|
+
const [searchResult, setSearchResult] = (0, react_1.useState)(null);
|
|
38
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
39
|
+
const [showDropdown, setShowDropdown] = (0, react_1.useState)(false);
|
|
40
|
+
const dropdownRef = (0, react_1.useRef)(null);
|
|
41
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
42
|
+
const searchTimeoutRef = (0, react_1.useRef)(undefined);
|
|
43
|
+
// Fetch profile from API using shared utility
|
|
44
|
+
const fetchProfile = (0, react_1.useCallback)(async (query) => {
|
|
45
|
+
if (!query || query.length < minSearchLength) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Determine if query is an address (starts with 0x) or a name
|
|
50
|
+
const params = query.startsWith("0x") ? { address: query } : { name: query };
|
|
51
|
+
const profile = await (0, profileApi_1.fetchProfile)(params);
|
|
52
|
+
return profile;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
// Return null for 404s (user not found)
|
|
56
|
+
if (err instanceof Error && err.message.includes("404")) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
console.error("Error fetching profile:", err);
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}, [minSearchLength]);
|
|
63
|
+
// Filter profile by type
|
|
64
|
+
const filterProfileByType = (0, react_1.useCallback)((profile) => {
|
|
65
|
+
if (!profileTypeFilter || profileTypeFilter.length === 0) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
// Check if any of the profile's types match the filter
|
|
69
|
+
return profile.profiles.some(p => {
|
|
70
|
+
return profileTypeFilter.some(filter => {
|
|
71
|
+
// Handle thirdweb-* wildcard matching
|
|
72
|
+
if (filter.startsWith("thirdweb-")) {
|
|
73
|
+
return p.type.startsWith("thirdweb-");
|
|
74
|
+
}
|
|
75
|
+
return p.type === filter;
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}, [profileTypeFilter]);
|
|
79
|
+
// Handle search with debouncing
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
if (searchTimeoutRef.current) {
|
|
82
|
+
clearTimeout(searchTimeoutRef.current);
|
|
83
|
+
}
|
|
84
|
+
if (!searchQuery || searchQuery.length < minSearchLength) {
|
|
85
|
+
setSearchResult(null);
|
|
86
|
+
setShowDropdown(false);
|
|
87
|
+
setError(null);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setIsSearching(true);
|
|
91
|
+
setError(null);
|
|
92
|
+
searchTimeoutRef.current = setTimeout(async () => {
|
|
93
|
+
try {
|
|
94
|
+
const result = await fetchProfile(searchQuery);
|
|
95
|
+
if (result) {
|
|
96
|
+
// Apply profile type filter
|
|
97
|
+
if (filterProfileByType(result)) {
|
|
98
|
+
setSearchResult(result);
|
|
99
|
+
setShowDropdown(true);
|
|
100
|
+
setError(null); // Clear any previous errors
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
setSearchResult(null);
|
|
104
|
+
setShowDropdown(false);
|
|
105
|
+
setError("No matching profile types found");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
setSearchResult(null);
|
|
110
|
+
setShowDropdown(false);
|
|
111
|
+
setError("No user found");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
setError(err instanceof Error ? err.message : "Failed to search");
|
|
116
|
+
setSearchResult(null);
|
|
117
|
+
setShowDropdown(false);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
setIsSearching(false);
|
|
121
|
+
}
|
|
122
|
+
}, 500); // 500ms debounce
|
|
123
|
+
return () => {
|
|
124
|
+
if (searchTimeoutRef.current) {
|
|
125
|
+
clearTimeout(searchTimeoutRef.current);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, [searchQuery, fetchProfile, filterProfileByType, minSearchLength]);
|
|
129
|
+
// Handle click outside to close dropdown
|
|
130
|
+
(0, react_1.useEffect)(() => {
|
|
131
|
+
const handleClickOutside = (event) => {
|
|
132
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
133
|
+
setShowDropdown(false);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
137
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
138
|
+
}, []);
|
|
139
|
+
// Handle user selection
|
|
140
|
+
const handleSelectUser = (0, react_1.useCallback)((profile) => {
|
|
141
|
+
onSelectUser(profile);
|
|
142
|
+
setShowDropdown(false);
|
|
143
|
+
setSearchQuery("");
|
|
144
|
+
setSearchResult(null);
|
|
145
|
+
}, [onSelectUser]);
|
|
146
|
+
// Handle clear search
|
|
147
|
+
const handleClear = (0, react_1.useCallback)(() => {
|
|
148
|
+
setSearchQuery("");
|
|
149
|
+
setSearchResult(null);
|
|
150
|
+
setShowDropdown(false);
|
|
151
|
+
setError(null);
|
|
152
|
+
inputRef.current?.focus();
|
|
153
|
+
}, []);
|
|
154
|
+
// Get display name for profile
|
|
155
|
+
const getDisplayName = (profile) => {
|
|
156
|
+
return profile.displayName || profile.name || profile.address || "Unknown";
|
|
157
|
+
};
|
|
158
|
+
// Get profile type badges
|
|
159
|
+
const getProfileTypeBadges = (profiles) => {
|
|
160
|
+
return profiles.map(p => p.type);
|
|
161
|
+
};
|
|
162
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("single-user-search-selector b3-root relative w-full", className), ref: dropdownRef, children: [(0, jsx_runtime_1.jsxs)("div", { className: "single-user-search-input-wrapper relative flex items-center", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Search, { className: "single-user-search-icon pointer-events-none absolute text-gray-400", style: { left: "12px", width: "16px", height: "16px" } }), (0, jsx_runtime_1.jsx)(input_1.Input, { ref: inputRef, type: "text", value: searchQuery, onChange: e => setSearchQuery(e.target.value), placeholder: placeholder, className: (0, utils_1.cn)("single-user-search-input w-full border-gray-300 focus:border-blue-500 focus:ring-blue-500"), style: { paddingLeft: "44px", paddingRight: "44px" } }), showClearButton && searchQuery && ((0, jsx_runtime_1.jsx)("button", { onClick: handleClear, className: "single-user-search-clear-button absolute text-gray-400 transition-colors hover:text-gray-600", style: { right: "12px" }, type: "button", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { style: { width: "16px", height: "16px" } }) }))] }), isSearching && (0, jsx_runtime_1.jsx)("div", { className: "single-user-search-loading mt-2 text-sm text-gray-500", children: "Searching..." }), error && !isSearching && (0, jsx_runtime_1.jsx)("div", { className: "single-user-search-error mt-2 text-sm text-red-500", children: error }), showDropdown && searchResult && !isSearching && ((0, jsx_runtime_1.jsx)("div", { className: "single-user-search-dropdown absolute z-50 mt-2 w-full rounded-lg border border-gray-200 bg-white shadow-lg", children: (0, jsx_runtime_1.jsx)("button", { onClick: () => handleSelectUser(searchResult), className: "single-user-search-result-button w-full px-4 py-3 text-left transition-colors hover:bg-gray-50", type: "button", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-start gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "single-user-search-result-avatar h-11 w-11 shrink-0", children: (0, jsx_runtime_1.jsx)(IPFSMediaRenderer_1.IPFSMediaRenderer, { src: searchResult.avatar, alt: getDisplayName(searchResult), className: "h-full w-full rounded-full object-cover" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "single-user-search-result-info min-w-0 flex-1 pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "single-user-search-result-name text-base font-semibold text-gray-900", children: getDisplayName(searchResult) }), searchResult.address && ((0, jsx_runtime_1.jsxs)("div", { className: "single-user-search-result-address mt-1 font-mono text-xs text-gray-500", children: [searchResult.address.slice(0, 6), "...", searchResult.address.slice(-4)] })), searchResult.bio && ((0, jsx_runtime_1.jsx)("div", { className: "single-user-search-result-bio mt-1.5 line-clamp-2 text-sm text-gray-600", children: searchResult.bio })), showBadges && ((0, jsx_runtime_1.jsx)("div", { className: "single-user-search-result-badges mt-2 flex flex-wrap gap-1.5", children: getProfileTypeBadges(searchResult.profiles).map((type, index) => ((0, jsx_runtime_1.jsx)("span", { className: "single-user-search-result-badge inline-flex items-center rounded-full bg-blue-100 px-2.5 py-0.5 text-xs font-medium text-blue-800", children: type }, `${type}-${index}`))) }))] })] }) }) }))] }));
|
|
163
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SingleUserSearchSelector = void 0;
|
|
4
|
+
var SingleUserSearchSelector_1 = require("./SingleUserSearchSelector");
|
|
5
|
+
Object.defineProperty(exports, "SingleUserSearchSelector", { enumerable: true, get: function () { return SingleUserSearchSelector_1.SingleUserSearchSelector; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
declare const WalletImage: ({ fallback }: {
|
|
2
2
|
fallback?: React.ReactNode;
|
|
3
|
-
}) => string | number | bigint | true |
|
|
3
|
+
}) => string | number | bigint | true | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
export default WalletImage;
|
|
@@ -24,6 +24,8 @@ export { AccountAssets } from "./AccountAssets/AccountAssets";
|
|
|
24
24
|
export { MintButton } from "./MintButton/MintButton";
|
|
25
25
|
export { SendETHButton } from "./SendETHButton/SendETHButton";
|
|
26
26
|
export { SendERC20Button } from "./SendERC20Button/SendERC20Button";
|
|
27
|
+
export { SingleUserSearchSelector } from "./SingleUserSearchSelector/SingleUserSearchSelector";
|
|
28
|
+
export type { ProfileTypeFilter, SingleUserSearchSelectorProps, } from "./SingleUserSearchSelector/SingleUserSearchSelector";
|
|
27
29
|
export { Button as CustomButton, buttonVariants as customButtonVariants } from "./custom/Button";
|
|
28
30
|
export { ClientOnly } from "./custom/ClientOnly";
|
|
29
31
|
export { CopyToClipboard } from "./custom/CopyToClipboard";
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.WalletImage = exports.useToastContext = exports.ToastProvider = exports.ToastContainer = exports.Toast = void 0;
|
|
6
|
+
exports.DialogContent = exports.DialogClose = exports.Dialog = exports.CommandShortcut = exports.CommandSeparator = exports.CommandList = exports.CommandItem = exports.CommandInput = exports.CommandGroup = exports.CommandEmpty = exports.CommandDialog = exports.Command = exports.buttonVariants = exports.Button = exports.badgeVariants = exports.Badge = exports.WalletConnectorIcon = exports.StaggeredFadeLoader = exports.CopyToClipboard = exports.ClientOnly = exports.customButtonVariants = exports.CustomButton = exports.SingleUserSearchSelector = exports.SendERC20Button = exports.SendETHButton = exports.MintButton = exports.AccountAssets = exports.RequestPermissionsButton = exports.RequestPermissions = exports.IPFSMediaRenderer = exports.Send = exports.Deposit = exports.ManageAccount = exports.TurnkeyAuthModal = exports.isWalletType = exports.getConnectOptionsFromStrategy = exports.LoginStepContainer = exports.SignInWithB3Privy = exports.SignInWithB3Flow = exports.SignInWithB3 = exports.WalletRow = exports.PermissionItem = exports.AuthButton = exports.StyleRoot = exports.useB3Config = exports.useB3Account = exports.useB3 = exports.RelayKitProviderWrapper = exports.B3Provider = exports.B3DynamicModal = void 0;
|
|
7
|
+
exports.AnimatedLottie = exports.TransitionPanel = exports.TooltipTrigger = exports.TooltipProvider = exports.TooltipContent = exports.Tooltip = exports.TextShimmer = exports.TextLoop = exports.TabTrigger = exports.TabsTransitionWrapper = exports.TabsList = exports.TabsContent = exports.Tabs = exports.TabTriggerPrimitive = exports.TabsPrimitive = exports.TabsListPrimitive = exports.TabsContentPrimitive = exports.Skeleton = exports.ShinyButton = exports.ScrollBar = exports.ScrollArea = exports.PopoverTrigger = exports.PopoverContent = exports.Popover = exports.Loading = exports.Input = exports.GlareCardRounded = exports.GlareCard = exports.DropdownMenuTrigger = exports.DropdownMenuSeparator = exports.DropdownMenuItem = exports.DropdownMenuContent = exports.DropdownMenu = exports.DrawerTrigger = exports.DrawerTitle = exports.DrawerPortal = exports.DrawerOverlay = exports.DrawerHeader = exports.DrawerFooter = exports.DrawerDescription = exports.DrawerContent = exports.DrawerClose = exports.Drawer = exports.DialogTrigger = exports.DialogTitle = exports.DialogPortal = exports.DialogOverlay = exports.DialogHeader = exports.DialogFooter = exports.DialogDescription = void 0;
|
|
8
|
+
exports.WalletImage = exports.useToastContext = exports.ToastProvider = exports.ToastContainer = exports.Toast = exports.toast = void 0;
|
|
9
9
|
// TODO woj: Barrel file for all components, this might be reason of bundle size issues
|
|
10
10
|
// Core Components
|
|
11
11
|
var B3DynamicModal_1 = require("./B3DynamicModal");
|
|
@@ -72,6 +72,9 @@ Object.defineProperty(exports, "SendETHButton", { enumerable: true, get: functio
|
|
|
72
72
|
// SendERC20Button Components
|
|
73
73
|
var SendERC20Button_1 = require("./SendERC20Button/SendERC20Button");
|
|
74
74
|
Object.defineProperty(exports, "SendERC20Button", { enumerable: true, get: function () { return SendERC20Button_1.SendERC20Button; } });
|
|
75
|
+
// SingleUserSearchSelector Components
|
|
76
|
+
var SingleUserSearchSelector_1 = require("./SingleUserSearchSelector/SingleUserSearchSelector");
|
|
77
|
+
Object.defineProperty(exports, "SingleUserSearchSelector", { enumerable: true, get: function () { return SingleUserSearchSelector_1.SingleUserSearchSelector; } });
|
|
75
78
|
// Custom Components
|
|
76
79
|
var Button_1 = require("./custom/Button");
|
|
77
80
|
Object.defineProperty(exports, "CustomButton", { enumerable: true, get: function () { return Button_1.Button; } });
|
|
@@ -30,7 +30,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
|
30
30
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
31
31
|
export { useRouter } from "./useRouter";
|
|
32
32
|
export { useSearchParamsSSR } from "./useSearchParamsSSR";
|
|
33
|
-
export { useSimBalance, useSimSvmBalance } from "./useSimBalance";
|
|
33
|
+
export { useSimBalance, useSimSvmBalance, useSimTokenBalance } from "./useSimBalance";
|
|
34
|
+
export { useSimCollectibles } from "./useSimCollectibles";
|
|
34
35
|
export { useSiwe } from "./useSiwe";
|
|
35
36
|
export { useTokenBalance } from "./useTokenBalance";
|
|
36
37
|
export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
|
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimCollectibles = exports.useSimTokenBalance = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAuth = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
|
|
18
|
+
exports.useUser = exports.useURLParams = void 0;
|
|
18
19
|
var createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
19
20
|
Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
|
|
20
21
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
@@ -85,6 +86,9 @@ Object.defineProperty(exports, "useSearchParamsSSR", { enumerable: true, get: fu
|
|
|
85
86
|
var useSimBalance_1 = require("./useSimBalance");
|
|
86
87
|
Object.defineProperty(exports, "useSimBalance", { enumerable: true, get: function () { return useSimBalance_1.useSimBalance; } });
|
|
87
88
|
Object.defineProperty(exports, "useSimSvmBalance", { enumerable: true, get: function () { return useSimBalance_1.useSimSvmBalance; } });
|
|
89
|
+
Object.defineProperty(exports, "useSimTokenBalance", { enumerable: true, get: function () { return useSimBalance_1.useSimTokenBalance; } });
|
|
90
|
+
var useSimCollectibles_1 = require("./useSimCollectibles");
|
|
91
|
+
Object.defineProperty(exports, "useSimCollectibles", { enumerable: true, get: function () { return useSimCollectibles_1.useSimCollectibles; } });
|
|
88
92
|
var useSiwe_1 = require("./useSiwe");
|
|
89
93
|
Object.defineProperty(exports, "useSiwe", { enumerable: true, get: function () { return useSiwe_1.useSiwe; } });
|
|
90
94
|
var useTokenBalance_1 = require("./useTokenBalance");
|
|
@@ -22,7 +22,7 @@ const useTWAuth_1 = require("./useTWAuth");
|
|
|
22
22
|
const useUserQuery_1 = require("./useUserQuery");
|
|
23
23
|
const debug = (0, debug_1.debugB3React)("useAuthentication");
|
|
24
24
|
function useAuthentication(partnerId) {
|
|
25
|
-
const { onConnectCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
|
|
25
|
+
const { onConnectCallback, onLogoutCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
|
|
26
26
|
const { disconnect } = (0, react_3.useDisconnect)();
|
|
27
27
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
28
28
|
const activeWallet = (0, react_3.useActiveWallet)();
|
|
@@ -156,7 +156,10 @@ function useAuthentication(partnerId) {
|
|
|
156
156
|
setIsConnected(false);
|
|
157
157
|
setUser();
|
|
158
158
|
callback?.();
|
|
159
|
-
|
|
159
|
+
if (onLogoutCallback) {
|
|
160
|
+
await onLogoutCallback();
|
|
161
|
+
}
|
|
162
|
+
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected, onLogoutCallback]);
|
|
160
163
|
const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
161
164
|
debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
162
165
|
try {
|
|
@@ -5,28 +5,9 @@ exports.useProfilePreference = useProfilePreference;
|
|
|
5
5
|
exports.useDisplayName = useDisplayName;
|
|
6
6
|
exports.useProfileSettings = useProfileSettings;
|
|
7
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
-
const
|
|
9
|
-
async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
|
|
10
|
-
if (!address && !name && !b3GlobalId) {
|
|
11
|
-
throw new Error("Either address or name or b3GlobalId must be provided");
|
|
12
|
-
}
|
|
13
|
-
const params = new URLSearchParams();
|
|
14
|
-
if (address)
|
|
15
|
-
params.append("address", address);
|
|
16
|
-
if (name)
|
|
17
|
-
params.append("name", name);
|
|
18
|
-
if (b3GlobalId)
|
|
19
|
-
params.append("b3GlobalId", b3GlobalId);
|
|
20
|
-
if (fresh)
|
|
21
|
-
params.append("fresh", "true");
|
|
22
|
-
const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
throw new Error(`Failed to fetch profile: ${response.statusText}`);
|
|
25
|
-
}
|
|
26
|
-
return response.json();
|
|
27
|
-
}
|
|
8
|
+
const profileApi_1 = require("../utils/profileApi");
|
|
28
9
|
async function setProfilePreference({ key, preferredType, signature, signer, timestamp, }) {
|
|
29
|
-
const response = await fetch(`${PROFILES_API_URL}/preference`, {
|
|
10
|
+
const response = await fetch(`${profileApi_1.PROFILES_API_URL}/preference`, {
|
|
30
11
|
method: "POST",
|
|
31
12
|
headers: {
|
|
32
13
|
"Content-Type": "application/json",
|
|
@@ -45,7 +26,7 @@ async function setProfilePreference({ key, preferredType, signature, signer, tim
|
|
|
45
26
|
return response.json();
|
|
46
27
|
}
|
|
47
28
|
async function setDisplayName({ key, displayName, signature, signer, timestamp, }) {
|
|
48
|
-
const response = await fetch(`${PROFILES_API_URL}/display-name`, {
|
|
29
|
+
const response = await fetch(`${profileApi_1.PROFILES_API_URL}/display-name`, {
|
|
49
30
|
method: "POST",
|
|
50
31
|
headers: {
|
|
51
32
|
"Content-Type": "application/json",
|
|
@@ -66,7 +47,7 @@ async function setDisplayName({ key, displayName, signature, signer, timestamp,
|
|
|
66
47
|
function useProfile({ address, name, b3GlobalId, fresh = false, }, options) {
|
|
67
48
|
return (0, react_query_1.useQuery)({
|
|
68
49
|
queryKey: ["profile", address || name || b3GlobalId, fresh],
|
|
69
|
-
queryFn: () => fetchProfile({ address, name, b3GlobalId, fresh }),
|
|
50
|
+
queryFn: () => (0, profileApi_1.fetchProfile)({ address, name, b3GlobalId, fresh }),
|
|
70
51
|
enabled: (options?.enabled ?? true) && (!!address || !!name || !!b3GlobalId),
|
|
71
52
|
refetchInterval: options?.refetchInterval,
|
|
72
53
|
staleTime: options?.staleTime ?? 5 * 60 * 1000, // 5 minutes default
|
|
@@ -50,3 +50,10 @@ export interface SvmBalanceResponse {
|
|
|
50
50
|
}
|
|
51
51
|
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
52
52
|
export declare function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number): import("@tanstack/react-query").UseQueryResult<SvmBalanceResponse, Error>;
|
|
53
|
+
/**
|
|
54
|
+
* Hook to fetch a single token balance for a wallet.
|
|
55
|
+
* @param walletAddress - The wallet address to fetch balance for
|
|
56
|
+
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
57
|
+
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
58
|
+
*/
|
|
59
|
+
export declare function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSimBalance = useSimBalance;
|
|
4
4
|
exports.useSimSvmBalance = useSimSvmBalance;
|
|
5
|
+
exports.useSimTokenBalance = useSimTokenBalance;
|
|
5
6
|
const react_query_1 = require("@tanstack/react-query");
|
|
7
|
+
const simdune_1 = require("../utils/simdune");
|
|
6
8
|
async function fetchSimBalance(address, chainIdsParam) {
|
|
7
9
|
if (!address)
|
|
8
10
|
throw new Error("Address is required");
|
|
9
11
|
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const queryParams = new URLSearchParams();
|
|
13
|
+
queryParams.append("metadata", "logo");
|
|
14
|
+
queryParams.append("chain_ids", chainIds);
|
|
15
|
+
queryParams.append("exclude_spam_tokens", "true");
|
|
16
|
+
const url = (0, simdune_1.buildSimduneUrl)(`/v1/evm/balances/${address}`, queryParams);
|
|
14
17
|
const response = await fetch(url);
|
|
15
18
|
if (!response.ok) {
|
|
16
19
|
throw new Error(`Failed to fetch balance: ${response.statusText}`);
|
|
@@ -18,6 +21,23 @@ async function fetchSimBalance(address, chainIdsParam) {
|
|
|
18
21
|
const balanceData = await response.json();
|
|
19
22
|
return balanceData;
|
|
20
23
|
}
|
|
24
|
+
async function fetchSimTokenBalance(walletAddress, tokenAddress, chainId) {
|
|
25
|
+
if (!walletAddress)
|
|
26
|
+
throw new Error("Wallet address is required");
|
|
27
|
+
if (!tokenAddress)
|
|
28
|
+
throw new Error("Token address is required");
|
|
29
|
+
if (!chainId)
|
|
30
|
+
throw new Error("Chain ID is required");
|
|
31
|
+
const queryParams = new URLSearchParams();
|
|
32
|
+
queryParams.append("chain_ids", chainId.toString());
|
|
33
|
+
const url = (0, simdune_1.buildSimduneUrl)(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
|
|
34
|
+
const response = await fetch(url);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`Failed to fetch token balance: ${response.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
const balanceData = await response.json();
|
|
39
|
+
return balanceData;
|
|
40
|
+
}
|
|
21
41
|
async function fetchSimSvmBalance(address, chains, limit) {
|
|
22
42
|
if (!address)
|
|
23
43
|
throw new Error("Address is required");
|
|
@@ -28,13 +48,7 @@ async function fetchSimSvmBalance(address, chains, limit) {
|
|
|
28
48
|
if (limit) {
|
|
29
49
|
queryParams.append("limit", limit.toString());
|
|
30
50
|
}
|
|
31
|
-
|
|
32
|
-
if (queryParams.toString()) {
|
|
33
|
-
url += `?${queryParams.toString()}`;
|
|
34
|
-
}
|
|
35
|
-
if (process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY) {
|
|
36
|
-
url += `${queryParams.toString() ? "&" : "?"}localkey=${process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY}`;
|
|
37
|
-
}
|
|
51
|
+
const url = (0, simdune_1.buildSimduneUrl)(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
|
|
38
52
|
const response = await fetch(url);
|
|
39
53
|
if (!response.ok) {
|
|
40
54
|
throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
|
|
@@ -64,3 +78,21 @@ function useSimSvmBalance(address, chains, limit) {
|
|
|
64
78
|
enabled: Boolean(address),
|
|
65
79
|
});
|
|
66
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Hook to fetch a single token balance for a wallet.
|
|
83
|
+
* @param walletAddress - The wallet address to fetch balance for
|
|
84
|
+
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
85
|
+
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
86
|
+
*/
|
|
87
|
+
function useSimTokenBalance(walletAddress, tokenAddress, chainId) {
|
|
88
|
+
return (0, react_query_1.useQuery)({
|
|
89
|
+
queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
|
|
90
|
+
queryFn: () => {
|
|
91
|
+
if (!walletAddress || !tokenAddress || !chainId) {
|
|
92
|
+
throw new Error("Missing required parameters");
|
|
93
|
+
}
|
|
94
|
+
return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
|
|
95
|
+
},
|
|
96
|
+
enabled: Boolean(walletAddress) && Boolean(tokenAddress),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SimpleHashNFTResponse } from "../../../global-account/types/simplehash.types";
|
|
2
|
+
export interface SimCollectibleMetadata {
|
|
3
|
+
uri: string;
|
|
4
|
+
attributes?: Array<{
|
|
5
|
+
trait_type: string;
|
|
6
|
+
value: string;
|
|
7
|
+
display_type?: string | null;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface SimCollectibleEntry {
|
|
11
|
+
contract_address: string;
|
|
12
|
+
token_standard: "ERC721" | "ERC1155";
|
|
13
|
+
token_id: string;
|
|
14
|
+
chain: string;
|
|
15
|
+
chain_id: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
symbol?: string;
|
|
19
|
+
image_url?: string;
|
|
20
|
+
last_sale_price?: string;
|
|
21
|
+
metadata?: SimCollectibleMetadata;
|
|
22
|
+
is_spam?: boolean;
|
|
23
|
+
spam_score?: number;
|
|
24
|
+
explanations?: string[];
|
|
25
|
+
balance?: string;
|
|
26
|
+
last_acquired?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SimCollectiblesResponse {
|
|
29
|
+
address: string;
|
|
30
|
+
entries: SimCollectibleEntry[];
|
|
31
|
+
next_offset?: string;
|
|
32
|
+
request_time: string;
|
|
33
|
+
response_time: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to fetch NFT collectibles from Simdune API.
|
|
37
|
+
* Returns data in SimpleHash format for compatibility with AccountAssets component.
|
|
38
|
+
* @param address - Wallet address to fetch collectibles for
|
|
39
|
+
* @param chainIdsParam - Optional array of chain IDs to filter by
|
|
40
|
+
* @param options - Optional parameters (limit, filterSpam)
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSimCollectibles(address?: string, chainIdsParam?: number[], options?: {
|
|
43
|
+
limit?: number;
|
|
44
|
+
filterSpam?: boolean;
|
|
45
|
+
}): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;
|