@b3dotfun/sdk 0.0.40 → 0.0.41-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +17 -4
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +33 -11
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -11
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +376 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +41 -9
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +17 -4
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +33 -11
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -11
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +372 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +42 -9
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +37 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +63 -13
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +10 -14
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +55 -15
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAuthentication.ts +2 -3
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
|
@@ -4,6 +4,7 @@ import { Button, TabsContentPrimitive, TabsListPrimitive, TabsPrimitive, TabTrig
|
|
|
4
4
|
import { SignOutIcon } from "../../../../global-account/react/components/icons/SignOutIcon.js";
|
|
5
5
|
import { formatNumber } from "../../../../shared/utils/formatNumber.js";
|
|
6
6
|
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
7
|
+
import { truncateAddress } from "../../../../shared/utils/truncateAddress.js";
|
|
7
8
|
import { BarChart3, Coins, Copy, Image, LinkIcon, Loader2, Pencil, Settings, UnlinkIcon } from "lucide-react";
|
|
8
9
|
import { useRef, useState } from "react";
|
|
9
10
|
import { toast } from "sonner";
|
|
@@ -12,6 +13,21 @@ import { formatUnits } from "viem";
|
|
|
12
13
|
import { getProfileDisplayInfo } from "../../utils/profileDisplay.js";
|
|
13
14
|
import { AccountAssets } from "../AccountAssets/AccountAssets.js";
|
|
14
15
|
import { ContentTokens } from "./ContentTokens.js";
|
|
16
|
+
// Helper function to check if a string is a wallet address and format it
|
|
17
|
+
const formatProfileTitle = (title) => {
|
|
18
|
+
// Check if title looks like an Ethereum address (0x followed by 40 hex characters)
|
|
19
|
+
const isEthereumAddress = /^0x[a-fA-F0-9]{40}$/.test(title);
|
|
20
|
+
if (isEthereumAddress) {
|
|
21
|
+
return {
|
|
22
|
+
displayTitle: truncateAddress(title),
|
|
23
|
+
isAddress: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
displayTitle: title,
|
|
28
|
+
isAddress: false,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
15
31
|
import { BalanceContent } from "./BalanceContent.js";
|
|
16
32
|
export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain, partnerId, showSwap, showDeposit, }) {
|
|
17
33
|
const [revokingSignerId, setRevokingSignerId] = useState(null);
|
|
@@ -111,7 +127,7 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
111
127
|
}
|
|
112
128
|
};
|
|
113
129
|
const profiles = profilesRaw
|
|
114
|
-
.filter((profile) => !["custom_auth_endpoint"
|
|
130
|
+
.filter((profile) => !["custom_auth_endpoint"].includes(profile.type))
|
|
115
131
|
.map((profile) => ({
|
|
116
132
|
...getProfileDisplayInfo(profile),
|
|
117
133
|
originalProfile: profile,
|
|
@@ -146,7 +162,24 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
146
162
|
},
|
|
147
163
|
});
|
|
148
164
|
};
|
|
149
|
-
|
|
165
|
+
console.log("@@profiles", profiles);
|
|
166
|
+
return (_jsxs("div", { className: "linked-accounts-settings space-y-8", children: [_jsxs("div", { className: "linked-accounts-section space-y-4", children: [_jsxs("div", { className: "linked-accounts-header flex items-center justify-between", children: [_jsx("h3", { className: "text-b3-grey font-neue-montreal-semibold linked-accounts-settings-title text-xl", children: "Linked Accounts" }), _jsxs(Button, { className: "linked-accounts-settings-button linked-accounts-link-button bg-b3-primary-wash hover:bg-b3-primary-wash/70 flex items-center gap-2 rounded-full px-4 py-2", onClick: handleOpenLinkModal, disabled: isLinking, children: [isLinking ? (_jsx(Loader2, { className: "linked-accounts-link-loading text-b3-primary-blue animate-spin", size: 16 })) : (_jsx(LinkIcon, { size: 16, className: "linked-accounts-link-icon text-b3-primary-blue" })), _jsx("span", { className: "linked-accounts-link-text text-b3-grey font-neue-montreal-semibold", children: isLinking ? "Linking..." : "Link New Account" })] })] }), isLoadingProfiles ? (_jsx("div", { className: "linked-accounts-loading flex justify-center py-8", children: _jsx(Loader2, { className: "text-b3-grey animate-spin" }) })) : profiles.length > 0 ? (_jsx("div", { className: "linked-accounts-list space-y-4", children: profiles.map(profile => (_jsxs("div", { className: "linked-account-item bg-b3-line group flex items-center justify-between rounded-xl p-4", children: [_jsxs("div", { className: "linked-account-info flex items-center gap-3", children: [profile.imageUrl ? (_jsx("img", { src: profile.imageUrl, alt: profile.title, className: "linked-account-avatar linked-account-avatar-image size-10 rounded-full" })) : (_jsx("div", { className: "linked-account-avatar linked-account-avatar-placeholder bg-b3-primary-wash flex h-10 w-10 items-center justify-center rounded-full", children: _jsx("span", { className: "linked-account-initial text-b3-grey font-neue-montreal-semibold text-sm uppercase", children: profile.initial }) })), _jsxs("div", { className: "linked-account-details", children: [_jsxs("div", { className: "linked-account-title-row flex items-center gap-2", children: [(() => {
|
|
167
|
+
const { displayTitle, isAddress } = formatProfileTitle(profile.title);
|
|
168
|
+
const handleCopyAddress = async (e) => {
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
try {
|
|
171
|
+
await navigator.clipboard.writeText(profile.title);
|
|
172
|
+
toast.success("Address copied to clipboard!");
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
toast.error("Failed to copy address");
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
return (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: `linked-account-title text-b3-grey font-neue-montreal-semibold ${isAddress
|
|
179
|
+
? "font-mono text-sm" // Use monospace font for addresses
|
|
180
|
+
: "break-words" // Use break-words for emails/names (better than break-all)
|
|
181
|
+
}`, title: isAddress ? profile.title : undefined, children: displayTitle }), isAddress && (_jsx("button", { onClick: handleCopyAddress, className: "linked-account-copy-button ml-1 rounded p-1 opacity-0 transition-opacity hover:bg-gray-100 group-hover:opacity-100", title: "Copy full address", children: _jsx(Copy, { size: 12, className: "text-gray-500 hover:text-gray-700" }) }))] }));
|
|
182
|
+
})(), _jsx("span", { className: "linked-account-type text-b3-foreground-muted font-neue-montreal-medium bg-b3-primary-wash rounded px-2 py-0.5 text-xs", children: profile.type.toUpperCase() })] }), _jsx("div", { className: "linked-account-subtitle text-b3-foreground-muted font-neue-montreal-medium text-sm", children: profile.subtitle })] })] }), _jsx(Button, { variant: "ghost", size: "icon", className: "linked-account-unlink-button text-b3-grey hover:text-b3-negative", onClick: () => handleUnlink(profile), disabled: unlinkingAccountId === profile.title || isUnlinking, children: unlinkingAccountId === profile.title || isUnlinking ? (_jsx(Loader2, { className: "linked-account-unlink-loading animate-spin" })) : (_jsx(UnlinkIcon, { size: 16, className: "linked-account-unlink-icon" })) })] }, profile.title))) })) : (_jsx("div", { className: "linked-accounts-empty text-b3-foreground-muted py-8 text-center", children: "No linked accounts found" }))] }), showReferralInfo && (
|
|
150
183
|
/* Referral Section */
|
|
151
184
|
_jsxs("div", { className: "referrals-section space-y-4", children: [_jsx("h3", { className: "referrals-title text-b3-grey font-neue-montreal-semibold text-xl", children: "Referrals" }), _jsxs("div", { className: "referral-code-container bg-b3-line rounded-xl p-4", children: [isEditingCode && (_jsxs("div", { className: "referral-code-header-editing", children: [_jsx("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), _jsx("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), _jsxs("div", { className: "referral-code-content flex items-center justify-between", children: [!isEditingCode && (_jsxs("div", { className: "referral-code-header", children: [_jsx("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), _jsx("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), _jsx("div", { className: "referral-code-actions flex items-center gap-2", children: isEditingCode ? (_jsxs("div", { className: "referral-code-edit-form flex items-center gap-2", children: [_jsx("input", { type: "text", value: newReferralCode, onChange: e => setNewReferralCode(e.target.value), className: "referral-code-input rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm", placeholder: "Enter new code", ref: referallCodeRef }), _jsx(Button, { size: "sm", className: "referral-code-save-button", onClick: handleUpdateReferralCode, disabled: isUpdatingCode || !newReferralCode, children: isUpdatingCode ? (_jsx(Loader2, { className: "referral-code-save-loading h-4 w-4 animate-spin" })) : ("Save") }), _jsx(Button, { size: "sm", variant: "ghost", className: "referral-code-cancel-button", onClick: () => {
|
|
152
185
|
setIsEditingCode(false);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
7
7
|
import { createWallet } from "thirdweb/wallets";
|
|
8
|
+
const debug = debugB3React("LoginStepCustom");
|
|
8
9
|
export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
9
10
|
const [isLoading, setIsLoading] = useState(false);
|
|
10
11
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
@@ -42,7 +43,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
|
|
|
42
43
|
connectResult = await connect(options);
|
|
43
44
|
}
|
|
44
45
|
const account = connectResult?.getAccount();
|
|
45
|
-
|
|
46
|
+
debug("@@connectResult", { connectResult, account, options });
|
|
46
47
|
if (!account)
|
|
47
48
|
throw new Error("Failed to connect");
|
|
48
49
|
await onSuccess(account);
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate.js";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA.js";
|
|
15
15
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo.js";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount.js";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted.js";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fetchSimpleHashData } from "../../../shared/utils/simplehash.js";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import invariant from "invariant";
|
|
3
4
|
async function fetchAccountAssets(address) {
|
|
4
|
-
|
|
5
|
-
throw new Error("Address is required");
|
|
5
|
+
invariant(address, "Address is required");
|
|
6
6
|
const [nftResponse] = await Promise.all([
|
|
7
7
|
fetchSimpleHashData(`/v0/nfts/owners`, {
|
|
8
8
|
chains: "b3,b3-sepolia,base",
|
|
@@ -92,7 +92,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
92
92
|
setIsAuthenticating(false);
|
|
93
93
|
}
|
|
94
94
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
95
|
-
}, [useAutoConnectLoading]);
|
|
95
|
+
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
96
96
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
if (useAutoConnectLoading) {
|
|
@@ -116,8 +116,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
116
116
|
if (activeWallet) {
|
|
117
117
|
debug("@@logout:activeWallet", activeWallet);
|
|
118
118
|
disconnect(activeWallet);
|
|
119
|
-
debug("@@logout:
|
|
120
|
-
console.log("@@gio:logout:activeWallet", activeWallet);
|
|
119
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
121
120
|
}
|
|
122
121
|
// Log out of each wallet
|
|
123
122
|
wallets.forEach(wallet => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useAuthStore } from "../../../global-account/react/index.js";
|
|
2
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
5
|
+
const debug = debugB3React("useGlobalAccount");
|
|
6
|
+
export function useGlobalAccount() {
|
|
7
|
+
const wallets = useConnectedWallets();
|
|
8
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
9
|
+
const [globalAccount, setGlobalAccount] = useState(undefined);
|
|
10
|
+
const [address, setAddress] = useState(undefined);
|
|
11
|
+
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!isConnected) {
|
|
14
|
+
debug("Not connected");
|
|
15
|
+
setGlobalAccount(undefined);
|
|
16
|
+
setAddress(undefined);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
20
|
+
const account = globalAccountWallet?.getAccount();
|
|
21
|
+
setGlobalAccount(globalAccountWallet);
|
|
22
|
+
setAddress(account?.address);
|
|
23
|
+
}, [isConnected, wallets]);
|
|
24
|
+
return {
|
|
25
|
+
account: globalAccount,
|
|
26
|
+
address,
|
|
27
|
+
info: walletInfo,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -24,11 +24,14 @@ fetchInitially = true) {
|
|
|
24
24
|
finally {
|
|
25
25
|
setIsLoading(false);
|
|
26
26
|
}
|
|
27
|
-
}, []);
|
|
27
|
+
}, [service, method]);
|
|
28
|
+
// Serialize params for stable comparison
|
|
29
|
+
const paramsJson = JSON.stringify(params);
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
if (fetchInitially) {
|
|
30
32
|
runQuery(params);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
33
36
|
return { data, error, isLoading, runQuery };
|
|
34
37
|
}
|
|
@@ -24,11 +24,14 @@ fetchInitially = true) {
|
|
|
24
24
|
finally {
|
|
25
25
|
setIsLoading(false);
|
|
26
26
|
}
|
|
27
|
-
}, []);
|
|
27
|
+
}, [service, method]);
|
|
28
|
+
// Serialize params for stable comparison
|
|
29
|
+
const paramsJson = JSON.stringify(params);
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
if (fetchInitially) {
|
|
30
32
|
runQuery(params);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
33
36
|
return { data, error, isLoading, runQuery };
|
|
34
37
|
}
|
|
@@ -3,8 +3,8 @@ async function fetchSimBalance(address) {
|
|
|
3
3
|
if (!address)
|
|
4
4
|
throw new Error("Address is required");
|
|
5
5
|
let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/v1/evm/balances/${address}?metadata=logo&chain_ids=mainnet`;
|
|
6
|
-
if (process.env.
|
|
7
|
-
url += `&localkey=${process.env.
|
|
6
|
+
if (process.env.NEXT_PUBLIC_LOCAL_KEY) {
|
|
7
|
+
url += `&localkey=${process.env.NEXT_PUBLIC_LOCAL_KEY}`;
|
|
8
8
|
}
|
|
9
9
|
const response = await fetch(url);
|
|
10
10
|
if (!response.ok) {
|
|
@@ -5,6 +5,7 @@ import { viemToThirdwebChain } from "../../../shared/constants/chains/b3Chain.js
|
|
|
5
5
|
import { getChainById } from "../../../shared/utils/chains.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getWalletBalance } from "thirdweb/wallets";
|
|
8
|
+
import invariant from "invariant";
|
|
8
9
|
export function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
9
10
|
// Normalize chains to array
|
|
10
11
|
const chainIds = Array.isArray(chainsIds) ? chainsIds : [chainsIds];
|
|
@@ -16,10 +17,12 @@ export function useTokenBalancesByChain({ address, chainsIds, enabled = true, })
|
|
|
16
17
|
const [nativeTokens, fungibleResponse] = await Promise.all([
|
|
17
18
|
// Fetch native token balances
|
|
18
19
|
Promise.all(chainIds.map(async (chainId) => {
|
|
20
|
+
const chain = getChainById(chainId);
|
|
21
|
+
invariant(chain, "Chain is required");
|
|
19
22
|
const walletBalance = await getWalletBalance({
|
|
20
23
|
address,
|
|
21
24
|
client,
|
|
22
|
-
chain: viemToThirdwebChain(
|
|
25
|
+
chain: viemToThirdwebChain(chain),
|
|
23
26
|
});
|
|
24
27
|
return {
|
|
25
28
|
...walletBalance,
|
|
@@ -34,7 +34,7 @@ export function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
34
34
|
const network = chainIdParam ? getCoingeckoChainInfo(Number(chainIdParam)).coingecko_id : "";
|
|
35
35
|
const { data: tokenInfo, isError } = useQuery({
|
|
36
36
|
queryKey: ["tokenInfo", network, currencyParam],
|
|
37
|
-
queryFn: () => fetchTokenInfo(network, currencyParam),
|
|
37
|
+
queryFn: () => fetchTokenInfo(network, currencyParam || ""),
|
|
38
38
|
enabled: shouldFetchToken,
|
|
39
39
|
staleTime: Infinity,
|
|
40
40
|
gcTime: Infinity,
|
|
@@ -47,7 +47,7 @@ export function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
47
47
|
if (isError || !tokenInfo) {
|
|
48
48
|
return {
|
|
49
49
|
...defaultToken,
|
|
50
|
-
address: currencyParam,
|
|
50
|
+
address: currencyParam || "",
|
|
51
51
|
chainId: Number(chainIdParam),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -6,50 +6,56 @@ import invariant from "invariant";
|
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
|
|
9
|
-
import {
|
|
9
|
+
import { useActiveWallet } from "thirdweb/react";
|
|
10
|
+
import { isAddress } from "viem";
|
|
11
|
+
import { useSwitchChain } from "wagmi";
|
|
10
12
|
import { useB3 } from "../components/index.js";
|
|
11
13
|
import { useAccountWallet } from "./useAccountWallet.js";
|
|
12
|
-
import { isAddress } from "viem";
|
|
13
14
|
const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
14
15
|
process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
15
16
|
process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID ||
|
|
16
17
|
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
17
18
|
invariant(partnerId, "Partner ID is required");
|
|
18
19
|
export function useUnifiedChainSwitchAndExecute() {
|
|
19
|
-
const { data: walletClient } = useWalletClient();
|
|
20
20
|
const { switchChainAsync } = useSwitchChain();
|
|
21
21
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
22
|
-
const
|
|
22
|
+
const activeWallet = useActiveWallet();
|
|
23
|
+
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = useAccountWallet();
|
|
23
24
|
const { account: aaAccount } = useB3();
|
|
24
25
|
// Handle EOA wallet chain switch and execute transaction
|
|
25
26
|
const handleEOASwitchChainAndSendTransaction = useCallback(async (targetChainId, params) => {
|
|
26
|
-
if (!
|
|
27
|
+
if (!connectedEOAWallet) {
|
|
27
28
|
toast.error("Please connect your wallet");
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
const
|
|
31
|
+
// Get target chain configuration once
|
|
32
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
33
|
+
if (!targetChain) {
|
|
34
|
+
toast.error(`Chain ${targetChainId} is not supported`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const currentChainId = activeWallet?.getChain()?.id;
|
|
38
|
+
const onCorrectChain = currentChainId === targetChainId;
|
|
32
39
|
// Helper function to execute the transaction
|
|
33
40
|
const executeTransaction = async () => {
|
|
34
|
-
const signer =
|
|
41
|
+
const signer = activeWallet?.getAccount();
|
|
35
42
|
if (!signer) {
|
|
36
43
|
throw new Error("No account connected");
|
|
37
44
|
}
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
45
|
+
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
46
|
+
const walletChain = connectedEOAWallet.getChain();
|
|
47
|
+
if (walletChain?.id !== targetChainId) {
|
|
48
|
+
activeWallet?.switchChain(getThirdwebChain(targetChainId));
|
|
42
49
|
}
|
|
43
50
|
invariant(isAddress(params.to), "params.to is not a valid address");
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
chain: targetChain,
|
|
51
|
+
const result = await signer.sendTransaction({
|
|
52
|
+
chainId: targetChainId,
|
|
47
53
|
to: params.to,
|
|
48
54
|
data: params.data,
|
|
49
55
|
value: params.value,
|
|
50
56
|
});
|
|
51
|
-
toast.success(`Transaction sent: ${
|
|
52
|
-
return
|
|
57
|
+
toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
|
|
58
|
+
return result.transactionHash;
|
|
53
59
|
};
|
|
54
60
|
try {
|
|
55
61
|
setIsSwitchingOrExecuting(true);
|
|
@@ -57,11 +63,6 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
57
63
|
return await executeTransaction();
|
|
58
64
|
}
|
|
59
65
|
const switchingToastId = toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
60
|
-
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
61
|
-
if (!targetChain) {
|
|
62
|
-
toast.error(`Chain ${targetChainId} is not supported`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
66
|
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
66
67
|
invariant(blockExplorerUrl, "Block explorer URL is required");
|
|
67
68
|
const nativeCurrency = getNativeToken(targetChainId);
|
|
@@ -96,7 +97,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
96
97
|
finally {
|
|
97
98
|
setIsSwitchingOrExecuting(false);
|
|
98
99
|
}
|
|
99
|
-
}, [
|
|
100
|
+
}, [connectedEOAWallet, activeWallet, switchChainAsync]);
|
|
100
101
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
101
102
|
const handleAASendTransaction = useCallback(async (targetChainId, params) => {
|
|
102
103
|
if (!aaAccount) {
|
|
@@ -124,18 +125,21 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
catch (err) {
|
|
127
|
-
console.error(err);
|
|
128
|
+
console.error("Create global-accounts-intents error", err);
|
|
128
129
|
}
|
|
129
130
|
toast.info("Sending transaction…");
|
|
131
|
+
const start = performance.now();
|
|
130
132
|
const sendTxResponse = await twSendTransaction({
|
|
131
133
|
account: aaAccount,
|
|
132
134
|
transaction,
|
|
133
135
|
});
|
|
136
|
+
const end = performance.now();
|
|
137
|
+
console.log("Time taken to send transaction", end - start);
|
|
134
138
|
toast.success("Transaction sent successfully");
|
|
135
139
|
return sendTxResponse.transactionHash;
|
|
136
140
|
}
|
|
137
141
|
catch (err) {
|
|
138
|
-
console.error(err);
|
|
142
|
+
console.error("Send transaction error", err);
|
|
139
143
|
toast.error(err?.message ?? "Transaction failed");
|
|
140
144
|
return undefined;
|
|
141
145
|
}
|
|
@@ -13,4 +13,4 @@ export interface AssetBalance {
|
|
|
13
13
|
totalBalance: string;
|
|
14
14
|
chainBalances: ChainBalance[];
|
|
15
15
|
}
|
|
16
|
-
export declare const fetchBalances: (address: string, testnet?: boolean) => Promise<AssetBalance[]>;
|
|
16
|
+
export declare const fetchBalances: (address: string | undefined, testnet?: boolean) => Promise<AssetBalance[]>;
|