@b3dotfun/sdk 0.0.22 → 0.0.23-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.
@@ -292,7 +292,10 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
292
292
  // );
293
293
  // State for recipient selection
294
294
  const [recipientAddress, setRecipientAddress] = (0, react_4.useState)();
295
- const { address: globalAddress, wallet: globalWallet } = (0, react_2.useAccountWallet)();
295
+ const { address: globalAddress, wallet: globalWallet, ensName: connectedName } = (0, react_2.useAccountWallet)();
296
+ const connectedAddress = globalWallet?.address;
297
+ const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress, fresh: true });
298
+ const recipientName = recipientProfile.data?.name;
296
299
  // Set default recipient address when wallet changes
297
300
  (0, react_4.useEffect)(() => {
298
301
  setRecipientAddress(recipientAddressFromProps || globalAddress);
@@ -342,9 +345,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
342
345
  amount: srcAmountOnrampInWei,
343
346
  onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
344
347
  });
345
- const { address: connectedAddress, name: connectedName, profile: connectedProfile } = (0, react_1.useConnectedUserProfile)();
346
- const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
347
- const recipientName = (0, utils_1.formatUsername)(recipientProfile.data?.name ?? "");
348
348
  // Load custom recipients from local storage on mount
349
349
  (0, react_4.useEffect)(() => {
350
350
  try {
@@ -807,7 +807,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
807
807
  setActiveTab("fiat");
808
808
  setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset crypto payment method when switching to fiat
809
809
  setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
810
- }, children: "Pay with Fiat" })] }) }), (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.jsxs)(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" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [recipientProfile && ((0, jsx_runtime_1.jsx)("img", { src: recipientProfile.data?.avatar || "", alt: recipientProfile.data?.name || "", className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [recipientName && (0, jsx_runtime_1.jsx)("span", { children: recipientName }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(recipientAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
810
+ }, children: "Pay with Fiat" })] }) }), (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.jsxs)(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" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalWallet?.meta?.icon && ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon || "", alt: globalWallet.ensName || "", className: "bg-b3-react-foreground size-6 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [connectedName && (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatUsername)(connectedName) }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(connectedAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
811
811
  setIsSrcInputDirty(true);
812
812
  setSrcAmount(value);
813
813
  }, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
@@ -832,7 +832,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
832
832
  const tempDstAmount = dstAmount;
833
833
  setSrcAmount(tempDstAmount);
834
834
  setDstAmount(tempSrcAmount);
835
- }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(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.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedProfile?.data?.avatar && ((0, jsx_runtime_1.jsx)("img", { src: connectedProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [connectedName && (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatUsername)(connectedName) }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(connectedAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode ? (
835
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(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.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [recipientAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [recipientProfile?.data?.avatar && ((0, jsx_runtime_1.jsx)("img", { src: recipientProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [recipientName && (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatUsername)(recipientName) }), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(recipientAddress || "") })] })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode ? (
836
836
  // Fixed destination token display in buy mode
837
837
  (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : ((0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
838
838
  setIsSrcInputDirty(false);
@@ -849,8 +849,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
849
849
  }
850
850
  // Using inline style to ensure color displays
851
851
  return ((0, jsx_runtime_1.jsxs)("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
852
- })()] })] }))] }), getAnyspendQuoteError && ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl p-4", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), (0, jsx_runtime_1.jsxs)(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.2, ease: "easeInOut" }, className: "mt-4 flex w-full max-w-[460px] flex-col gap-2 pb-2", children: [(0, jsx_runtime_1.jsxs)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
853
- const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
852
+ })()] })] }))] }), getAnyspendQuoteError && ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), (0, jsx_runtime_1.jsxs)(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.2, ease: "easeInOut" }, className: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [(0, jsx_runtime_1.jsxs)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
853
+ const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
854
854
  setOrderId(orderId);
855
855
  setActivePanel(PanelView.ORDER_DETAILS);
856
856
  // Add orderId and payment method to URL for persistence
@@ -26,6 +26,7 @@ function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod,
26
26
  const { wallet: globalWallet } = (0, react_1.useAccountWallet)();
27
27
  const activeWallet = (0, react_3.useActiveWallet)();
28
28
  const { disconnect } = (0, wagmi_1.useDisconnect)();
29
+ const { disconnect: disconnectThirdweb } = (0, react_3.useDisconnect)();
29
30
  const [showWalletModal, setShowWalletModal] = (0, react_2.useState)(false);
30
31
  // Define available wallets for the modal
31
32
  const availableWallets = [
@@ -45,6 +46,7 @@ function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod,
45
46
  onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
46
47
  }, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: async () => {
47
48
  disconnect();
49
+ disconnectThirdweb(activeWallet);
48
50
  sonner_1.toast.success("Wallet disconnected");
49
51
  if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
50
52
  setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
@@ -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.ManageAccount = ManageAccount;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -9,6 +12,7 @@ const lucide_react_1 = require("lucide-react");
9
12
  const react_2 = require("react");
10
13
  const react_3 = require("thirdweb/react");
11
14
  const viem_1 = require("viem");
15
+ const useFirstEOA_1 = __importDefault(require("../../hooks/useFirstEOA"));
12
16
  const AccountAssets_1 = require("../AccountAssets/AccountAssets");
13
17
  function centerTruncate(str, length = 4) {
14
18
  if (str.length <= length * 2)
@@ -16,12 +20,16 @@ function centerTruncate(str, length = 4) {
16
20
  return `${str.slice(0, length)}...${str.slice(-length)}`;
17
21
  }
18
22
  function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain, partnerId, }) {
23
+ const { automaticallySetFirstEoa } = (0, react_1.useB3)();
19
24
  const [activeTab, setActiveTab] = (0, react_2.useState)("balance");
20
25
  const [revokingSignerId, setRevokingSignerId] = (0, react_2.useState)(null);
21
26
  const account = (0, react_3.useActiveAccount)();
27
+ const { address: eoaAddress, info: { data: eoaInfo }, } = (0, useFirstEOA_1.default)();
22
28
  const { data: assets, isLoading } = (0, react_1.useAccountAssets)(account?.address);
23
29
  const { data: b3Balance } = (0, react_1.useB3BalanceFromAddresses)(account?.address);
24
30
  const { data: nativeBalance } = (0, react_1.useNativeBalance)(account?.address);
31
+ const { data: eoaNativeBalance } = (0, react_1.useNativeBalance)(eoaAddress);
32
+ const { data: eoaB3Balance } = (0, react_1.useB3BalanceFromAddresses)(eoaAddress);
25
33
  const { data: signers, refetch: refetchSigners } = (0, react_1.useGetAllTWSigners)({
26
34
  chain,
27
35
  accountAddress: account?.address,
@@ -29,7 +37,6 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
29
37
  const { setB3ModalOpen, setB3ModalContentType } = (0, react_1.useModalStore)();
30
38
  const { logout } = (0, react_1.useAuthentication)(partnerId);
31
39
  const [logoutLoading, setLogoutLoading] = (0, react_2.useState)(false);
32
- console.log("@@assets", assets);
33
40
  const { removeSessionKey } = (0, react_1.useRemoveSessionKey)({
34
41
  chain,
35
42
  onSuccess: tx => {
@@ -53,7 +60,7 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
53
60
  setB3ModalOpen(false);
54
61
  setLogoutLoading(false);
55
62
  };
56
- const BalanceContent = () => ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col items-center justify-between gap-8", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-b3-react-subtle flex flex-col rounded-lg border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-6 w-6" }), (0, jsx_runtime_1.jsx)("h2", { className: "font-neue-montreal-bold text-b3-react-primary text-lg", children: "Global Account" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-secondary-foreground text-sm", children: "Your universal account for all B3-powered apps" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-muted-foreground font-mono text-sm", children: centerTruncate(account?.address || "", 6) }), (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: account?.address || "" })] })] })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-b3-react-subtle w-full rounded-lg border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [b3Balance?.formattedTotal || "--", " B3"] })] }), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border my-4 border-t" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [nativeBalance?.formattedTotal || "--", " ETH"] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "font-neue-montreal-medium flex-1", onClick: () => {
63
+ const BalanceContent = () => ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col items-center justify-between gap-8", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-b3-react-subtle flex flex-col rounded-lg border p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-6 w-6" }), (0, jsx_runtime_1.jsx)("h2", { className: "font-neue-montreal-bold text-b3-react-primary text-lg", children: "Global Account" })] }), !automaticallySetFirstEoa && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [b3Balance?.formattedTotal || "--", " B3"] })] }), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border my-4 border-t" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [nativeBalance?.formattedTotal || "--", " ETH"] })] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-b3-react-secondary-foreground text-sm", children: "Your universal account for all B3-powered apps" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-muted-foreground font-mono text-sm", children: centerTruncate(account?.address || "", 6) }), (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: account?.address || "" })] })] })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border bg-b3-react-subtle w-full rounded-lg border p-4", children: eoaAddress && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h3", { className: "font-neue-montreal-bold text-b3-react-primary mb-2", children: ["Connected ", eoaInfo?.name] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [eoaNativeBalance?.formattedTotal || "--", " ETH"] })] }), (0, jsx_runtime_1.jsx)("div", { className: "border-b3-react-border my-4 border-t" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), (0, jsx_runtime_1.jsxs)("span", { className: "font-neue-montreal-bold text-2xl", children: [eoaB3Balance?.formattedTotal || "--", " B3"] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "text-b3-react-muted-foreground mt-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-mono text-sm", children: centerTruncate(eoaAddress, 6) }), (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: eoaAddress })] })] }) })) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "font-neue-montreal-medium flex-1", onClick: () => {
57
64
  setB3ModalOpen(true);
58
65
  setB3ModalContentType({
59
66
  type: "anySpend",
@@ -0,0 +1,6 @@
1
+ import { Wallet } from "thirdweb/wallets";
2
+ export default function useFirstEOA(): {
3
+ account: Wallet | undefined;
4
+ address: string | undefined;
5
+ info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
6
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = useFirstEOA;
4
+ const react_1 = require("../../../global-account/react");
5
+ const react_2 = require("react");
6
+ const react_3 = require("thirdweb/react");
7
+ function useFirstEOA() {
8
+ const wallets = (0, react_3.useConnectedWallets)();
9
+ const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
10
+ const [firstEOA, setFirstEOA] = (0, react_2.useState)(undefined);
11
+ const [address, setAddress] = (0, react_2.useState)(undefined);
12
+ const walletInfo = (0, react_3.useWalletInfo)(firstEOA?.id);
13
+ console.log("@@wallets", wallets);
14
+ console.log("@@wallets:isConnected", isConnected);
15
+ (0, react_2.useEffect)(() => {
16
+ const autoSelectFirstEOAWallet = async () => {
17
+ // Only proceed if auto-selection is enabled and user is authenticated
18
+ if (!isConnected) {
19
+ console.log("@@wallets:not connected");
20
+ return;
21
+ }
22
+ // Find the first EOA wallet (excluding ecosystem wallets)
23
+ const isEOAWallet = (wallet) => !wallet.id.startsWith("ecosystem.");
24
+ const firstEOAWallet = wallets.find(isEOAWallet);
25
+ console.log("@@wallets:firstEOAWallet", firstEOAWallet);
26
+ const account = await firstEOAWallet?.getAccount();
27
+ console.log("@@wallets:account", account);
28
+ setFirstEOA(firstEOAWallet);
29
+ console.log("@@wallets:address", account?.address);
30
+ setAddress(account?.address);
31
+ };
32
+ autoSelectFirstEOAWallet();
33
+ }, [isConnected, wallets]);
34
+ return {
35
+ account: firstEOA,
36
+ address,
37
+ info: walletInfo,
38
+ };
39
+ }
@@ -1,7 +1,7 @@
1
1
  "use client";
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
- import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useConnectedUserProfile, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
4
+ import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
5
5
  import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
6
6
  import { formatUsername } from "../../../shared/utils/index.js";
7
7
  import { cn } from "../../../shared/utils/cn.js";
@@ -285,7 +285,10 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
285
285
  // );
286
286
  // State for recipient selection
287
287
  const [recipientAddress, setRecipientAddress] = useState();
288
- const { address: globalAddress, wallet: globalWallet } = useAccountWallet();
288
+ const { address: globalAddress, wallet: globalWallet, ensName: connectedName } = useAccountWallet();
289
+ const connectedAddress = globalWallet?.address;
290
+ const recipientProfile = useProfile({ address: recipientAddress, fresh: true });
291
+ const recipientName = recipientProfile.data?.name;
289
292
  // Set default recipient address when wallet changes
290
293
  useEffect(() => {
291
294
  setRecipientAddress(recipientAddressFromProps || globalAddress);
@@ -335,9 +338,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
335
338
  amount: srcAmountOnrampInWei,
336
339
  onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
337
340
  });
338
- const { address: connectedAddress, name: connectedName, profile: connectedProfile } = useConnectedUserProfile();
339
- const recipientProfile = useProfile({ address: recipientAddress });
340
- const recipientName = formatUsername(recipientProfile.data?.name ?? "");
341
341
  // Load custom recipients from local storage on mount
342
342
  useEffect(() => {
343
343
  try {
@@ -800,7 +800,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
800
800
  setActiveTab("fiat");
801
801
  setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset crypto payment method when switching to fiat
802
802
  setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
803
- }, children: "Pay with Fiat" })] }) }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsxs(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" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [recipientProfile && (_jsx("img", { src: recipientProfile.data?.avatar || "", alt: recipientProfile.data?.name || "", className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "flex items-center gap-1", children: [recipientName && _jsx("span", { children: recipientName }), _jsx("span", { children: shortenAddress(recipientAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx(OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
803
+ }, children: "Pay with Fiat" })] }) }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsxs(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" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [globalWallet?.meta?.icon && (_jsx("img", { src: globalWallet.meta.icon || "", alt: globalWallet.ensName || "", className: "bg-b3-react-foreground size-6 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "flex items-center gap-1", children: [connectedName && _jsx("span", { children: formatUsername(connectedName) }), _jsx("span", { children: shortenAddress(connectedAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx(OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
804
804
  setIsSrcInputDirty(true);
805
805
  setSrcAmount(value);
806
806
  }, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), _jsx(TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
@@ -825,7 +825,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
825
825
  const tempDstAmount = dstAmount;
826
826
  setSrcAmount(tempDstAmount);
827
827
  setDstAmount(tempSrcAmount);
828
- }, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [connectedProfile?.data?.avatar && (_jsx("img", { src: connectedProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), _jsxs("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [connectedName && _jsx("span", { children: formatUsername(connectedName) }), _jsx("span", { children: shortenAddress(connectedAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode ? (
828
+ }, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsxs(_Fragment, { children: [recipientAddress ? (_jsxs(_Fragment, { children: [recipientProfile?.data?.avatar && (_jsx("img", { src: recipientProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), _jsxs("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [recipientName && _jsx("span", { children: formatUsername(recipientName) }), _jsx("span", { children: shortenAddress(recipientAddress || "") })] })] })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode ? (
829
829
  // Fixed destination token display in buy mode
830
830
  _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), _jsxs("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && (_jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), _jsx("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : (_jsx(OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
831
831
  setIsSrcInputDirty(false);
@@ -842,8 +842,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
842
842
  }
843
843
  // Using inline style to ensure color displays
844
844
  return (_jsxs("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
845
- })()] })] }))] }), getAnyspendQuoteError && (_jsxs("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl p-4", children: [_jsx(CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), _jsx("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), _jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "mt-4 flex w-full max-w-[460px] flex-col gap-2 pb-2", children: [_jsxs(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && (_jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
846
- const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
845
+ })()] })] }))] }), getAnyspendQuoteError && (_jsxs("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [_jsx(CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), _jsx("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), _jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [_jsxs(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && (_jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
846
+ const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
847
847
  setOrderId(orderId);
848
848
  setActivePanel(PanelView.ORDER_DETAILS);
849
849
  // Add orderId and payment method to URL for persistence
@@ -9,7 +9,7 @@ import { ChevronLeft, ChevronRightCircle, Wallet, X } from "lucide-react";
9
9
  import { useState } from "react";
10
10
  import { createPortal } from "react-dom";
11
11
  import { toast } from "sonner";
12
- import { ConnectEmbed, lightTheme, useActiveWallet } from "thirdweb/react";
12
+ import { ConnectEmbed, lightTheme, useActiveWallet, useDisconnect as useThirdwebDisconnect } from "thirdweb/react";
13
13
  import { createWallet } from "thirdweb/wallets";
14
14
  import { useDisconnect } from "wagmi";
15
15
  export var CryptoPaymentMethodType;
@@ -22,6 +22,7 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
22
22
  const { wallet: globalWallet } = useAccountWallet();
23
23
  const activeWallet = useActiveWallet();
24
24
  const { disconnect } = useDisconnect();
25
+ const { disconnect: disconnectThirdweb } = useThirdwebDisconnect();
25
26
  const [showWalletModal, setShowWalletModal] = useState(false);
26
27
  // Define available wallets for the modal
27
28
  const availableWallets = [
@@ -41,6 +42,7 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
41
42
  onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
42
43
  }, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), _jsx("button", { onClick: async () => {
43
44
  disconnect();
45
+ disconnectThirdweb(activeWallet);
44
46
  toast.success("Wallet disconnected");
45
47
  if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
46
48
  setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
@@ -1,11 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, CopyToClipboard, useAccountAssets, useAuthentication, useB3BalanceFromAddresses, useGetAllTWSigners, useNativeBalance, useRemoveSessionKey, useModalStore, TabsPrimitive, TabsContentPrimitive, TabsListPrimitive, TabTriggerPrimitive, } from "../../../../global-account/react/index.js";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button, CopyToClipboard, TabsContentPrimitive, TabsListPrimitive, TabsPrimitive, TabTriggerPrimitive, useAccountAssets, useAuthentication, useB3, useB3BalanceFromAddresses, useGetAllTWSigners, useModalStore, useNativeBalance, useRemoveSessionKey, } from "../../../../global-account/react/index.js";
3
3
  import { formatAddress } from "../../../../shared/utils/formatAddress.js";
4
4
  import { formatNumber } from "../../../../shared/utils/formatNumber.js";
5
5
  import { ArrowRightLeft } from "lucide-react";
6
6
  import { useState } from "react";
7
7
  import { useActiveAccount } from "thirdweb/react";
8
8
  import { formatUnits } from "viem";
9
+ import useFirstEOA from "../../hooks/useFirstEOA.js";
9
10
  import { AccountAssets } from "../AccountAssets/AccountAssets.js";
10
11
  function centerTruncate(str, length = 4) {
11
12
  if (str.length <= length * 2)
@@ -13,12 +14,16 @@ function centerTruncate(str, length = 4) {
13
14
  return `${str.slice(0, length)}...${str.slice(-length)}`;
14
15
  }
15
16
  export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain, partnerId, }) {
17
+ const { automaticallySetFirstEoa } = useB3();
16
18
  const [activeTab, setActiveTab] = useState("balance");
17
19
  const [revokingSignerId, setRevokingSignerId] = useState(null);
18
20
  const account = useActiveAccount();
21
+ const { address: eoaAddress, info: { data: eoaInfo }, } = useFirstEOA();
19
22
  const { data: assets, isLoading } = useAccountAssets(account?.address);
20
23
  const { data: b3Balance } = useB3BalanceFromAddresses(account?.address);
21
24
  const { data: nativeBalance } = useNativeBalance(account?.address);
25
+ const { data: eoaNativeBalance } = useNativeBalance(eoaAddress);
26
+ const { data: eoaB3Balance } = useB3BalanceFromAddresses(eoaAddress);
22
27
  const { data: signers, refetch: refetchSigners } = useGetAllTWSigners({
23
28
  chain,
24
29
  accountAddress: account?.address,
@@ -26,7 +31,6 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
26
31
  const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
27
32
  const { logout } = useAuthentication(partnerId);
28
33
  const [logoutLoading, setLogoutLoading] = useState(false);
29
- console.log("@@assets", assets);
30
34
  const { removeSessionKey } = useRemoveSessionKey({
31
35
  chain,
32
36
  onSuccess: tx => {
@@ -50,7 +54,7 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
50
54
  setB3ModalOpen(false);
51
55
  setLogoutLoading(false);
52
56
  };
53
- const BalanceContent = () => (_jsxs("div", { className: "flex h-full flex-col items-center justify-between gap-8", children: [_jsx("div", { className: "w-full", children: _jsxs("div", { className: "border-b3-react-border bg-b3-react-subtle flex flex-col rounded-lg border p-4", children: [_jsxs("div", { className: "mb-4 flex items-center gap-3", children: [_jsx("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-6 w-6" }), _jsx("h2", { className: "font-neue-montreal-bold text-b3-react-primary text-lg", children: "Global Account" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-b3-react-secondary-foreground text-sm", children: "Your universal account for all B3-powered apps" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-b3-react-muted-foreground font-mono text-sm", children: centerTruncate(account?.address || "", 6) }), _jsx(CopyToClipboard, { text: account?.address || "" })] })] })] }) }), _jsxs("div", { className: "border-b3-react-border bg-b3-react-subtle w-full rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [b3Balance?.formattedTotal || "--", " B3"] })] }), _jsx("div", { className: "border-b3-react-border my-4 border-t" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [nativeBalance?.formattedTotal || "--", " ETH"] })] })] }), _jsxs("div", { className: "flex w-full gap-4", children: [_jsx(Button, { className: "font-neue-montreal-medium flex-1", onClick: () => {
57
+ const BalanceContent = () => (_jsxs("div", { className: "flex h-full flex-col items-center justify-between gap-8", children: [_jsx("div", { className: "w-full", children: _jsxs("div", { className: "border-b3-react-border bg-b3-react-subtle flex flex-col rounded-lg border p-4", children: [_jsxs("div", { className: "mb-4 flex items-center gap-3", children: [_jsx("img", { src: "https://cdn.b3.fun/b3_logo.svg", alt: "B3", className: "h-6 w-6" }), _jsx("h2", { className: "font-neue-montreal-bold text-b3-react-primary text-lg", children: "Global Account" })] }), !automaticallySetFirstEoa && (_jsxs("div", { className: "mb-4", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [b3Balance?.formattedTotal || "--", " B3"] })] }), _jsx("div", { className: "border-b3-react-border my-4 border-t" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [nativeBalance?.formattedTotal || "--", " ETH"] })] })] })), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-b3-react-secondary-foreground text-sm", children: "Your universal account for all B3-powered apps" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-b3-react-muted-foreground font-mono text-sm", children: centerTruncate(account?.address || "", 6) }), _jsx(CopyToClipboard, { text: account?.address || "" })] })] })] }) }), _jsx("div", { className: "border-b3-react-border bg-b3-react-subtle w-full rounded-lg border p-4", children: eoaAddress && (_jsx(_Fragment, { children: _jsxs("div", { children: [_jsxs("h3", { className: "font-neue-montreal-bold text-b3-react-primary mb-2", children: ["Connected ", eoaInfo?.name] }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/ethereum.svg", alt: "ETH", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [eoaNativeBalance?.formattedTotal || "--", " ETH"] })] }), _jsx("div", { className: "border-b3-react-border my-4 border-t" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", alt: "B3", className: "h-10 w-10" }), _jsxs("span", { className: "font-neue-montreal-bold text-2xl", children: [eoaB3Balance?.formattedTotal || "--", " B3"] })] }), _jsxs("div", { className: "text-b3-react-muted-foreground mt-2", children: [_jsx("span", { className: "font-mono text-sm", children: centerTruncate(eoaAddress, 6) }), _jsx(CopyToClipboard, { text: eoaAddress })] })] }) })) }), _jsxs("div", { className: "flex w-full gap-4", children: [_jsx(Button, { className: "font-neue-montreal-medium flex-1", onClick: () => {
54
58
  setB3ModalOpen(true);
55
59
  setB3ModalContentType({
56
60
  type: "anySpend",
@@ -0,0 +1,6 @@
1
+ import { Wallet } from "thirdweb/wallets";
2
+ export default function useFirstEOA(): {
3
+ account: Wallet | undefined;
4
+ address: string | undefined;
5
+ info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
6
+ };
@@ -0,0 +1,36 @@
1
+ import { useAuthStore } from "../../../global-account/react/index.js";
2
+ import { useEffect, useState } from "react";
3
+ import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
4
+ export default function useFirstEOA() {
5
+ const wallets = useConnectedWallets();
6
+ const isConnected = useAuthStore(state => state.isConnected);
7
+ const [firstEOA, setFirstEOA] = useState(undefined);
8
+ const [address, setAddress] = useState(undefined);
9
+ const walletInfo = useWalletInfo(firstEOA?.id);
10
+ console.log("@@wallets", wallets);
11
+ console.log("@@wallets:isConnected", isConnected);
12
+ useEffect(() => {
13
+ const autoSelectFirstEOAWallet = async () => {
14
+ // Only proceed if auto-selection is enabled and user is authenticated
15
+ if (!isConnected) {
16
+ console.log("@@wallets:not connected");
17
+ return;
18
+ }
19
+ // Find the first EOA wallet (excluding ecosystem wallets)
20
+ const isEOAWallet = (wallet) => !wallet.id.startsWith("ecosystem.");
21
+ const firstEOAWallet = wallets.find(isEOAWallet);
22
+ console.log("@@wallets:firstEOAWallet", firstEOAWallet);
23
+ const account = await firstEOAWallet?.getAccount();
24
+ console.log("@@wallets:account", account);
25
+ setFirstEOA(firstEOAWallet);
26
+ console.log("@@wallets:address", account?.address);
27
+ setAddress(account?.address);
28
+ };
29
+ autoSelectFirstEOAWallet();
30
+ }, [isConnected, wallets]);
31
+ return {
32
+ account: firstEOA,
33
+ address,
34
+ info: walletInfo,
35
+ };
36
+ }
@@ -0,0 +1,6 @@
1
+ import { Wallet } from "thirdweb/wallets";
2
+ export default function useFirstEOA(): {
3
+ account: Wallet | undefined;
4
+ address: string | undefined;
5
+ info: import("@tanstack/react-query").UseQueryResult<import("thirdweb/wallets").WalletInfo, Error>;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.22",
3
+ "version": "0.0.23-alpha.1",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -191,7 +191,7 @@
191
191
  ],
192
192
  "dependencies": {
193
193
  "@amplitude/analytics-browser": "2.14.0",
194
- "@b3dotfun/b3-api": "0.0.38",
194
+ "@b3dotfun/b3-api": "0.0.39",
195
195
  "@b3dotfun/basement-api": "0.0.11",
196
196
  "@b3dotfun/bondkit": "^0.1.17",
197
197
  "@chakra-ui/react": "2.10.7",
@@ -6,7 +6,6 @@ import {
6
6
  useAnyspendCreateOrder,
7
7
  useAnyspendOrderAndTransactions,
8
8
  useAnyspendQuote,
9
- useConnectedUserProfile,
10
9
  useGeoOnrampOptions,
11
10
  } from "@b3dotfun/sdk/anyspend/react";
12
11
  import {
@@ -405,7 +404,10 @@ function AnySpendInner({
405
404
  // State for recipient selection
406
405
  const [recipientAddress, setRecipientAddress] = useState<string | undefined>();
407
406
 
408
- const { address: globalAddress, wallet: globalWallet } = useAccountWallet();
407
+ const { address: globalAddress, wallet: globalWallet, ensName: connectedName } = useAccountWallet();
408
+ const connectedAddress = globalWallet?.address;
409
+ const recipientProfile = useProfile({ address: recipientAddress, fresh: true });
410
+ const recipientName = recipientProfile.data?.name;
409
411
 
410
412
  // Set default recipient address when wallet changes
411
413
  useEffect(() => {
@@ -465,10 +467,6 @@ function AnySpendInner({
465
467
  },
466
468
  );
467
469
 
468
- const { address: connectedAddress, name: connectedName, profile: connectedProfile } = useConnectedUserProfile();
469
- const recipientProfile = useProfile({ address: recipientAddress });
470
- const recipientName = formatUsername(recipientProfile.data?.name ?? "");
471
-
472
470
  // Load custom recipients from local storage on mount
473
471
  useEffect(() => {
474
472
  try {
@@ -1080,16 +1078,16 @@ function AnySpendInner({
1080
1078
  <>
1081
1079
  {connectedAddress ? (
1082
1080
  <>
1083
- {recipientProfile && (
1081
+ {globalWallet?.meta?.icon && (
1084
1082
  <img
1085
- src={recipientProfile.data?.avatar || ""}
1086
- alt={recipientProfile.data?.name || ""}
1087
- className="bg-b3-react-foreground size-7 rounded-full object-cover opacity-100"
1083
+ src={globalWallet.meta.icon || ""}
1084
+ alt={globalWallet.ensName || ""}
1085
+ className="bg-b3-react-foreground size-6 rounded-full object-cover opacity-100"
1088
1086
  />
1089
1087
  )}
1090
1088
  <div className="flex items-center gap-1">
1091
- {recipientName && <span>{recipientName}</span>}
1092
- <span>{shortenAddress(recipientAddress || "")}</span>
1089
+ {connectedName && <span>{formatUsername(connectedName)}</span>}
1090
+ <span>{shortenAddress(connectedAddress || "")}</span>
1093
1091
  </div>
1094
1092
  </>
1095
1093
  ) : (
@@ -1211,18 +1209,18 @@ function AnySpendInner({
1211
1209
  onClick={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
1212
1210
  >
1213
1211
  <>
1214
- {connectedAddress ? (
1212
+ {recipientAddress ? (
1215
1213
  <>
1216
- {connectedProfile?.data?.avatar && (
1214
+ {recipientProfile?.data?.avatar && (
1217
1215
  <img
1218
- src={connectedProfile.data?.avatar || ""}
1216
+ src={recipientProfile.data?.avatar || ""}
1219
1217
  alt="Connected Wallet"
1220
1218
  className="bg-as-primary h-6 w-6 rounded-full"
1221
1219
  />
1222
1220
  )}
1223
1221
  <span className="text-as-tertiarry flex items-center gap-1 text-sm">
1224
- {connectedName && <span>{formatUsername(connectedName)}</span>}
1225
- <span>{shortenAddress(connectedAddress || "")}</span>
1222
+ {recipientName && <span>{formatUsername(recipientName)}</span>}
1223
+ <span>{shortenAddress(recipientAddress || "")}</span>
1226
1224
  </span>
1227
1225
  </>
1228
1226
  ) : (
@@ -1324,7 +1322,7 @@ function AnySpendInner({
1324
1322
 
1325
1323
  {/* Error message section */}
1326
1324
  {getAnyspendQuoteError && (
1327
- <div className="bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl p-4">
1325
+ <div className="bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2">
1328
1326
  <CircleAlert className="bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" />
1329
1327
  <div className="text-as-red text-sm">{getAnyspendQuoteError.message}</div>
1330
1328
  </div>
@@ -1335,7 +1333,7 @@ function AnySpendInner({
1335
1333
  initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
1336
1334
  animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
1337
1335
  transition={{ duration: 0.3, delay: 0.2, ease: "easeInOut" }}
1338
- className="mt-4 flex w-full max-w-[460px] flex-col gap-2 pb-2"
1336
+ className={cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0")}
1339
1337
  >
1340
1338
  <ShinyButton
1341
1339
  accentColor={"hsl(var(--as-brand))"}
@@ -1369,7 +1367,7 @@ function AnySpendInner({
1369
1367
  const onrampPaymentView = (
1370
1368
  <PanelOnrampPayment
1371
1369
  srcAmountOnRamp={srcAmountOnRamp}
1372
- recipientName={recipientName}
1370
+ recipientName={recipientName || undefined}
1373
1371
  recipientAddress={recipientAddress}
1374
1372
  isMainnet={isMainnet}
1375
1373
  isBuyMode={isBuyMode}
@@ -9,7 +9,7 @@ import { ChevronLeft, ChevronRightCircle, Wallet, X } from "lucide-react";
9
9
  import { useState } from "react";
10
10
  import { createPortal } from "react-dom";
11
11
  import { toast } from "sonner";
12
- import { ConnectEmbed, lightTheme, useActiveWallet } from "thirdweb/react";
12
+ import { ConnectEmbed, lightTheme, useActiveWallet, useDisconnect as useThirdwebDisconnect } from "thirdweb/react";
13
13
  import { createWallet } from "thirdweb/wallets";
14
14
  import { useDisconnect } from "wagmi";
15
15
 
@@ -43,6 +43,7 @@ export function CryptoPaymentMethod({
43
43
  const { wallet: globalWallet } = useAccountWallet();
44
44
  const activeWallet = useActiveWallet();
45
45
  const { disconnect } = useDisconnect();
46
+ const { disconnect: disconnectThirdweb } = useThirdwebDisconnect();
46
47
  const [showWalletModal, setShowWalletModal] = useState(false);
47
48
 
48
49
  // Define available wallets for the modal
@@ -123,6 +124,7 @@ export function CryptoPaymentMethod({
123
124
  <button
124
125
  onClick={async () => {
125
126
  disconnect();
127
+ disconnectThirdweb(activeWallet);
126
128
  toast.success("Wallet disconnected");
127
129
  if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
128
130
  setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
@@ -1,18 +1,19 @@
1
1
  import {
2
2
  Button,
3
3
  CopyToClipboard,
4
+ TabsContentPrimitive,
5
+ TabsListPrimitive,
6
+ TabsPrimitive,
7
+ TabTriggerPrimitive,
4
8
  TWSignerWithMetadata,
5
9
  useAccountAssets,
6
10
  useAuthentication,
11
+ useB3,
7
12
  useB3BalanceFromAddresses,
8
13
  useGetAllTWSigners,
14
+ useModalStore,
9
15
  useNativeBalance,
10
16
  useRemoveSessionKey,
11
- useModalStore,
12
- TabsPrimitive,
13
- TabsContentPrimitive,
14
- TabsListPrimitive,
15
- TabTriggerPrimitive,
16
17
  } from "@b3dotfun/sdk/global-account/react";
17
18
  import { formatAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
18
19
  import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
@@ -21,6 +22,7 @@ import { useState } from "react";
21
22
  import { Chain } from "thirdweb";
22
23
  import { useActiveAccount } from "thirdweb/react";
23
24
  import { formatUnits } from "viem";
25
+ import useFirstEOA from "../../hooks/useFirstEOA";
24
26
  import { AccountAssets } from "../AccountAssets/AccountAssets";
25
27
 
26
28
  interface ManageAccountProps {
@@ -44,12 +46,19 @@ export function ManageAccount({
44
46
  chain,
45
47
  partnerId,
46
48
  }: ManageAccountProps) {
49
+ const { automaticallySetFirstEoa } = useB3();
47
50
  const [activeTab, setActiveTab] = useState("balance");
48
51
  const [revokingSignerId, setRevokingSignerId] = useState<string | null>(null);
49
52
  const account = useActiveAccount();
53
+ const {
54
+ address: eoaAddress,
55
+ info: { data: eoaInfo },
56
+ } = useFirstEOA();
50
57
  const { data: assets, isLoading } = useAccountAssets(account?.address);
51
58
  const { data: b3Balance } = useB3BalanceFromAddresses(account?.address);
52
59
  const { data: nativeBalance } = useNativeBalance(account?.address);
60
+ const { data: eoaNativeBalance } = useNativeBalance(eoaAddress);
61
+ const { data: eoaB3Balance } = useB3BalanceFromAddresses(eoaAddress);
53
62
  const { data: signers, refetch: refetchSigners } = useGetAllTWSigners({
54
63
  chain,
55
64
  accountAddress: account?.address,
@@ -58,8 +67,6 @@ export function ManageAccount({
58
67
  const { logout } = useAuthentication(partnerId);
59
68
  const [logoutLoading, setLogoutLoading] = useState(false);
60
69
 
61
- console.log("@@assets", assets);
62
-
63
70
  const { removeSessionKey } = useRemoveSessionKey({
64
71
  chain,
65
72
  onSuccess: tx => {
@@ -94,6 +101,20 @@ export function ManageAccount({
94
101
  <img src="https://cdn.b3.fun/b3_logo.svg" alt="B3" className="h-6 w-6" />
95
102
  <h2 className="font-neue-montreal-bold text-b3-react-primary text-lg">Global Account</h2>
96
103
  </div>
104
+
105
+ {!automaticallySetFirstEoa && (
106
+ <div className="mb-4">
107
+ <div className="flex items-center gap-4">
108
+ <img src="https://cdn.b3.fun/b3-coin-3d.png" alt="B3" className="h-10 w-10" />
109
+ <span className="font-neue-montreal-bold text-2xl">{b3Balance?.formattedTotal || "--"} B3</span>
110
+ </div>
111
+ <div className="border-b3-react-border my-4 border-t" />
112
+ <div className="flex items-center gap-4">
113
+ <img src="https://cdn.b3.fun/ethereum.svg" alt="ETH" className="h-10 w-10" />
114
+ <span className="font-neue-montreal-bold text-2xl">{nativeBalance?.formattedTotal || "--"} ETH</span>
115
+ </div>
116
+ </div>
117
+ )}
97
118
  <div className="flex flex-col gap-2">
98
119
  <p className="text-b3-react-secondary-foreground text-sm">Your universal account for all B3-powered apps</p>
99
120
  <div className="flex items-center gap-2">
@@ -107,15 +128,26 @@ export function ManageAccount({
107
128
  </div>
108
129
 
109
130
  <div className="border-b3-react-border bg-b3-react-subtle w-full rounded-lg border p-4">
110
- <div className="flex items-center gap-4">
111
- <img src="https://cdn.b3.fun/b3-coin-3d.png" alt="B3" className="h-10 w-10" />
112
- <span className="font-neue-montreal-bold text-2xl">{b3Balance?.formattedTotal || "--"} B3</span>
113
- </div>
114
- <div className="border-b3-react-border my-4 border-t" />
115
- <div className="flex items-center gap-4">
116
- <img src="https://cdn.b3.fun/ethereum.svg" alt="ETH" className="h-10 w-10" />
117
- <span className="font-neue-montreal-bold text-2xl">{nativeBalance?.formattedTotal || "--"} ETH</span>
118
- </div>
131
+ {eoaAddress && (
132
+ <>
133
+ <div>
134
+ <h3 className="font-neue-montreal-bold text-b3-react-primary mb-2">Connected {eoaInfo?.name}</h3>
135
+ <div className="flex items-center gap-4">
136
+ <img src="https://cdn.b3.fun/ethereum.svg" alt="ETH" className="h-10 w-10" />
137
+ <span className="font-neue-montreal-bold text-2xl">{eoaNativeBalance?.formattedTotal || "--"} ETH</span>
138
+ </div>
139
+ <div className="border-b3-react-border my-4 border-t" />
140
+ <div className="flex items-center gap-4">
141
+ <img src="https://cdn.b3.fun/b3-coin-3d.png" alt="B3" className="h-10 w-10" />
142
+ <span className="font-neue-montreal-bold text-2xl">{eoaB3Balance?.formattedTotal || "--"} B3</span>
143
+ </div>
144
+ <div className="text-b3-react-muted-foreground mt-2">
145
+ <span className="font-mono text-sm">{centerTruncate(eoaAddress, 6)}</span>
146
+ <CopyToClipboard text={eoaAddress} />
147
+ </div>
148
+ </div>
149
+ </>
150
+ )}
119
151
  </div>
120
152
 
121
153
  <div className="flex w-full gap-4">
@@ -0,0 +1,44 @@
1
+ import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
2
+ import { useEffect, useState } from "react";
3
+ import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
4
+ import { Wallet } from "thirdweb/wallets";
5
+
6
+ export default function useFirstEOA() {
7
+ const wallets = useConnectedWallets();
8
+ const isConnected = useAuthStore(state => state.isConnected);
9
+ const [firstEOA, setFirstEOA] = useState<Wallet | undefined>(undefined);
10
+ const [address, setAddress] = useState<string | undefined>(undefined);
11
+ const walletInfo = useWalletInfo(firstEOA?.id);
12
+
13
+ console.log("@@wallets", wallets);
14
+ console.log("@@wallets:isConnected", isConnected);
15
+
16
+ useEffect(() => {
17
+ const autoSelectFirstEOAWallet = async () => {
18
+ // Only proceed if auto-selection is enabled and user is authenticated
19
+ if (!isConnected) {
20
+ console.log("@@wallets:not connected");
21
+ return;
22
+ }
23
+
24
+ // Find the first EOA wallet (excluding ecosystem wallets)
25
+ const isEOAWallet = (wallet: Wallet) => !wallet.id.startsWith("ecosystem.");
26
+ const firstEOAWallet = wallets.find(isEOAWallet);
27
+ console.log("@@wallets:firstEOAWallet", firstEOAWallet);
28
+
29
+ const account = await firstEOAWallet?.getAccount();
30
+ console.log("@@wallets:account", account);
31
+ setFirstEOA(firstEOAWallet);
32
+ console.log("@@wallets:address", account?.address);
33
+ setAddress(account?.address);
34
+ };
35
+
36
+ autoSelectFirstEOAWallet();
37
+ }, [isConnected, wallets]);
38
+
39
+ return {
40
+ account: firstEOA,
41
+ address,
42
+ info: walletInfo,
43
+ };
44
+ }