@b3dotfun/sdk 0.0.11 → 0.0.12-alpha.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.
Files changed (37) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +2 -5
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
  3. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -1
  4. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
  5. package/dist/cjs/global-account/react/hooks/index.js +1 -5
  6. package/dist/cjs/global-account/react/hooks/useAccountWallet.js +2 -3
  7. package/dist/esm/anyspend/react/components/AnySpend.js +3 -6
  8. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
  9. package/dist/esm/anyspend/react/components/common/OrderDetails.js +3 -2
  10. package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
  11. package/dist/esm/global-account/react/hooks/index.js +0 -2
  12. package/dist/esm/global-account/react/hooks/useAccountWallet.js +3 -4
  13. package/dist/types/global-account/react/hooks/index.d.ts +0 -2
  14. package/package.json +22 -23
  15. package/src/anyspend/react/components/AnySpend.tsx +3 -7
  16. package/src/anyspend/react/components/AnySpendCustom.tsx +3 -3
  17. package/src/anyspend/react/components/common/OrderDetails.tsx +4 -2
  18. package/src/global-account/react/hooks/index.ts +0 -2
  19. package/src/global-account/react/hooks/useAccountWallet.tsx +3 -4
  20. package/dist/cjs/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  21. package/dist/cjs/global-account/react/hooks/useBsmntProfile.js +0 -13
  22. package/dist/cjs/global-account/react/hooks/useOnchainName.d.ts +0 -19
  23. package/dist/cjs/global-account/react/hooks/useOnchainName.js +0 -193
  24. package/dist/cjs/shared/utils/fetchBsmntProfile.d.ts +0 -1
  25. package/dist/cjs/shared/utils/fetchBsmntProfile.js +0 -26
  26. package/dist/esm/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  27. package/dist/esm/global-account/react/hooks/useBsmntProfile.js +0 -9
  28. package/dist/esm/global-account/react/hooks/useOnchainName.d.ts +0 -19
  29. package/dist/esm/global-account/react/hooks/useOnchainName.js +0 -187
  30. package/dist/esm/shared/utils/fetchBsmntProfile.d.ts +0 -1
  31. package/dist/esm/shared/utils/fetchBsmntProfile.js +0 -23
  32. package/dist/types/global-account/react/hooks/useBsmntProfile.d.ts +0 -4
  33. package/dist/types/global-account/react/hooks/useOnchainName.d.ts +0 -19
  34. package/dist/types/shared/utils/fetchBsmntProfile.d.ts +0 -1
  35. package/src/global-account/react/hooks/useBsmntProfile.ts +0 -14
  36. package/src/global-account/react/hooks/useOnchainName.tsx +0 -198
  37. package/src/shared/utils/fetchBsmntProfile.ts +0 -29
@@ -306,11 +306,8 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
306
306
  tradeType: "EXACT_INPUT",
307
307
  amount: srcAmountOnrampInWei,
308
308
  });
309
- // Replace the old ENS lookup with our new hooks
310
- const { name: recipientName } = (0, react_2.useOnchainName)(recipientAddress);
311
- // const { name: walletName } = useOnchainName(globalAddress);
312
- // Batch lookup for custom recipients
313
- // const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
309
+ const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
310
+ const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
314
311
  // Load custom recipients from local storage on mount
315
312
  (0, react_3.useEffect)(() => {
316
313
  try {
@@ -102,8 +102,8 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
102
102
  const [customRecipientAddress, setCustomRecipientAddress] = (0, react_3.useState)(recipientAddressProps);
103
103
  // Update recipient logic to use custom recipient
104
104
  const recipientAddress = customRecipientAddress || currentWallet.address;
105
- const recipientPropsProfile = (0, react_2.useBsmntProfile)({ address: recipientAddress });
106
- const recipientEnsName = recipientPropsProfile.data?.username?.replace(/\.b3\.fun/g, "");
105
+ const recipientPropsProfile = (0, react_2.useProfile)({ address: recipientAddress });
106
+ const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
107
107
  const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
108
108
  const [orderId, setOrderId] = (0, react_3.useState)(loadOrder);
109
109
  const [srcChainId, setSrcChainId] = (0, react_3.useState)(isMainnet ? chains_1.base.id : chains_1.baseSepolia.id);
@@ -130,7 +130,8 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
130
130
  const dstToken = order.metadata.dstToken;
131
131
  const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
132
132
  const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
133
- const { name: recipientName } = (0, react_1.useOnchainName)(order.recipientAddress);
133
+ const profile = (0, react_1.useProfile)({ address: order.recipientAddress });
134
+ const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
134
135
  const account = (0, react_1.useAccountWallet)();
135
136
  const { data: walletClient } = (0, wagmi_1.useWalletClient)();
136
137
  const [txHash, setTxHash] = (0, react_4.useState)();
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
24
22
  export { useQueryB3 } from "./useQueryB3";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useOnchainName = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useClaim = exports.useChainSwitchWithAction = exports.useBsmntProfile = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
3
+ exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useClaim = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
4
4
  var useAccountAssets_1 = require("./useAccountAssets");
5
5
  Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
6
6
  var useAccountWallet_1 = require("./useAccountWallet");
@@ -15,8 +15,6 @@ var useB3EnsName_1 = require("./useB3EnsName");
15
15
  Object.defineProperty(exports, "useB3EnsName", { enumerable: true, get: function () { return useB3EnsName_1.useB3EnsName; } });
16
16
  var useBestTransactionPath_1 = require("./useBestTransactionPath");
17
17
  Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get: function () { return useBestTransactionPath_1.useBestTransactionPath; } });
18
- var useBsmntProfile_1 = require("./useBsmntProfile");
19
- Object.defineProperty(exports, "useBsmntProfile", { enumerable: true, get: function () { return useBsmntProfile_1.useBsmntProfile; } });
20
18
  var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
21
19
  Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
22
20
  var useClaim_1 = require("./useClaim");
@@ -42,8 +40,6 @@ Object.defineProperty(exports, "useMediaQuery", { enumerable: true, get: functio
42
40
  var useNativeBalance_1 = require("./useNativeBalance");
43
41
  Object.defineProperty(exports, "useNativeBalance", { enumerable: true, get: function () { return useNativeBalance_1.useNativeBalance; } });
44
42
  Object.defineProperty(exports, "useNativeBalanceFromRPC", { enumerable: true, get: function () { return useNativeBalance_1.useNativeBalanceFromRPC; } });
45
- var useOnchainName_1 = require("./useOnchainName");
46
- Object.defineProperty(exports, "useOnchainName", { enumerable: true, get: function () { return useOnchainName_1.useOnchainName; } });
47
43
  var useOneBalance_1 = require("./useOneBalance");
48
44
  Object.defineProperty(exports, "useOneBalance", { enumerable: true, get: function () { return useOneBalance_1.useOneBalance; } });
49
45
  var useProfile_1 = require("./useProfile");
@@ -6,7 +6,6 @@ const constants_1 = require("../../../shared/constants");
6
6
  const react_2 = require("react");
7
7
  const react_3 = require("thirdweb/react");
8
8
  const in_app_1 = require("thirdweb/wallets/in-app");
9
- const useBsmntProfile_1 = require("./useBsmntProfile");
10
9
  function useLastAuthProvider() {
11
10
  const [lastAuthProvider, setLastAuthProvider] = (0, react_2.useState)(null);
12
11
  (0, react_2.useEffect)(() => {
@@ -32,8 +31,8 @@ function useAccountWallet() {
32
31
  const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
33
32
  ? in_app_1.socialIcons[lastAuthProvider]
34
33
  : "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
35
- const { data: profileData } = (0, useBsmntProfile_1.useBsmntProfile)({ address: account?.address });
36
- const ensName = profileData?.username?.replace(/\.b3\.fun/g, "");
34
+ const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
35
+ const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
37
36
  const avatarUrl = profileData?.avatar;
38
37
  const res = (0, react_2.useMemo)(() => ({
39
38
  wallet: {
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
4
4
  import { useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, } from "../../../anyspend/react/index.js";
5
- import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useOnchainName, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
5
+ import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
6
6
  import { cn } from "../../../shared/utils/cn.js";
7
7
  import { shortenAddress } from "../../../shared/utils/formatAddress.js";
8
8
  import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/number.js";
@@ -299,11 +299,8 @@ export function AnySpend({ destinationTokenAddress, destinationTokenChainId, isM
299
299
  tradeType: "EXACT_INPUT",
300
300
  amount: srcAmountOnrampInWei,
301
301
  });
302
- // Replace the old ENS lookup with our new hooks
303
- const { name: recipientName } = useOnchainName(recipientAddress);
304
- // const { name: walletName } = useOnchainName(globalAddress);
305
- // Batch lookup for custom recipients
306
- // const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
302
+ const recipientProfile = useProfile({ address: recipientAddress });
303
+ const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
307
304
  // Load custom recipients from local storage on mount
308
305
  useEffect(() => {
309
306
  try {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { eqci, getDefaultToken } from "../../../anyspend/index.js";
3
3
  import { RELAY_ETH_ADDRESS, USDC_BASE } from "../../../anyspend/constants/index.js";
4
4
  import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
5
- import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useBsmntProfile, useHasMounted, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
5
+ import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useHasMounted, useProfile, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
6
6
  import { cn } from "../../../shared/utils/index.js";
7
7
  import centerTruncate from "../../../shared/utils/centerTruncate.js";
8
8
  import { formatTokenAmount } from "../../../shared/utils/number.js";
@@ -96,8 +96,8 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
96
96
  const [customRecipientAddress, setCustomRecipientAddress] = useState(recipientAddressProps);
97
97
  // Update recipient logic to use custom recipient
98
98
  const recipientAddress = customRecipientAddress || currentWallet.address;
99
- const recipientPropsProfile = useBsmntProfile({ address: recipientAddress });
100
- const recipientEnsName = recipientPropsProfile.data?.username?.replace(/\.b3\.fun/g, "");
99
+ const recipientPropsProfile = useProfile({ address: recipientAddress });
100
+ const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
101
101
  const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
102
102
  const [orderId, setOrderId] = useState(loadOrder);
103
103
  const [srcChainId, setSrcChainId] = useState(isMainnet ? base.id : baseSepolia.id);
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { ALL_CHAINS, capitalizeFirstLetter, EVM_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, RELAY_ETH_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID, } from "../../../../anyspend/index.js";
4
- import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useChainSwitchWithAction, useModalStore, useOnchainName, } from "../../../../global-account/react/index.js";
4
+ import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useChainSwitchWithAction, useModalStore, useProfile, } from "../../../../global-account/react/index.js";
5
5
  import { useRouter, useSearchParams } from "../../../../shared/react/hooks/index.js";
6
6
  import { cn } from "../../../../shared/utils/index.js";
7
7
  import centerTruncate from "../../../../shared/utils/centerTruncate.js";
@@ -124,7 +124,8 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
124
124
  const dstToken = order.metadata.dstToken;
125
125
  const nft = order.type === "mint_nft" ? order.metadata.nft : undefined;
126
126
  const tournament = order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
127
- const { name: recipientName } = useOnchainName(order.recipientAddress);
127
+ const profile = useProfile({ address: order.recipientAddress });
128
+ const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
128
129
  const account = useAccountWallet();
129
130
  const { data: walletClient } = useWalletClient();
130
131
  const [txHash, setTxHash] = useState();
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
24
22
  export { useQueryB3 } from "./useQueryB3";
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication.js";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
6
6
  export { useB3EnsName } from "./useB3EnsName.js";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath.js";
8
- export { useBsmntProfile } from "./useBsmntProfile.js";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
10
9
  export { useClaim } from "./useClaim.js";
11
10
  export { useConnect } from "./useConnect.js";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile.js";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
19
18
  export { useMediaQuery } from "./useMediaQuery.js";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance.js";
21
- export { useOnchainName } from "./useOnchainName.js";
22
20
  export { useOneBalance } from "./useOneBalance.js";
23
21
  export { useProfile, useProfilePreference, } from "./useProfile.js";
24
22
  export { useQueryB3 } from "./useQueryB3.js";
@@ -1,9 +1,8 @@
1
- import { useB3 } from "../../../global-account/react/index.js";
1
+ import { useB3, useProfile } from "../../../global-account/react/index.js";
2
2
  import { ecosystemWalletId } from "../../../shared/constants/index.js";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
5
5
  import { socialIcons } from "thirdweb/wallets/in-app";
6
- import { useBsmntProfile } from "./useBsmntProfile.js";
7
6
  function useLastAuthProvider() {
8
7
  const [lastAuthProvider, setLastAuthProvider] = useState(null);
9
8
  useEffect(() => {
@@ -29,8 +28,8 @@ export function useAccountWallet() {
29
28
  const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
30
29
  ? socialIcons[lastAuthProvider]
31
30
  : "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
32
- const { data: profileData } = useBsmntProfile({ address: account?.address });
33
- const ensName = profileData?.username?.replace(/\.b3\.fun/g, "");
31
+ const { data: profileData } = useProfile({ address: account?.address });
32
+ const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
34
33
  const avatarUrl = profileData?.avatar;
35
34
  const res = useMemo(() => ({
36
35
  wallet: {
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
24
22
  export { useQueryB3 } from "./useQueryB3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.12-alpha.1",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -189,27 +189,6 @@
189
189
  "utils",
190
190
  "constants"
191
191
  ],
192
- "scripts": {
193
- "clean": "rm -rf dist",
194
- "prebuild": "pnpm clean",
195
- "fix-dist": "[ -d ./dist/react/src ] && cp -r ./dist/react/src/* ./dist/ && rm -rf ./dist/react || echo \"No react directory found\"",
196
- "build": "pnpm clean && pnpm lint && pnpm build:types && pnpm build:cjs && pnpm build:esm && pnpm build:css",
197
- "build:types": "tsc -p tsconfig.cjs.json --emitDeclarationOnly --declarationDir dist/types",
198
- "build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/",
199
- "build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && node scripts/fix-esm-imports.js",
200
- "build:css": "postcss src/styles/index.css -o dist/styles/index.css",
201
- "dev:cjs": "tsc-watch -p tsconfig.cjs.json --onSuccess \"tsc-alias -p tsconfig.cjs.json --outDir dist/cjs\"",
202
- "dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
203
- "dev": "concurrently \"pnpm dev:cjs\" \"pnpm dev:esm\" \"pnpm dev:css\"",
204
- "dev:css": "postcss src/styles/index.css -o dist/styles/index.css --watch",
205
- "prepublishOnly": "pnpm build",
206
- "release:test": "pnpm version prerelease --preid test && git push --follow-tags && pnpm publish --tag test --no-git-checks",
207
- "release:alpha": "pnpm version prerelease --preid alpha && git push --follow-tags && pnpm publish --tag alpha --no-git-checks",
208
- "typecheck": "tsc --noEmit",
209
- "generate:thirdweb": "npx @hey-api/openapi-ts --file src/thirdweb/openapi-ts.config.ts --input src/thirdweb/insight-service.json",
210
- "lint": "eslint 'src/**/*.{ts,tsx}'",
211
- "lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix"
212
- },
213
192
  "dependencies": {
214
193
  "@amplitude/analytics-browser": "2.14.0",
215
194
  "@b3dotfun/b3-api": "0.0.28",
@@ -327,5 +306,25 @@
327
306
  "three": {
328
307
  "optional": true
329
308
  }
309
+ },
310
+ "scripts": {
311
+ "clean": "rm -rf dist",
312
+ "prebuild": "pnpm clean",
313
+ "fix-dist": "[ -d ./dist/react/src ] && cp -r ./dist/react/src/* ./dist/ && rm -rf ./dist/react || echo \"No react directory found\"",
314
+ "build": "pnpm clean && pnpm lint && pnpm build:types && pnpm build:cjs && pnpm build:esm && pnpm build:css",
315
+ "build:types": "tsc -p tsconfig.cjs.json --emitDeclarationOnly --declarationDir dist/types",
316
+ "build:cjs": "tsc -p tsconfig.cjs.json --outDir dist/cjs --module commonjs && tsc-alias -p tsconfig.cjs.json --outDir dist/cjs && mkdir -p dist/cjs/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/cjs/shared/generated/",
317
+ "build:esm": "tsc -p tsconfig.esm.json --outDir dist/esm --module esnext && tsc-alias -p tsconfig.esm.json --outDir dist/esm && mkdir -p dist/esm/shared/generated && cp src/shared/generated/chain-networks.json src/shared/generated/coingecko-chains.json dist/esm/shared/generated/ && node scripts/fix-esm-imports.js",
318
+ "build:css": "postcss src/styles/index.css -o dist/styles/index.css",
319
+ "dev:cjs": "tsc-watch -p tsconfig.cjs.json --onSuccess \"tsc-alias -p tsconfig.cjs.json --outDir dist/cjs\"",
320
+ "dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
321
+ "dev": "concurrently \"pnpm dev:cjs\" \"pnpm dev:esm\" \"pnpm dev:css\"",
322
+ "dev:css": "postcss src/styles/index.css -o dist/styles/index.css --watch",
323
+ "release:test": "pnpm version prerelease --preid test && git push --follow-tags && pnpm publish --tag test --no-git-checks",
324
+ "release:alpha": "pnpm version prerelease --preid alpha && git push --follow-tags && pnpm publish --tag alpha --no-git-checks",
325
+ "typecheck": "tsc --noEmit",
326
+ "generate:thirdweb": "npx @hey-api/openapi-ts --file src/thirdweb/openapi-ts.config.ts --input src/thirdweb/insight-service.json",
327
+ "lint": "eslint 'src/**/*.{ts,tsx}'",
328
+ "lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix"
330
329
  }
331
- }
330
+ }
@@ -12,7 +12,7 @@ import {
12
12
  StyleRoot,
13
13
  TransitionPanel,
14
14
  useAccountWallet,
15
- useOnchainName,
15
+ useProfile,
16
16
  useRouter,
17
17
  useSearchParamsSSR,
18
18
  useTokenData,
@@ -405,12 +405,8 @@ export function AnySpend({
405
405
  },
406
406
  );
407
407
 
408
- // Replace the old ENS lookup with our new hooks
409
- const { name: recipientName } = useOnchainName(recipientAddress);
410
- // const { name: walletName } = useOnchainName(globalAddress);
411
-
412
- // Batch lookup for custom recipients
413
- // const { names: customRecipientNames } = useOnchainNames(customRecipients.map(r => r.address));
408
+ const recipientProfile = useProfile({ address: recipientAddress });
409
+ const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
414
410
 
415
411
  // Load custom recipients from local storage on mount
416
412
  useEffect(() => {
@@ -30,8 +30,8 @@ import {
30
30
  TooltipTrigger,
31
31
  TransitionPanel,
32
32
  useAccountWallet,
33
- useBsmntProfile,
34
33
  useHasMounted,
34
+ useProfile,
35
35
  useRouter,
36
36
  useSearchParamsSSR,
37
37
  useTokenBalancesByChain,
@@ -201,8 +201,8 @@ export function AnySpendCustom({
201
201
 
202
202
  // Update recipient logic to use custom recipient
203
203
  const recipientAddress = customRecipientAddress || currentWallet.address;
204
- const recipientPropsProfile = useBsmntProfile({ address: recipientAddress });
205
- const recipientEnsName = recipientPropsProfile.data?.username?.replace(/\.b3\.fun/g, "");
204
+ const recipientPropsProfile = useProfile({ address: recipientAddress });
205
+ const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
206
206
  const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
207
207
 
208
208
  const [orderId, setOrderId] = useState<string | undefined>(loadOrder);
@@ -25,7 +25,7 @@ import {
25
25
  useAccountWallet,
26
26
  useChainSwitchWithAction,
27
27
  useModalStore,
28
- useOnchainName,
28
+ useProfile,
29
29
  } from "@b3dotfun/sdk/global-account/react";
30
30
  import { useRouter, useSearchParams } from "@b3dotfun/sdk/shared/react/hooks";
31
31
  import { cn } from "@b3dotfun/sdk/shared/utils";
@@ -218,7 +218,9 @@ export const OrderDetails = memo(function OrderDetails({
218
218
  const tournament =
219
219
  order.type === "join_tournament" || order.type === "fund_tournament" ? order.metadata.tournament : undefined;
220
220
 
221
- const { name: recipientName } = useOnchainName(order.recipientAddress);
221
+ const profile = useProfile({ address: order.recipientAddress });
222
+ const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
223
+
222
224
  const account = useAccountWallet();
223
225
 
224
226
  const { data: walletClient } = useWalletClient();
@@ -5,7 +5,6 @@ export { useAuthentication } from "./useAuthentication";
5
5
  export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
6
6
  export { useB3EnsName } from "./useB3EnsName";
7
7
  export { useBestTransactionPath } from "./useBestTransactionPath";
8
- export { useBsmntProfile } from "./useBsmntProfile";
9
8
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
9
  export { useClaim } from "./useClaim";
11
10
  export { useConnect } from "./useConnect";
@@ -18,7 +17,6 @@ export { useIsMobile } from "./useIsMobile";
18
17
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
19
18
  export { useMediaQuery } from "./useMediaQuery";
20
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
21
- export { useOnchainName } from "./useOnchainName";
22
20
  export { useOneBalance } from "./useOneBalance";
23
21
  export {
24
22
  useProfile,
@@ -1,10 +1,9 @@
1
- import { useB3 } from "@b3dotfun/sdk/global-account/react";
1
+ import { useB3, useProfile } from "@b3dotfun/sdk/global-account/react";
2
2
  import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
5
5
  import { Account, Wallet } from "thirdweb/wallets";
6
6
  import { socialIcons } from "thirdweb/wallets/in-app";
7
- import { useBsmntProfile } from "./useBsmntProfile";
8
7
 
9
8
  function useLastAuthProvider(): string | null {
10
9
  const [lastAuthProvider, setLastAuthProvider] = useState<string | null>(null);
@@ -62,8 +61,8 @@ export function useAccountWallet(): {
62
61
  ? socialIcons[lastAuthProvider as keyof typeof socialIcons]
63
62
  : "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
64
63
 
65
- const { data: profileData } = useBsmntProfile({ address: account?.address });
66
- const ensName = profileData?.username?.replace(/\.b3\.fun/g, "");
64
+ const { data: profileData } = useProfile({ address: account?.address });
65
+ const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
67
66
  const avatarUrl = profileData?.avatar;
68
67
 
69
68
  const res = useMemo(
@@ -1,4 +0,0 @@
1
- export interface UseProfileOptions {
2
- address?: string;
3
- }
4
- export declare const useBsmntProfile: ({ address }: UseProfileOptions) => import("@tanstack/react-query").UseQueryResult<any, Error>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBsmntProfile = void 0;
4
- const fetchBsmntProfile_1 = require("../../../shared/utils/fetchBsmntProfile");
5
- const react_query_1 = require("@tanstack/react-query");
6
- const useBsmntProfile = ({ address }) => {
7
- return (0, react_query_1.useQuery)({
8
- queryKey: ["useBsmntProfile", address],
9
- queryFn: () => (0, fetchBsmntProfile_1.fetchBsmntProfile)(undefined, address),
10
- enabled: !!address,
11
- });
12
- };
13
- exports.useBsmntProfile = useBsmntProfile;
@@ -1,19 +0,0 @@
1
- export declare function useOnchainName(address: string | undefined): {
2
- name: any;
3
- isLoading: boolean;
4
- b3Name: string | null | undefined;
5
- ensName: any;
6
- };
7
- export declare function useOnchainNames(addresses: string[]): {
8
- names: any[];
9
- isLoading: boolean;
10
- };
11
- export declare function useResolveOnchainName(name: string | undefined): {
12
- address: any;
13
- isLoading: boolean;
14
- };
15
- export declare function useOnchainPFP(name: string | undefined): {
16
- pfp: any;
17
- isLoading: boolean;
18
- address: any;
19
- };
@@ -1,193 +0,0 @@
1
- "use strict";
2
- "use client";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useOnchainName = useOnchainName;
5
- exports.useOnchainNames = useOnchainNames;
6
- exports.useResolveOnchainName = useResolveOnchainName;
7
- exports.useOnchainPFP = useOnchainPFP;
8
- const b3Ens_1 = require("../../../shared/utils/b3Ens");
9
- const fetchBsmntProfile_1 = require("../../../shared/utils/fetchBsmntProfile");
10
- const react_query_1 = require("@tanstack/react-query");
11
- function useOnchainName(address) {
12
- const { data: bsmntName, isLoading: isLoadingBsmnt } = (0, react_query_1.useQuery)({
13
- queryKey: ["useOnchainName/bsmntName", address?.toLowerCase()],
14
- queryFn: async () => {
15
- if (!address)
16
- return null;
17
- try {
18
- const response = await (0, fetchBsmntProfile_1.fetchBsmntProfile)(undefined, address);
19
- return response?.username?.replace(/\.b3\.fun/g, "") || null;
20
- }
21
- catch (error) {
22
- return null;
23
- }
24
- },
25
- enabled: !!address,
26
- });
27
- const { data: b3Name, isLoading: isLoadingB3 } = (0, react_query_1.useQuery)({
28
- queryKey: ["b3-name", address?.toLowerCase()],
29
- queryFn: async () => {
30
- if (!address)
31
- return null;
32
- try {
33
- const response = await (0, b3Ens_1.getB3NameByAddress)(address);
34
- return response?.name?.replace(/\.b3\.fun/g, "") || null;
35
- }
36
- catch (error) {
37
- return null;
38
- }
39
- },
40
- enabled: !!address,
41
- });
42
- const { data: ensName, isLoading: isLoadingEns } = (0, react_query_1.useQuery)({
43
- queryKey: ["ens-name", address?.toLowerCase()],
44
- queryFn: async () => {
45
- if (!address)
46
- return null;
47
- try {
48
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
49
- const response = await fetch(corsProxyUrl);
50
- const data = await response.json();
51
- return data?.ens || null;
52
- }
53
- catch (error) {
54
- console.error("Error fetching ENS name:", error);
55
- return null;
56
- }
57
- },
58
- enabled: !!address,
59
- });
60
- return {
61
- name: bsmntName || b3Name || ensName || null,
62
- isLoading: isLoadingBsmnt || isLoadingB3 || isLoadingEns,
63
- b3Name,
64
- ensName,
65
- };
66
- }
67
- function useOnchainNames(addresses) {
68
- const queries = addresses.map(address => ({
69
- queryKey: ["onchain-name", address.toLowerCase()],
70
- queryFn: async () => {
71
- try {
72
- // Try B3 name first
73
- const b3Response = await (0, b3Ens_1.getB3NameByAddress)(address);
74
- if (b3Response?.name) {
75
- return b3Response.name;
76
- }
77
- // Fall back to ENS
78
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
79
- const ensResponse = await fetch(corsProxyUrl);
80
- const ensData = await ensResponse.json();
81
- return ensData?.ens || null;
82
- }
83
- catch (error) {
84
- console.error("Error fetching onchain name:", error);
85
- return null;
86
- }
87
- },
88
- enabled: !!address,
89
- }));
90
- const results = (0, react_query_1.useQueries)({ queries });
91
- return {
92
- names: results.map(result => result.data),
93
- isLoading: results.some(result => result.isLoading),
94
- };
95
- }
96
- // Add a new hook to resolve ENS/B3 names to addresses
97
- function useResolveOnchainName(name) {
98
- const { data: address, isLoading } = (0, react_query_1.useQuery)({
99
- queryKey: ["name-resolve", name?.toLowerCase()],
100
- queryFn: async () => {
101
- if (!name)
102
- return null;
103
- try {
104
- const isB3Name = name.startsWith("@") || name.toLowerCase().endsWith(".b3");
105
- if (isB3Name) {
106
- // If contains and @, remove @ and add .b3.fun
107
- if (name.includes("@")) {
108
- name = name.replace("@", "").replace(".b3.fun", "") + ".b3.fun";
109
- }
110
- // Try B3 name resolution first
111
- try {
112
- const b3Response = await (0, b3Ens_1.getEnsName)(name);
113
- const b3Data = await b3Response.json();
114
- if (b3Data?.addresses?.["60"]) {
115
- return b3Data.addresses["60"];
116
- }
117
- }
118
- catch (error) { }
119
- // Fall back to ENS only if it's a .b3 name (not @)
120
- if (!name.startsWith("@")) {
121
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
122
- const ensResponse = await fetch(corsProxyUrl);
123
- const ensData = await ensResponse.json();
124
- return ensData?.address || null;
125
- }
126
- return null;
127
- }
128
- else {
129
- // Try ENS resolution first
130
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
131
- const ensResponse = await fetch(corsProxyUrl);
132
- const ensData = await ensResponse.json();
133
- if (ensData?.address) {
134
- return ensData.address;
135
- }
136
- // Fall back to B3 name resolution
137
- try {
138
- const b3Response = await (0, b3Ens_1.getEnsName)(name.replace("@", "").replace(".b3.fun", "").replace(".b3", "") + ".b3.fun");
139
- const b3Data = await b3Response.json();
140
- return b3Data?.addresses?.["60"] || null;
141
- }
142
- catch (error) {
143
- return null;
144
- }
145
- }
146
- }
147
- catch (error) {
148
- console.error("Error resolving name:", error);
149
- return null;
150
- }
151
- },
152
- enabled: !!name,
153
- });
154
- return {
155
- address,
156
- isLoading,
157
- };
158
- }
159
- // Add a new hook to fetch ENS profile image
160
- function useOnchainPFP(name) {
161
- const { address } = useResolveOnchainName(name);
162
- const { data: pfp, isLoading } = (0, react_query_1.useQuery)({
163
- queryKey: ["ens-pfp", name?.toLowerCase()],
164
- queryFn: async () => {
165
- if (!name)
166
- return null;
167
- try {
168
- // First try ENS avatar
169
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
170
- const response = await fetch(corsProxyUrl);
171
- const data = await response.json();
172
- if (data?.avatar) {
173
- // If it's an IPFS URL, convert it to a gateway URL
174
- if (data.avatar.startsWith("ipfs://")) {
175
- return data.avatar.replace("ipfs://", "https://ipfs.io/ipfs/");
176
- }
177
- return data.avatar;
178
- }
179
- return null;
180
- }
181
- catch (error) {
182
- console.error("Error fetching ENS PFP:", error);
183
- return null;
184
- }
185
- },
186
- enabled: !!name,
187
- });
188
- return {
189
- pfp,
190
- isLoading,
191
- address,
192
- };
193
- }
@@ -1 +0,0 @@
1
- export declare function fetchBsmntProfile(username?: string, address?: string): Promise<any>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchBsmntProfile = fetchBsmntProfile;
4
- const baseUrl = process.env.NEXT_PUBLIC_BASEMENT_API_URL ||
5
- process.env.NEXT_PUBLIC_FEATHERS_API ||
6
- "https://basement-feathers-api-production.up.railway.app";
7
- async function fetchBsmntProfile(username, address) {
8
- let response;
9
- const queryUsername = username?.includes(".b3.fun") ? username : `${username}.b3.fun`;
10
- try {
11
- if (username) {
12
- response = await fetch(`${baseUrl}/profiles/?username=${queryUsername}`);
13
- }
14
- else if (address) {
15
- response = await fetch(`${baseUrl}/profiles/?linkedAccounts[$elemMatch][normalizedAddress]=${String(address).toLowerCase() || ""}`);
16
- }
17
- const json = await response?.json();
18
- if (json.data.length == 0)
19
- throw new Error(`Profile not found`);
20
- return json.data[0];
21
- }
22
- catch (error) {
23
- console.error("Error fetching profile", error);
24
- throw error;
25
- }
26
- }
@@ -1,4 +0,0 @@
1
- export interface UseProfileOptions {
2
- address?: string;
3
- }
4
- export declare const useBsmntProfile: ({ address }: UseProfileOptions) => import("@tanstack/react-query").UseQueryResult<any, Error>;
@@ -1,9 +0,0 @@
1
- import { fetchBsmntProfile } from "../../../shared/utils/fetchBsmntProfile.js";
2
- import { useQuery } from "@tanstack/react-query";
3
- export const useBsmntProfile = ({ address }) => {
4
- return useQuery({
5
- queryKey: ["useBsmntProfile", address],
6
- queryFn: () => fetchBsmntProfile(undefined, address),
7
- enabled: !!address,
8
- });
9
- };
@@ -1,19 +0,0 @@
1
- export declare function useOnchainName(address: string | undefined): {
2
- name: any;
3
- isLoading: boolean;
4
- b3Name: string | null | undefined;
5
- ensName: any;
6
- };
7
- export declare function useOnchainNames(addresses: string[]): {
8
- names: any[];
9
- isLoading: boolean;
10
- };
11
- export declare function useResolveOnchainName(name: string | undefined): {
12
- address: any;
13
- isLoading: boolean;
14
- };
15
- export declare function useOnchainPFP(name: string | undefined): {
16
- pfp: any;
17
- isLoading: boolean;
18
- address: any;
19
- };
@@ -1,187 +0,0 @@
1
- "use client";
2
- import { getB3NameByAddress, getEnsName } from "../../../shared/utils/b3Ens.js";
3
- import { fetchBsmntProfile } from "../../../shared/utils/fetchBsmntProfile.js";
4
- import { useQueries, useQuery } from "@tanstack/react-query";
5
- export function useOnchainName(address) {
6
- const { data: bsmntName, isLoading: isLoadingBsmnt } = useQuery({
7
- queryKey: ["useOnchainName/bsmntName", address?.toLowerCase()],
8
- queryFn: async () => {
9
- if (!address)
10
- return null;
11
- try {
12
- const response = await fetchBsmntProfile(undefined, address);
13
- return response?.username?.replace(/\.b3\.fun/g, "") || null;
14
- }
15
- catch (error) {
16
- return null;
17
- }
18
- },
19
- enabled: !!address,
20
- });
21
- const { data: b3Name, isLoading: isLoadingB3 } = useQuery({
22
- queryKey: ["b3-name", address?.toLowerCase()],
23
- queryFn: async () => {
24
- if (!address)
25
- return null;
26
- try {
27
- const response = await getB3NameByAddress(address);
28
- return response?.name?.replace(/\.b3\.fun/g, "") || null;
29
- }
30
- catch (error) {
31
- return null;
32
- }
33
- },
34
- enabled: !!address,
35
- });
36
- const { data: ensName, isLoading: isLoadingEns } = useQuery({
37
- queryKey: ["ens-name", address?.toLowerCase()],
38
- queryFn: async () => {
39
- if (!address)
40
- return null;
41
- try {
42
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
43
- const response = await fetch(corsProxyUrl);
44
- const data = await response.json();
45
- return data?.ens || null;
46
- }
47
- catch (error) {
48
- console.error("Error fetching ENS name:", error);
49
- return null;
50
- }
51
- },
52
- enabled: !!address,
53
- });
54
- return {
55
- name: bsmntName || b3Name || ensName || null,
56
- isLoading: isLoadingBsmnt || isLoadingB3 || isLoadingEns,
57
- b3Name,
58
- ensName,
59
- };
60
- }
61
- export function useOnchainNames(addresses) {
62
- const queries = addresses.map(address => ({
63
- queryKey: ["onchain-name", address.toLowerCase()],
64
- queryFn: async () => {
65
- try {
66
- // Try B3 name first
67
- const b3Response = await getB3NameByAddress(address);
68
- if (b3Response?.name) {
69
- return b3Response.name;
70
- }
71
- // Fall back to ENS
72
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
73
- const ensResponse = await fetch(corsProxyUrl);
74
- const ensData = await ensResponse.json();
75
- return ensData?.ens || null;
76
- }
77
- catch (error) {
78
- console.error("Error fetching onchain name:", error);
79
- return null;
80
- }
81
- },
82
- enabled: !!address,
83
- }));
84
- const results = useQueries({ queries });
85
- return {
86
- names: results.map(result => result.data),
87
- isLoading: results.some(result => result.isLoading),
88
- };
89
- }
90
- // Add a new hook to resolve ENS/B3 names to addresses
91
- export function useResolveOnchainName(name) {
92
- const { data: address, isLoading } = useQuery({
93
- queryKey: ["name-resolve", name?.toLowerCase()],
94
- queryFn: async () => {
95
- if (!name)
96
- return null;
97
- try {
98
- const isB3Name = name.startsWith("@") || name.toLowerCase().endsWith(".b3");
99
- if (isB3Name) {
100
- // If contains and @, remove @ and add .b3.fun
101
- if (name.includes("@")) {
102
- name = name.replace("@", "").replace(".b3.fun", "") + ".b3.fun";
103
- }
104
- // Try B3 name resolution first
105
- try {
106
- const b3Response = await getEnsName(name);
107
- const b3Data = await b3Response.json();
108
- if (b3Data?.addresses?.["60"]) {
109
- return b3Data.addresses["60"];
110
- }
111
- }
112
- catch (error) { }
113
- // Fall back to ENS only if it's a .b3 name (not @)
114
- if (!name.startsWith("@")) {
115
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
116
- const ensResponse = await fetch(corsProxyUrl);
117
- const ensData = await ensResponse.json();
118
- return ensData?.address || null;
119
- }
120
- return null;
121
- }
122
- else {
123
- // Try ENS resolution first
124
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
125
- const ensResponse = await fetch(corsProxyUrl);
126
- const ensData = await ensResponse.json();
127
- if (ensData?.address) {
128
- return ensData.address;
129
- }
130
- // Fall back to B3 name resolution
131
- try {
132
- const b3Response = await getEnsName(name.replace("@", "").replace(".b3.fun", "").replace(".b3", "") + ".b3.fun");
133
- const b3Data = await b3Response.json();
134
- return b3Data?.addresses?.["60"] || null;
135
- }
136
- catch (error) {
137
- return null;
138
- }
139
- }
140
- }
141
- catch (error) {
142
- console.error("Error resolving name:", error);
143
- return null;
144
- }
145
- },
146
- enabled: !!name,
147
- });
148
- return {
149
- address,
150
- isLoading,
151
- };
152
- }
153
- // Add a new hook to fetch ENS profile image
154
- export function useOnchainPFP(name) {
155
- const { address } = useResolveOnchainName(name);
156
- const { data: pfp, isLoading } = useQuery({
157
- queryKey: ["ens-pfp", name?.toLowerCase()],
158
- queryFn: async () => {
159
- if (!name)
160
- return null;
161
- try {
162
- // First try ENS avatar
163
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
164
- const response = await fetch(corsProxyUrl);
165
- const data = await response.json();
166
- if (data?.avatar) {
167
- // If it's an IPFS URL, convert it to a gateway URL
168
- if (data.avatar.startsWith("ipfs://")) {
169
- return data.avatar.replace("ipfs://", "https://ipfs.io/ipfs/");
170
- }
171
- return data.avatar;
172
- }
173
- return null;
174
- }
175
- catch (error) {
176
- console.error("Error fetching ENS PFP:", error);
177
- return null;
178
- }
179
- },
180
- enabled: !!name,
181
- });
182
- return {
183
- pfp,
184
- isLoading,
185
- address,
186
- };
187
- }
@@ -1 +0,0 @@
1
- export declare function fetchBsmntProfile(username?: string, address?: string): Promise<any>;
@@ -1,23 +0,0 @@
1
- const baseUrl = process.env.NEXT_PUBLIC_BASEMENT_API_URL ||
2
- process.env.NEXT_PUBLIC_FEATHERS_API ||
3
- "https://basement-feathers-api-production.up.railway.app";
4
- export async function fetchBsmntProfile(username, address) {
5
- let response;
6
- const queryUsername = username?.includes(".b3.fun") ? username : `${username}.b3.fun`;
7
- try {
8
- if (username) {
9
- response = await fetch(`${baseUrl}/profiles/?username=${queryUsername}`);
10
- }
11
- else if (address) {
12
- response = await fetch(`${baseUrl}/profiles/?linkedAccounts[$elemMatch][normalizedAddress]=${String(address).toLowerCase() || ""}`);
13
- }
14
- const json = await response?.json();
15
- if (json.data.length == 0)
16
- throw new Error(`Profile not found`);
17
- return json.data[0];
18
- }
19
- catch (error) {
20
- console.error("Error fetching profile", error);
21
- throw error;
22
- }
23
- }
@@ -1,4 +0,0 @@
1
- export interface UseProfileOptions {
2
- address?: string;
3
- }
4
- export declare const useBsmntProfile: ({ address }: UseProfileOptions) => import("@tanstack/react-query").UseQueryResult<any, Error>;
@@ -1,19 +0,0 @@
1
- export declare function useOnchainName(address: string | undefined): {
2
- name: any;
3
- isLoading: boolean;
4
- b3Name: string | null | undefined;
5
- ensName: any;
6
- };
7
- export declare function useOnchainNames(addresses: string[]): {
8
- names: any[];
9
- isLoading: boolean;
10
- };
11
- export declare function useResolveOnchainName(name: string | undefined): {
12
- address: any;
13
- isLoading: boolean;
14
- };
15
- export declare function useOnchainPFP(name: string | undefined): {
16
- pfp: any;
17
- isLoading: boolean;
18
- address: any;
19
- };
@@ -1 +0,0 @@
1
- export declare function fetchBsmntProfile(username?: string, address?: string): Promise<any>;
@@ -1,14 +0,0 @@
1
- import { fetchBsmntProfile } from "@b3dotfun/sdk/shared/utils/fetchBsmntProfile";
2
- import { useQuery } from "@tanstack/react-query";
3
-
4
- export interface UseProfileOptions {
5
- address?: string;
6
- }
7
-
8
- export const useBsmntProfile = ({ address }: UseProfileOptions) => {
9
- return useQuery({
10
- queryKey: ["useBsmntProfile", address],
11
- queryFn: () => fetchBsmntProfile(undefined, address),
12
- enabled: !!address,
13
- });
14
- };
@@ -1,198 +0,0 @@
1
- "use client";
2
-
3
- import { getB3NameByAddress, getEnsName } from "@b3dotfun/sdk/shared/utils/b3Ens";
4
- import { fetchBsmntProfile } from "@b3dotfun/sdk/shared/utils/fetchBsmntProfile";
5
- import { useQueries, useQuery } from "@tanstack/react-query";
6
-
7
- export function useOnchainName(address: string | undefined) {
8
- const { data: bsmntName, isLoading: isLoadingBsmnt } = useQuery({
9
- queryKey: ["useOnchainName/bsmntName", address?.toLowerCase()],
10
- queryFn: async () => {
11
- if (!address) return null;
12
- try {
13
- const response = await fetchBsmntProfile(undefined, address);
14
- return response?.username?.replace(/\.b3\.fun/g, "") || null;
15
- } catch (error) {
16
- return null;
17
- }
18
- },
19
- enabled: !!address,
20
- });
21
-
22
- const { data: b3Name, isLoading: isLoadingB3 } = useQuery({
23
- queryKey: ["b3-name", address?.toLowerCase()],
24
- queryFn: async () => {
25
- if (!address) return null;
26
- try {
27
- const response = await getB3NameByAddress(address);
28
- return response?.name?.replace(/\.b3\.fun/g, "") || null;
29
- } catch (error) {
30
- return null;
31
- }
32
- },
33
- enabled: !!address,
34
- });
35
-
36
- const { data: ensName, isLoading: isLoadingEns } = useQuery({
37
- queryKey: ["ens-name", address?.toLowerCase()],
38
- queryFn: async () => {
39
- if (!address) return null;
40
- try {
41
- const corsProxyUrl =
42
- "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
43
- const response = await fetch(corsProxyUrl);
44
- const data = await response.json();
45
- return data?.ens || null;
46
- } catch (error) {
47
- console.error("Error fetching ENS name:", error);
48
- return null;
49
- }
50
- },
51
- enabled: !!address,
52
- });
53
-
54
- return {
55
- name: bsmntName || b3Name || ensName || null,
56
- isLoading: isLoadingBsmnt || isLoadingB3 || isLoadingEns,
57
- b3Name,
58
- ensName,
59
- };
60
- }
61
-
62
- export function useOnchainNames(addresses: string[]) {
63
- const queries = addresses.map(address => ({
64
- queryKey: ["onchain-name", address.toLowerCase()],
65
- queryFn: async () => {
66
- try {
67
- // Try B3 name first
68
- const b3Response = await getB3NameByAddress(address);
69
- if (b3Response?.name) {
70
- return b3Response.name;
71
- }
72
-
73
- // Fall back to ENS
74
- const corsProxyUrl =
75
- "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${address}`);
76
- const ensResponse = await fetch(corsProxyUrl);
77
- const ensData = await ensResponse.json();
78
- return ensData?.ens || null;
79
- } catch (error) {
80
- console.error("Error fetching onchain name:", error);
81
- return null;
82
- }
83
- },
84
- enabled: !!address,
85
- }));
86
-
87
- const results = useQueries({ queries });
88
-
89
- return {
90
- names: results.map(result => result.data),
91
- isLoading: results.some(result => result.isLoading),
92
- };
93
- }
94
-
95
- // Add a new hook to resolve ENS/B3 names to addresses
96
- export function useResolveOnchainName(name: string | undefined) {
97
- const { data: address, isLoading } = useQuery({
98
- queryKey: ["name-resolve", name?.toLowerCase()],
99
- queryFn: async () => {
100
- if (!name) return null;
101
- try {
102
- const isB3Name = name.startsWith("@") || name.toLowerCase().endsWith(".b3");
103
-
104
- if (isB3Name) {
105
- // If contains and @, remove @ and add .b3.fun
106
- if (name.includes("@")) {
107
- name = name.replace("@", "").replace(".b3.fun", "") + ".b3.fun";
108
- }
109
-
110
- // Try B3 name resolution first
111
- try {
112
- const b3Response = await getEnsName(name);
113
- const b3Data = await b3Response.json();
114
- if (b3Data?.addresses?.["60"]) {
115
- return b3Data.addresses["60"];
116
- }
117
- } catch (error) {}
118
-
119
- // Fall back to ENS only if it's a .b3 name (not @)
120
- if (!name.startsWith("@")) {
121
- const corsProxyUrl =
122
- "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
123
- const ensResponse = await fetch(corsProxyUrl);
124
- const ensData = await ensResponse.json();
125
- return ensData?.address || null;
126
- }
127
- return null;
128
- } else {
129
- // Try ENS resolution first
130
- const corsProxyUrl =
131
- "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
132
- const ensResponse = await fetch(corsProxyUrl);
133
- const ensData = await ensResponse.json();
134
- if (ensData?.address) {
135
- return ensData.address;
136
- }
137
-
138
- // Fall back to B3 name resolution
139
- try {
140
- const b3Response = await getEnsName(
141
- name.replace("@", "").replace(".b3.fun", "").replace(".b3", "") + ".b3.fun",
142
- );
143
- const b3Data = await b3Response.json();
144
- return b3Data?.addresses?.["60"] || null;
145
- } catch (error) {
146
- return null;
147
- }
148
- }
149
- } catch (error) {
150
- console.error("Error resolving name:", error);
151
- return null;
152
- }
153
- },
154
- enabled: !!name,
155
- });
156
-
157
- return {
158
- address,
159
- isLoading,
160
- };
161
- }
162
-
163
- // Add a new hook to fetch ENS profile image
164
- export function useOnchainPFP(name: string | undefined) {
165
- const { address } = useResolveOnchainName(name);
166
-
167
- const { data: pfp, isLoading } = useQuery({
168
- queryKey: ["ens-pfp", name?.toLowerCase()],
169
- queryFn: async () => {
170
- if (!name) return null;
171
- try {
172
- // First try ENS avatar
173
- const corsProxyUrl = "https://proxy.basement.fun/?url=" + encodeURIComponent(`https://api.ensdata.net/${name}`);
174
- const response = await fetch(corsProxyUrl);
175
- const data = await response.json();
176
-
177
- if (data?.avatar) {
178
- // If it's an IPFS URL, convert it to a gateway URL
179
- if (data.avatar.startsWith("ipfs://")) {
180
- return data.avatar.replace("ipfs://", "https://ipfs.io/ipfs/");
181
- }
182
- return data.avatar;
183
- }
184
- return null;
185
- } catch (error) {
186
- console.error("Error fetching ENS PFP:", error);
187
- return null;
188
- }
189
- },
190
- enabled: !!name,
191
- });
192
-
193
- return {
194
- pfp,
195
- isLoading,
196
- address,
197
- };
198
- }
@@ -1,29 +0,0 @@
1
- const baseUrl =
2
- process.env.NEXT_PUBLIC_BASEMENT_API_URL ||
3
- process.env.NEXT_PUBLIC_FEATHERS_API ||
4
- "https://basement-feathers-api-production.up.railway.app";
5
-
6
- export async function fetchBsmntProfile(username?: string, address?: string) {
7
- let response: Response | undefined;
8
-
9
- const queryUsername = username?.includes(".b3.fun") ? username : `${username}.b3.fun`;
10
-
11
- try {
12
- if (username) {
13
- response = await fetch(`${baseUrl}/profiles/?username=${queryUsername}`);
14
- } else if (address) {
15
- response = await fetch(
16
- `${baseUrl}/profiles/?linkedAccounts[$elemMatch][normalizedAddress]=${String(address).toLowerCase() || ""}`,
17
- );
18
- }
19
-
20
- const json = await response?.json();
21
-
22
- if (json.data.length == 0) throw new Error(`Profile not found`);
23
-
24
- return json.data[0];
25
- } catch (error) {
26
- console.error("Error fetching profile", error);
27
- throw error;
28
- }
29
- }