@b3dotfun/sdk 0.0.33-alpha.3 → 0.0.33-alpha.5

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.
@@ -662,7 +662,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
662
662
  setActivePanel(PanelView.MAIN);
663
663
  setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
664
664
  } })] })) }) }));
665
- const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsx)(PaySection_1.PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
665
+ const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsx)(PaySection_1.PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
666
666
  if (activeTab === "fiat" || isBuyMode) {
667
667
  return;
668
668
  }
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.LinkAccount = LinkAccount;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -9,11 +12,11 @@ const react_1 = require("react");
9
12
  const sonner_1 = require("sonner");
10
13
  const react_2 = require("thirdweb/react");
11
14
  const wallets_1 = require("thirdweb/wallets");
12
- const useSiwe_1 = require("../../hooks/useSiwe");
13
15
  const useModalStore_1 = require("../../stores/useModalStore");
14
16
  const profileDisplay_1 = require("../../utils/profileDisplay");
15
17
  const useB3_1 = require("../B3Provider/useB3");
16
18
  const button_1 = require("../ui/button");
19
+ const app_1 = __importDefault(require("../../../../global-account/app"));
17
20
  const AUTH_METHODS = [
18
21
  { id: "email", label: "Email", enabled: true },
19
22
  { id: "phone", label: "Phone", enabled: true },
@@ -44,9 +47,8 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
44
47
  ...(0, profileDisplay_1.getProfileDisplayInfo)(profile),
45
48
  originalProfile: profile,
46
49
  }));
47
- const { account, setUser } = (0, useB3_1.useB3)();
50
+ const { account } = (0, useB3_1.useB3)();
48
51
  const { mutate: linkProfile } = (0, react_2.useLinkProfile)();
49
- const { authenticate } = (0, useSiwe_1.useSiwe)();
50
52
  const onSuccess = (0, react_1.useCallback)(async () => {
51
53
  await onSuccessCallback?.();
52
54
  }, [onSuccessCallback]);
@@ -68,11 +70,8 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
68
70
  onSuccess: async (data) => {
69
71
  console.log("Raw Link Account Data:", data);
70
72
  try {
71
- if (account) {
72
- console.log("Sync user data...");
73
- const userAuth = await authenticate(account, partnerId);
74
- setUser(userAuth.user);
75
- }
73
+ console.log("Sync user data...");
74
+ await app_1.default.service("users").syncTwProfiles({});
76
75
  }
77
76
  catch (refreshError) {
78
77
  console.warn("⚠️ Could not sync user data:", refreshError);
@@ -66,6 +66,22 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
66
66
  const [isEditingCode, setIsEditingCode] = (0, react_2.useState)(false);
67
67
  const referallCodeRef = (0, react_2.useRef)(null);
68
68
  const { data: referrals, isLoading: isLoadingReferrals } = (0, react_1.useQueryB3)("referrals", "find", { query: { referrerId: user?.userId } }, !!user?.userId);
69
+ const mutationOptions = {
70
+ onError: (error) => {
71
+ console.error("Error Unlinking account:", error);
72
+ sonner_1.toast.error(error.message);
73
+ },
74
+ onSuccess: async (data) => {
75
+ console.log("Raw Link Account Data:", data);
76
+ try {
77
+ console.log("Sync user data...");
78
+ await app_1.default.service("users").syncTwProfiles({});
79
+ }
80
+ catch (refreshError) {
81
+ console.warn("⚠️ Could not sync user data:", refreshError);
82
+ }
83
+ },
84
+ };
69
85
  // Fetch referred users
70
86
  const currentReferralCode = user?.referralCode || user?.userId || "";
71
87
  const handleCopyCode = async () => {
@@ -108,7 +124,7 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
108
124
  const handleUnlink = async (profile) => {
109
125
  setUnlinkingAccountId(profile.title);
110
126
  try {
111
- unlinkProfile({ client: thirdweb_1.client, profileToUnlink: profile.originalProfile });
127
+ unlinkProfile({ client: thirdweb_1.client, profileToUnlink: profile.originalProfile }, mutationOptions);
112
128
  }
113
129
  catch (error) {
114
130
  console.error("Error unlinking account:", error);
@@ -655,7 +655,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
655
655
  setActivePanel(PanelView.MAIN);
656
656
  setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
657
657
  } })] })) }) }));
658
- const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
658
+ const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
659
659
  if (activeTab === "fiat" || isBuyMode) {
660
660
  return;
661
661
  }
@@ -6,11 +6,11 @@ import { useCallback, useEffect, useState } from "react";
6
6
  import { toast } from "sonner";
7
7
  import { useLinkProfile, useProfiles } from "thirdweb/react";
8
8
  import { preAuthenticate } from "thirdweb/wallets";
9
- import { useSiwe } from "../../hooks/useSiwe.js";
10
9
  import { useModalStore } from "../../stores/useModalStore.js";
11
10
  import { getProfileDisplayInfo } from "../../utils/profileDisplay.js";
12
11
  import { useB3 } from "../B3Provider/useB3.js";
13
12
  import { Button } from "../ui/button.js";
13
+ import app from "../../../../global-account/app.js";
14
14
  const AUTH_METHODS = [
15
15
  { id: "email", label: "Email", enabled: true },
16
16
  { id: "phone", label: "Phone", enabled: true },
@@ -41,9 +41,8 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
41
41
  ...getProfileDisplayInfo(profile),
42
42
  originalProfile: profile,
43
43
  }));
44
- const { account, setUser } = useB3();
44
+ const { account } = useB3();
45
45
  const { mutate: linkProfile } = useLinkProfile();
46
- const { authenticate } = useSiwe();
47
46
  const onSuccess = useCallback(async () => {
48
47
  await onSuccessCallback?.();
49
48
  }, [onSuccessCallback]);
@@ -65,11 +64,8 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
65
64
  onSuccess: async (data) => {
66
65
  console.log("Raw Link Account Data:", data);
67
66
  try {
68
- if (account) {
69
- console.log("Sync user data...");
70
- const userAuth = await authenticate(account, partnerId);
71
- setUser(userAuth.user);
72
- }
67
+ console.log("Sync user data...");
68
+ await app.service("users").syncTwProfiles({});
73
69
  }
74
70
  catch (refreshError) {
75
71
  console.warn("⚠️ Could not sync user data:", refreshError);
@@ -60,6 +60,22 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
60
60
  const [isEditingCode, setIsEditingCode] = useState(false);
61
61
  const referallCodeRef = useRef(null);
62
62
  const { data: referrals, isLoading: isLoadingReferrals } = useQueryB3("referrals", "find", { query: { referrerId: user?.userId } }, !!user?.userId);
63
+ const mutationOptions = {
64
+ onError: (error) => {
65
+ console.error("Error Unlinking account:", error);
66
+ toast.error(error.message);
67
+ },
68
+ onSuccess: async (data) => {
69
+ console.log("Raw Link Account Data:", data);
70
+ try {
71
+ console.log("Sync user data...");
72
+ await app.service("users").syncTwProfiles({});
73
+ }
74
+ catch (refreshError) {
75
+ console.warn("⚠️ Could not sync user data:", refreshError);
76
+ }
77
+ },
78
+ };
63
79
  // Fetch referred users
64
80
  const currentReferralCode = user?.referralCode || user?.userId || "";
65
81
  const handleCopyCode = async () => {
@@ -102,7 +118,7 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
102
118
  const handleUnlink = async (profile) => {
103
119
  setUnlinkingAccountId(profile.title);
104
120
  try {
105
- unlinkProfile({ client, profileToUnlink: profile.originalProfile });
121
+ unlinkProfile({ client, profileToUnlink: profile.originalProfile }, mutationOptions);
106
122
  }
107
123
  catch (error) {
108
124
  console.error("Error unlinking account:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.33-alpha.3",
3
+ "version": "0.0.33-alpha.5",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -237,7 +237,7 @@
237
237
  "constants"
238
238
  ],
239
239
  "dependencies": {
240
- "@b3dotfun/b3-api": "0.0.45",
240
+ "@b3dotfun/b3-api": "0.0.47",
241
241
  "@b3dotfun/basement-api": "0.0.11",
242
242
  "@feathersjs/authentication-client": "5.0.33",
243
243
  "@feathersjs/feathers": "5.0.33",
@@ -890,6 +890,7 @@ function AnySpendInner({
890
890
  onDestinationChainChange={setSelectedDstChainId}
891
891
  fiatPaymentMethodIndex={PanelView.FIAT_PAYMENT_METHOD}
892
892
  recipientSelectionPanelIndex={PanelView.RECIPIENT_SELECTION}
893
+ hideDstToken={isBuyMode}
893
894
  />
894
895
  </motion.div>
895
896
  )}
@@ -5,11 +5,11 @@ import { useCallback, useEffect, useState } from "react";
5
5
  import { toast } from "sonner";
6
6
  import { useLinkProfile, useProfiles } from "thirdweb/react";
7
7
  import { preAuthenticate } from "thirdweb/wallets";
8
- import { useSiwe } from "../../hooks/useSiwe";
9
8
  import { LinkAccountModalProps, useModalStore } from "../../stores/useModalStore";
10
9
  import { getProfileDisplayInfo } from "../../utils/profileDisplay";
11
10
  import { useB3 } from "../B3Provider/useB3";
12
11
  import { Button } from "../ui/button";
12
+ import app from "@b3dotfun/sdk/global-account/app";
13
13
  type OTPStrategy = "email" | "phone";
14
14
  type SocialStrategy = "google" | "x" | "discord" | "apple" | "farcaster";
15
15
  type Strategy = OTPStrategy | SocialStrategy;
@@ -64,9 +64,8 @@ export function LinkAccount({
64
64
  originalProfile: profile,
65
65
  }));
66
66
 
67
- const { account, setUser } = useB3();
67
+ const { account } = useB3();
68
68
  const { mutate: linkProfile } = useLinkProfile();
69
- const { authenticate } = useSiwe();
70
69
 
71
70
  const onSuccess = useCallback(async () => {
72
71
  await onSuccessCallback?.();
@@ -91,11 +90,8 @@ export function LinkAccount({
91
90
  onSuccess: async (data: any) => {
92
91
  console.log("Raw Link Account Data:", data);
93
92
  try {
94
- if (account) {
95
- console.log("Sync user data...");
96
- const userAuth = await authenticate(account, partnerId);
97
- setUser(userAuth.user);
98
- }
93
+ console.log("Sync user data...");
94
+ await app.service("users").syncTwProfiles({});
99
95
  } catch (refreshError) {
100
96
  console.warn("⚠️ Could not sync user data:", refreshError);
101
97
  }
@@ -146,6 +146,22 @@ export function ManageAccount({
146
146
  !!user?.userId,
147
147
  );
148
148
 
149
+ const mutationOptions = {
150
+ onError: (error: Error) => {
151
+ console.error("Error Unlinking account:", error);
152
+ toast.error(error.message);
153
+ },
154
+ onSuccess: async (data: any) => {
155
+ console.log("Raw Link Account Data:", data);
156
+ try {
157
+ console.log("Sync user data...");
158
+ await app.service("users").syncTwProfiles({});
159
+ } catch (refreshError) {
160
+ console.warn("⚠️ Could not sync user data:", refreshError);
161
+ }
162
+ },
163
+ };
164
+
149
165
  // Fetch referred users
150
166
  const currentReferralCode = user?.referralCode || user?.userId || "";
151
167
 
@@ -189,7 +205,7 @@ export function ManageAccount({
189
205
  const handleUnlink = async (profile: any) => {
190
206
  setUnlinkingAccountId(profile.title);
191
207
  try {
192
- unlinkProfile({ client, profileToUnlink: profile.originalProfile });
208
+ unlinkProfile({ client, profileToUnlink: profile.originalProfile }, mutationOptions);
193
209
  } catch (error) {
194
210
  console.error("Error unlinking account:", error);
195
211
  } finally {