@b3dotfun/sdk 0.0.40-alpha.2 → 0.0.40-alpha.21
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 +10 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +8 -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 +26 -10
- 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 +0 -1
- 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 -8
- 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 +1 -0
- 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/types/api.d.ts +11 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +1 -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/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 +373 -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 +35 -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/useAuthentication.js +1 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +8 -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 +26 -10
- 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 +0 -1
- 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 -8
- 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 +1 -0
- 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/types/api.d.ts +11 -1
- package/dist/esm/anyspend/utils/orderPayload.js +1 -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/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 +369 -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 +36 -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/useAuthentication.js +1 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -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/types/api.d.ts +11 -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/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +24 -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 +55 -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 +0 -1
- 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 +8 -9
- 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 +1 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api.ts +11 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/orderPayload.ts +1 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- 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 +461 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +51 -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/useAuthentication.ts +1 -2
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +23 -21
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import app from "../../../../global-account/app.js";
|
|
3
3
|
import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
4
|
+
import { thirdwebB3Mainnet } from "../../../../shared/constants/chains/b3Chain.js";
|
|
4
5
|
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
5
|
-
import { Loader2, Mail, Phone } from "lucide-react";
|
|
6
|
+
import { Loader2, Mail, Phone, WalletIcon } from "lucide-react";
|
|
6
7
|
import { useCallback, useEffect, useState } from "react";
|
|
7
8
|
import { toast } from "sonner";
|
|
8
9
|
import { useLinkProfile, useProfiles } from "thirdweb/react";
|
|
9
|
-
import { preAuthenticate } from "thirdweb/wallets";
|
|
10
|
+
import { createWallet, preAuthenticate } from "thirdweb/wallets";
|
|
11
|
+
import { WalletRow } from "../../index.js";
|
|
10
12
|
import { useModalStore } from "../../stores/useModalStore.js";
|
|
11
13
|
import { getProfileDisplayInfo } from "../../utils/profileDisplay.js";
|
|
12
14
|
import { useB3 } from "../B3Provider/useB3.js";
|
|
@@ -30,6 +32,38 @@ const AUTH_METHODS = [
|
|
|
30
32
|
icon: _jsx(FarcasterIcon, { className: "size-6" }),
|
|
31
33
|
},
|
|
32
34
|
];
|
|
35
|
+
const WALLET_METHODS = [
|
|
36
|
+
{
|
|
37
|
+
id: "wallet",
|
|
38
|
+
label: "Wallet",
|
|
39
|
+
enabled: true,
|
|
40
|
+
icon: _jsx(WalletIcon, { className: "size-6" }),
|
|
41
|
+
walletType: "com.coinbase.wallet",
|
|
42
|
+
},
|
|
43
|
+
{ id: "wallet", label: "Wallet", enabled: true, icon: _jsx(WalletIcon, { className: "size-6" }), walletType: "io.metamask" },
|
|
44
|
+
{
|
|
45
|
+
id: "wallet",
|
|
46
|
+
label: "Wallet",
|
|
47
|
+
enabled: true,
|
|
48
|
+
icon: _jsx(WalletIcon, { className: "size-6" }),
|
|
49
|
+
walletType: "me.rainbow",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "wallet",
|
|
53
|
+
label: "Wallet",
|
|
54
|
+
enabled: true,
|
|
55
|
+
icon: _jsx(WalletIcon, { className: "size-6" }),
|
|
56
|
+
walletType: "app.phantom",
|
|
57
|
+
},
|
|
58
|
+
{ id: "wallet", label: "Wallet", enabled: true, icon: _jsx(WalletIcon, { className: "size-6" }), walletType: "io.rabby" },
|
|
59
|
+
{
|
|
60
|
+
id: "wallet",
|
|
61
|
+
label: "Wallet",
|
|
62
|
+
enabled: true,
|
|
63
|
+
icon: _jsx(WalletIcon, { className: "size-6" }),
|
|
64
|
+
walletType: "walletConnect",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
33
67
|
export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, partnerId, className, }) {
|
|
34
68
|
const { isLinking, linkingMethod, setLinkingState, navigateBack, setB3ModalContentType } = useModalStore();
|
|
35
69
|
const [selectedMethod, setSelectedMethod] = useState(null);
|
|
@@ -41,12 +75,12 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
|
|
|
41
75
|
const { data: profilesRaw = [] } = useProfiles({ client });
|
|
42
76
|
// Get connected auth methods
|
|
43
77
|
const connectedAuthMethods = profilesRaw
|
|
44
|
-
.filter((profile) => !["custom_auth_endpoint"
|
|
78
|
+
.filter((profile) => !["custom_auth_endpoint"].includes(profile.type))
|
|
45
79
|
.map((profile) => profile.type);
|
|
46
80
|
// Filter available auth methods
|
|
47
81
|
const availableAuthMethods = AUTH_METHODS.filter(method => !connectedAuthMethods.includes(method.id) && method.enabled);
|
|
48
82
|
const profiles = profilesRaw
|
|
49
|
-
.filter((profile) => !["custom_auth_endpoint"
|
|
83
|
+
.filter((profile) => !["custom_auth_endpoint"].includes(profile.type))
|
|
50
84
|
.map((profile) => ({
|
|
51
85
|
...getProfileDisplayInfo(profile),
|
|
52
86
|
originalProfile: profile,
|
|
@@ -176,6 +210,26 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
|
|
|
176
210
|
onError?.(error);
|
|
177
211
|
}
|
|
178
212
|
};
|
|
213
|
+
const handleLinkWallet = async (walletType) => {
|
|
214
|
+
setLinkingState(true, "wallet");
|
|
215
|
+
console.log("selectedMethod", walletType);
|
|
216
|
+
try {
|
|
217
|
+
if (!walletType) {
|
|
218
|
+
throw new Error("Wallet type not found");
|
|
219
|
+
}
|
|
220
|
+
await linkProfile({
|
|
221
|
+
client,
|
|
222
|
+
strategy: "wallet",
|
|
223
|
+
wallet: createWallet(walletType),
|
|
224
|
+
chain: thirdwebB3Mainnet,
|
|
225
|
+
}, mutationOptions);
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error("Error linking account:", error);
|
|
229
|
+
setError(error instanceof Error ? error.message : "Failed to link account");
|
|
230
|
+
onError?.(error);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
179
233
|
const handleSocialLink = async (strategy) => {
|
|
180
234
|
try {
|
|
181
235
|
console.log("handleSocialLink", strategy);
|
|
@@ -256,5 +310,11 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
|
|
|
256
310
|
else {
|
|
257
311
|
handleSocialLink(method.id);
|
|
258
312
|
}
|
|
259
|
-
}, disabled: linkingMethod === method.id, children: isLinking && linkingMethod === method.id ? (_jsx(Loader2, { className: "h-5 w-5 animate-spin" })) : (_jsxs("div", { className: "b3-link-account-method-content flex items-center gap-4", children: [_jsx("div", { className: "b3-link-account-method-icon flex items-center justify-center rounded-full", children: method.icon }), _jsx("span", { className: "b3-link-account-method-label font-medium", children: method.label })] })) }, method.id))),
|
|
313
|
+
}, disabled: linkingMethod === method.id, children: isLinking && linkingMethod === method.id ? (_jsx(Loader2, { className: "h-5 w-5 animate-spin" })) : (_jsxs("div", { className: "b3-link-account-method-content flex items-center gap-4", children: [_jsx("div", { className: "b3-link-account-method-icon flex items-center justify-center rounded-full", children: method.icon }), _jsx("span", { className: "b3-link-account-method-label font-medium", children: method.label })] })) }, method.id))), WALLET_METHODS.map(method => {
|
|
314
|
+
if (!method.walletType) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return (_jsx(WalletRow, { walletId: method.walletType, onClick: () => handleLinkWallet(method.walletType), isLoading: isLinking }, method.walletType));
|
|
318
|
+
}), availableAuthMethods.length === 0 && (_jsx("div", { className: "text-b3-foreground-muted py-8 text-center", children: "All available authentication methods have been connected" }))] })) : (_jsxs("div", { className: "b3-link-account-form space-y-4", children: [selectedMethod === "email" && (_jsxs("div", { className: "space-y-2", children: [_jsx("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Email Address" }), _jsx("input", { type: "email", placeholder: "Enter your email", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: email, onChange: e => setEmail(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "email") })] })), selectedMethod === "phone" && (_jsxs("div", { className: "space-y-2", children: [_jsx("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Phone Number" }), _jsx("input", { type: "tel", placeholder: "Enter your phone number", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: phone, onChange: e => setPhone(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "phone") }), _jsx("p", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Include country code (e.g., +1 for US)" })] })), error && _jsx("div", { className: "text-b3-negative font-neue-montreal-medium py-2 text-sm", children: error }), (selectedMethod === "email" || selectedMethod === "phone") &&
|
|
319
|
+
(otpSent ? (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Verification Code" }), _jsx("input", { type: "text", placeholder: "Enter verification code", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: otp, onChange: e => setOtp(e.target.value) })] }), _jsx(Button, { className: "bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white", onClick: handleLinkAccount, children: "Link Account" })] })) : (_jsx(Button, { className: "bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white", onClick: handleSendOTP, disabled: (!email && !phone) || (isLinking && linkingMethod === selectedMethod), children: isLinking && linkingMethod === selectedMethod ? (_jsx(Loader2, { className: "animate-spin" })) : ("Send Verification Code") })))] }))] }));
|
|
260
320
|
}
|
|
@@ -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);
|
|
@@ -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 => {
|
|
@@ -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) {
|
|
@@ -6,10 +6,11 @@ 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 { useActiveWallet } from "thirdweb/react";
|
|
10
|
+
import { isAddress } from "viem";
|
|
9
11
|
import { useSwitchChain, useWalletClient } 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 ||
|
|
@@ -19,37 +20,43 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
19
20
|
const { data: walletClient } = useWalletClient();
|
|
20
21
|
const { switchChainAsync } = useSwitchChain();
|
|
21
22
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
22
|
-
const
|
|
23
|
+
const activeWallet = useActiveWallet();
|
|
24
|
+
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = useAccountWallet();
|
|
23
25
|
const { account: aaAccount } = useB3();
|
|
24
26
|
// Handle EOA wallet chain switch and execute transaction
|
|
25
27
|
const handleEOASwitchChainAndSendTransaction = useCallback(async (targetChainId, params) => {
|
|
26
|
-
if (!
|
|
28
|
+
if (!connectedEOAWallet) {
|
|
27
29
|
toast.error("Please connect your wallet");
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
+
// Get target chain configuration once
|
|
33
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
34
|
+
if (!targetChain) {
|
|
35
|
+
toast.error(`Chain ${targetChainId} is not supported`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const currentChainId = activeWallet?.getChain()?.id;
|
|
39
|
+
const onCorrectChain = currentChainId === targetChainId;
|
|
32
40
|
// Helper function to execute the transaction
|
|
33
41
|
const executeTransaction = async () => {
|
|
34
|
-
const signer =
|
|
42
|
+
const signer = activeWallet?.getAccount();
|
|
35
43
|
if (!signer) {
|
|
36
44
|
throw new Error("No account connected");
|
|
37
45
|
}
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
46
|
+
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
47
|
+
const walletChain = connectedEOAWallet.getChain();
|
|
48
|
+
if (walletChain?.id !== targetChainId) {
|
|
49
|
+
activeWallet?.switchChain(getThirdwebChain(targetChainId));
|
|
42
50
|
}
|
|
43
51
|
invariant(isAddress(params.to), "params.to is not a valid address");
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
chain: targetChain,
|
|
52
|
+
const result = await signer.sendTransaction({
|
|
53
|
+
chainId: targetChainId,
|
|
47
54
|
to: params.to,
|
|
48
55
|
data: params.data,
|
|
49
56
|
value: params.value,
|
|
50
57
|
});
|
|
51
|
-
toast.success(`Transaction sent: ${
|
|
52
|
-
return
|
|
58
|
+
toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
|
|
59
|
+
return result.transactionHash;
|
|
53
60
|
};
|
|
54
61
|
try {
|
|
55
62
|
setIsSwitchingOrExecuting(true);
|
|
@@ -57,11 +64,6 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
57
64
|
return await executeTransaction();
|
|
58
65
|
}
|
|
59
66
|
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
67
|
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
66
68
|
invariant(blockExplorerUrl, "Block explorer URL is required");
|
|
67
69
|
const nativeCurrency = getNativeToken(targetChainId);
|