@b3dotfun/sdk 0.0.83-alpha.3 → 0.0.83-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +28 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +5 -8
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +3 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +1 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +25 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +6 -9
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -5
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +7 -23
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +7 -30
- package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +64 -0
- package/src/anyspend/react/hooks/useConnectedUserProfile.ts +7 -10
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +2 -15
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +4 -6
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAccountWallet.tsx +12 -11
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.js +0 -148
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.js +0 -145
- package/dist/types/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/src/global-account/react/hooks/useBestTransactionPath.tsx +0 -201
|
@@ -56,6 +56,7 @@ const useCryptoPaymentMethodState_1 = require("../hooks/useCryptoPaymentMethodSt
|
|
|
56
56
|
const useRecipientAddressState_1 = require("../hooks/useRecipientAddressState");
|
|
57
57
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
58
58
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
59
|
+
const CryptoPaymentMethodDisplay_1 = require("./common/CryptoPaymentMethodDisplay");
|
|
59
60
|
const FeeBreakDown_1 = require("./common/FeeBreakDown");
|
|
60
61
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
61
62
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
@@ -337,7 +338,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
337
338
|
},
|
|
338
339
|
});
|
|
339
340
|
const isCreatingOrder = isCreatingRegularOrder || isCreatingOnrampOrder;
|
|
340
|
-
const { address: connectedAddress, name: connectedName } = (0, react_1.useConnectedUserProfile)();
|
|
341
|
+
const { address: connectedAddress, name: connectedName } = (0, react_1.useConnectedUserProfile)(effectiveCryptoPaymentMethod);
|
|
341
342
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
342
343
|
const recipientName = recipientProfile.data?.name;
|
|
343
344
|
const handleCreateOrder = async (recipientAddress, onramp) => {
|
|
@@ -559,7 +560,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
559
560
|
opacity: hasMounted ? 1 : 0,
|
|
560
561
|
y: hasMounted ? 0 : 20,
|
|
561
562
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
562
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children:
|
|
563
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: (0, jsx_runtime_1.jsx)(CryptoPaymentMethodDisplay_1.CryptoPaymentMethodDisplay, { paymentMethod: effectiveCryptoPaymentMethod, connectedAddress: connectedAddress, connectedName: connectedName }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)(react_4.motion.div, { initial: false, animate: {
|
|
563
564
|
opacity: hasMounted ? 1 : 0,
|
|
564
565
|
y: hasMounted ? 0 : 20,
|
|
565
566
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -3,14 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CryptoPaySection = CryptoPaySection;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("../../../../global-account/react");
|
|
6
|
-
const utils_1 = require("../../../../shared/utils");
|
|
7
|
-
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
8
6
|
const number_1 = require("../../../../shared/utils/number");
|
|
9
7
|
const lucide_react_1 = require("lucide-react");
|
|
10
8
|
const react_2 = require("motion/react");
|
|
11
9
|
const react_3 = require("react");
|
|
12
10
|
const useConnectedWalletDisplay_1 = require("../../hooks/useConnectedWalletDisplay");
|
|
13
|
-
const
|
|
11
|
+
const CryptoPaymentMethodDisplay_1 = require("./CryptoPaymentMethodDisplay");
|
|
14
12
|
const OrderTokenAmount_1 = require("./OrderTokenAmount");
|
|
15
13
|
const TokenBalance_1 = require("./TokenBalance");
|
|
16
14
|
function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, }) {
|
|
@@ -43,7 +41,7 @@ function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedS
|
|
|
43
41
|
(0, react_3.useEffect)(() => {
|
|
44
42
|
appliedSrcMetadataRef.current = false;
|
|
45
43
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
46
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.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: "pay-section 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.jsxs)("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }))] }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children:
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.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: "pay-section 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.jsxs)("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }))] }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: (0, jsx_runtime_1.jsx)(CryptoPaymentMethodDisplay_1.CryptoPaymentMethodDisplay, { paymentMethod: selectedCryptoPaymentMethod, connectedAddress: walletAddress, connectedName: connectedName }) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: walletAddress, walletAddress: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
47
45
|
setIsSrcInputDirty(true);
|
|
48
46
|
setSrcAmount(value);
|
|
49
47
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }), (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, {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
2
|
+
interface CryptoPaymentMethodDisplayProps {
|
|
3
|
+
paymentMethod: CryptoPaymentMethodType;
|
|
4
|
+
connectedAddress?: string | null;
|
|
5
|
+
connectedName?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Displays the selected crypto payment method with appropriate label
|
|
9
|
+
* - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
|
|
10
|
+
* - GLOBAL_WALLET: Shows "Global Account"
|
|
11
|
+
* - TRANSFER_CRYPTO: Shows "Transfer crypto"
|
|
12
|
+
* - NONE: Shows "Select payment method"
|
|
13
|
+
*/
|
|
14
|
+
export declare function CryptoPaymentMethodDisplay({ paymentMethod, connectedAddress, connectedName, }: CryptoPaymentMethodDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptoPaymentMethodDisplay = CryptoPaymentMethodDisplay;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../../../shared/utils");
|
|
6
|
+
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
7
|
+
const lucide_react_1 = require("lucide-react");
|
|
8
|
+
const CryptoPaymentMethod_1 = require("./CryptoPaymentMethod");
|
|
9
|
+
/**
|
|
10
|
+
* Displays the selected crypto payment method with appropriate label
|
|
11
|
+
* - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
|
|
12
|
+
* - GLOBAL_WALLET: Shows "Global Account"
|
|
13
|
+
* - TRANSFER_CRYPTO: Shows "Transfer crypto"
|
|
14
|
+
* - NONE: Shows "Select payment method"
|
|
15
|
+
*/
|
|
16
|
+
function CryptoPaymentMethodDisplay({ paymentMethod, connectedAddress, connectedName, }) {
|
|
17
|
+
if (paymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry whitespace-nowrap", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(connectedAddress) })) : ((0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Connect wallet" })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
19
|
+
}
|
|
20
|
+
if (paymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Global Account" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
22
|
+
}
|
|
23
|
+
if (paymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Transfer crypto" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
25
|
+
}
|
|
26
|
+
// NONE or any other case
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap", children: "Select payment method" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
28
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
1
2
|
/**
|
|
2
3
|
* Hook that provides connected user's address, profile, and cleaned display name
|
|
3
4
|
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
4
5
|
*/
|
|
5
|
-
export declare function useConnectedUserProfile(): {
|
|
6
|
+
export declare function useConnectedUserProfile(selectedCryptoPaymentMethod?: CryptoPaymentMethodType): {
|
|
6
7
|
address: string | undefined;
|
|
7
8
|
profile: import("@tanstack/react-query").UseQueryResult<import("../../../global-account/react").CombinedProfile, Error>;
|
|
8
9
|
name: string | null | undefined;
|
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useConnectedUserProfile = useConnectedUserProfile;
|
|
4
4
|
const react_1 = require("../../../global-account/react");
|
|
5
|
-
const
|
|
5
|
+
const useConnectedWalletDisplay_1 = require("./useConnectedWalletDisplay");
|
|
6
6
|
/**
|
|
7
7
|
* Hook that provides connected user's address, profile, and cleaned display name
|
|
8
8
|
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
9
9
|
*/
|
|
10
|
-
function useConnectedUserProfile() {
|
|
11
|
-
const {
|
|
12
|
-
const connectedWallets = (0, react_2.useConnectedWallets)();
|
|
13
|
-
// Get connected address from global account or first connected wallet
|
|
14
|
-
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
10
|
+
function useConnectedUserProfile(selectedCryptoPaymentMethod) {
|
|
11
|
+
const { walletAddress } = (0, useConnectedWalletDisplay_1.useConnectedWalletDisplay)(selectedCryptoPaymentMethod);
|
|
15
12
|
// Fetch profile data for the connected address with cleaned name
|
|
16
|
-
const connectedProfile = (0, react_1.useProfile)({ address:
|
|
13
|
+
const connectedProfile = (0, react_1.useProfile)({ address: walletAddress });
|
|
17
14
|
return {
|
|
18
|
-
address:
|
|
15
|
+
address: walletAddress,
|
|
19
16
|
profile: connectedProfile,
|
|
20
17
|
name: connectedProfile.data?.name,
|
|
21
18
|
isLoading: connectedProfile.isLoading,
|
|
@@ -2,8 +2,6 @@ import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMetho
|
|
|
2
2
|
interface UseConnectedWalletDisplayResult {
|
|
3
3
|
walletAddress: string | undefined;
|
|
4
4
|
shouldShowConnectedEOA: boolean;
|
|
5
|
-
shouldShowWagmiWallet: boolean;
|
|
6
|
-
isWalletDuplicated: boolean;
|
|
7
5
|
suggestedPaymentMethod: CryptoPaymentMethodType;
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
@@ -12,23 +12,15 @@ function useConnectedWalletDisplay(selectedCryptoPaymentMethod) {
|
|
|
12
12
|
const { connectedEOAWallet, connectedSmartWallet } = (0, react_1.useAccountWallet)();
|
|
13
13
|
const { address: wagmiAddress } = (0, wagmi_1.useAccount)();
|
|
14
14
|
const globalWalletAddress = connectedSmartWallet?.getAccount()?.address;
|
|
15
|
-
// Helper function to check if two addresses are the same
|
|
16
|
-
const isSameAddress = (addr1, addr2) => {
|
|
17
|
-
if (!addr1 || !addr2)
|
|
18
|
-
return false;
|
|
19
|
-
return addr1.toLowerCase() === addr2.toLowerCase();
|
|
20
|
-
};
|
|
21
15
|
// Check if connectedEOAWallet and wagmi wallet represent the same wallet
|
|
22
16
|
const connectedEOAAddress = connectedEOAWallet?.getAccount()?.address;
|
|
23
|
-
const isWalletDuplicated = isSameAddress(connectedEOAAddress, wagmiAddress) || isSameAddress(globalWalletAddress, wagmiAddress);
|
|
24
17
|
// Determine which wallet to show (prefer connectedEOAWallet if both exist and are the same)
|
|
25
18
|
const shouldShowConnectedEOA = !!connectedEOAWallet;
|
|
26
19
|
// this is disabled because we don't want to display In-App Wallet as a payment method
|
|
27
|
-
const shouldShowWagmiWallet = false; // wagmiWalletIsConnected && (!isWalletDuplicated || !connectedEOAWallet);
|
|
28
20
|
// Determine which address to use based on payment method
|
|
29
21
|
let walletAddress;
|
|
30
22
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
31
|
-
walletAddress =
|
|
23
|
+
walletAddress = globalWalletAddress;
|
|
32
24
|
}
|
|
33
25
|
else if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
34
26
|
// Prefer connectedEOAWallet, fallback to wagmi wallet
|
|
@@ -45,15 +37,13 @@ function useConnectedWalletDisplay(selectedCryptoPaymentMethod) {
|
|
|
45
37
|
// If there's a connected EOA or wagmi wallet, suggest CONNECT_WALLET
|
|
46
38
|
suggestedPaymentMethod = CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET;
|
|
47
39
|
}
|
|
48
|
-
else if (
|
|
40
|
+
else if (globalWalletAddress) {
|
|
49
41
|
// If only global wallet is available, suggest that
|
|
50
42
|
suggestedPaymentMethod = CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET;
|
|
51
43
|
}
|
|
52
44
|
return {
|
|
53
45
|
walletAddress,
|
|
54
46
|
shouldShowConnectedEOA,
|
|
55
|
-
shouldShowWagmiWallet,
|
|
56
|
-
isWalletDuplicated,
|
|
57
47
|
suggestedPaymentMethod,
|
|
58
48
|
};
|
|
59
49
|
}
|
|
@@ -12,12 +12,12 @@ const utils_1 = require("../../../../shared/utils");
|
|
|
12
12
|
const react_2 = require("@headlessui/react");
|
|
13
13
|
const react_3 = require("react");
|
|
14
14
|
const react_4 = require("thirdweb/react");
|
|
15
|
-
const useAccountWallet_1 = require("../../hooks/useAccountWallet");
|
|
16
15
|
const ManageAccountButton_1 = require("../custom/ManageAccountButton");
|
|
17
16
|
function SignIn(props) {
|
|
18
17
|
const { className } = props;
|
|
19
18
|
const { automaticallySetFirstEoa, partnerId } = (0, react_1.useB3)();
|
|
20
|
-
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon,
|
|
19
|
+
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, } = (0, react_1.useAccountWallet)();
|
|
20
|
+
const { data: walletImage } = (0, react_4.useWalletImage)(connectedEOAWallet?.id);
|
|
21
21
|
const isMobile = (0, react_1.useIsMobile)();
|
|
22
22
|
const { logout } = (0, react_1.useAuthentication)(partnerId);
|
|
23
23
|
const onDisconnect = async () => {
|
|
@@ -40,11 +40,10 @@ function SignIn(props) {
|
|
|
40
40
|
setActiveWallet(connectedEOAWallet);
|
|
41
41
|
}
|
|
42
42
|
}, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
|
|
43
|
-
const walletImage = (0, useAccountWallet_1.useAccountWalletImage)();
|
|
44
43
|
// Desktop version - original dropdown menu
|
|
45
44
|
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)(react_2.Menu, { className: `relative flex items-center ${className || ""}`, as: "div", children: globalAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_2.MenuButton, { className: "bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3 focus:outline-none", children: [!!walletImage && ((0, jsx_runtime_1.jsx)(react_1.IPFSMediaRenderer, { src: walletImage, alt: "Wallet Image", className: "bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", children: ensName ? ensName : (0, utils_1.truncateAddress)(globalAddress) })] }), (0, jsx_runtime_1.jsx)(react_2.Transition, { enter: "duration-200 ease-out", enterFrom: "scale-95 opacity-0", enterTo: "scale-100 opacity-100", leave: "duration-300 ease-out", leaveFrom: "scale-100 opacity-100", leaveTo: "scale-95 opacity-0", children: (0, jsx_runtime_1.jsx)(react_2.MenuItems, { className: "b3-root absolute -right-4 top-full min-w-64 rounded-2xl border focus:outline-none lg:right-0", modal: false,
|
|
46
45
|
// TODO: Figure out why setting anchor on mobile causes z-index issues where it appears under elements
|
|
47
|
-
anchor: isMobile ? "top end" : undefined, children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src:
|
|
46
|
+
anchor: isMobile ? "top end" : undefined, children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: walletImage, alt: connectedEOAWallet?.id }), (0, jsx_runtime_1.jsxs)("div", { className: "ml-4 grow", children: [ensName && (0, jsx_runtime_1.jsx)("div", { children: ensName }), (0, jsx_runtime_1.jsx)("div", { children: (0, utils_1.truncateAddress)(globalAddress) })] })] }), isActiveEOAWallet && (0, jsx_runtime_1.jsx)(Icon_1.default, { className: "fill-b3-react-primary", name: "check" })] })) : (connectedSmartWallet && ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mb-2 flex cursor-pointer items-center justify-between rounded-xl p-3", isActiveSmartWallet
|
|
48
47
|
? "bg-b3-react-background"
|
|
49
48
|
: "bg-b3-react-background hover:bg-b3-react-background"), onClick: () => handleSetActiveAccount(connectedSmartWallet?.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: smartWalletIcon, alt: connectedSmartWallet?.id }), (0, jsx_runtime_1.jsxs)("div", { className: "grow pl-4", children: [ensName && (0, jsx_runtime_1.jsx)("div", { children: ensName }), (0, jsx_runtime_1.jsx)("div", { children: (0, utils_1.truncateAddress)(globalAddress) }), (0, jsx_runtime_1.jsx)("div", { children: "Smart wallet" })] })] }), isActiveSmartWallet && (0, jsx_runtime_1.jsx)(Icon_1.default, { className: "fill-b3-react-primary", name: "check" })] }))), (0, jsx_runtime_1.jsx)("div", { className: "ml-3", children: (0, jsx_runtime_1.jsx)(ManageAccountButton_1.ManageAccountButton, { ...props, className: "w-[calc(100%-12px)]" }) }), (0, jsx_runtime_1.jsx)("button", { className: "mb-2 w-full space-y-1", onClick: onDisconnect, children: (0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { className: "fill-b3-react-primary mr-4 shrink-0 transition-colors", name: "logout" }), (0, jsx_runtime_1.jsx)("div", { className: "text-b3-react-primary mr-auto transition-colors", children: "Disconnect" })] }) })] }) }) })] })) : ((0, jsx_runtime_1.jsx)(react_1.SignInWithB3, { closeAfterLogin: true, onLoginSuccess: async (globalAccount) => {
|
|
50
49
|
console.log("User authenticated with Global Account!", globalAccount);
|
|
@@ -16,7 +16,7 @@ function LoginStepContainer({ children, partnerId }) {
|
|
|
16
16
|
},
|
|
17
17
|
}, !!partnerId);
|
|
18
18
|
const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
|
|
19
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center justify-center pt-6", children: [partnerLogo && ((0, jsx_runtime_1.jsx)("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex flex-col items-center justify-center pt-6", children: [partnerLogo && ((0, jsx_runtime_1.jsx)("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
|
|
20
20
|
}
|
|
21
21
|
function LoginStep({ onSuccess, chain }) {
|
|
22
22
|
const { partnerId, theme } = (0, react_1.useB3)();
|
|
@@ -6,7 +6,6 @@ export { useAnalytics } from "./useAnalytics";
|
|
|
6
6
|
export { useAuthentication } from "./useAuthentication";
|
|
7
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
8
8
|
export { useB3EnsName } from "./useB3EnsName";
|
|
9
|
-
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
10
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
11
10
|
export * from "./useClaim";
|
|
12
11
|
export { useClient } from "./useClient";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.
|
|
17
|
+
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
|
|
18
18
|
var createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
19
19
|
Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
|
|
20
20
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
@@ -31,8 +31,6 @@ var useB3BalanceFromAddresses_1 = require("./useB3BalanceFromAddresses");
|
|
|
31
31
|
Object.defineProperty(exports, "useB3BalanceFromAddresses", { enumerable: true, get: function () { return useB3BalanceFromAddresses_1.useB3BalanceFromAddresses; } });
|
|
32
32
|
var useB3EnsName_1 = require("./useB3EnsName");
|
|
33
33
|
Object.defineProperty(exports, "useB3EnsName", { enumerable: true, get: function () { return useB3EnsName_1.useB3EnsName; } });
|
|
34
|
-
var useBestTransactionPath_1 = require("./useBestTransactionPath");
|
|
35
|
-
Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get: function () { return useBestTransactionPath_1.useBestTransactionPath; } });
|
|
36
34
|
var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
|
|
37
35
|
Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
|
|
38
36
|
__exportStar(require("./useClaim"), exports);
|
|
@@ -5,7 +5,6 @@ exports.useAccountWalletImage = useAccountWalletImage;
|
|
|
5
5
|
const react_1 = require("../../../global-account/react");
|
|
6
6
|
const constants_1 = require("../../../shared/constants");
|
|
7
7
|
const debug_1 = require("../../../shared/utils/debug");
|
|
8
|
-
const ipfs_1 = require("../../../shared/utils/ipfs");
|
|
9
8
|
const react_2 = require("react");
|
|
10
9
|
const react_3 = require("thirdweb/react");
|
|
11
10
|
const in_app_1 = require("thirdweb/wallets/in-app");
|
|
@@ -22,7 +21,13 @@ function useLastAuthProvider() {
|
|
|
22
21
|
return lastAuthProvider;
|
|
23
22
|
}
|
|
24
23
|
function useAccountWallet() {
|
|
25
|
-
|
|
24
|
+
// WOJ: --------------------
|
|
25
|
+
// values from in useB3:
|
|
26
|
+
// const activeAccount = useActiveAccount();
|
|
27
|
+
// const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
28
|
+
// can we possibly just use useActiveAccount here?
|
|
29
|
+
// --------------------
|
|
30
|
+
const { account } = (0, react_1.useB3)();
|
|
26
31
|
const activeWallet = (0, react_3.useActiveWallet)();
|
|
27
32
|
const connectedWallets = (0, react_3.useConnectedWallets)();
|
|
28
33
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === constants_1.ecosystemWalletId);
|
|
@@ -35,7 +40,6 @@ function useAccountWallet() {
|
|
|
35
40
|
debug("connectedEOAWallet", connectedEOAWallet);
|
|
36
41
|
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
37
42
|
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
38
|
-
const { data: walletImage } = (0, react_3.useWalletImage)(connectedEOAWallet?.id);
|
|
39
43
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
40
44
|
const lastAuthProvider = useLastAuthProvider();
|
|
41
45
|
const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
|
|
@@ -43,13 +47,12 @@ function useAccountWallet() {
|
|
|
43
47
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
44
48
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
45
49
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
46
|
-
const avatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profileData?.avatar;
|
|
47
50
|
const res = (0, react_2.useMemo)(() => ({
|
|
48
51
|
wallet: {
|
|
49
52
|
...account,
|
|
50
53
|
ensName,
|
|
51
54
|
meta: {
|
|
52
|
-
icon:
|
|
55
|
+
icon: "", // deprecated
|
|
53
56
|
},
|
|
54
57
|
},
|
|
55
58
|
address: account?.address,
|
|
@@ -59,22 +62,20 @@ function useAccountWallet() {
|
|
|
59
62
|
isActiveSmartWallet: isActiveSmartWallet,
|
|
60
63
|
isActiveEOAWallet: isActiveEOAWallet,
|
|
61
64
|
smartWalletIcon: smartWalletIcon,
|
|
62
|
-
eoaWalletIcon:
|
|
65
|
+
eoaWalletIcon: "", // deprecated
|
|
63
66
|
}), [
|
|
64
67
|
account,
|
|
65
|
-
avatarUrl,
|
|
66
68
|
connectedEOAWallet,
|
|
67
69
|
connectedSmartWallet,
|
|
68
70
|
ensName,
|
|
69
71
|
isActiveEOAWallet,
|
|
70
72
|
isActiveSmartWallet,
|
|
71
73
|
smartWalletIcon,
|
|
72
|
-
walletImage,
|
|
73
74
|
]);
|
|
74
75
|
return res;
|
|
75
76
|
}
|
|
76
77
|
function useAccountWalletImage() {
|
|
77
|
-
const { account
|
|
78
|
+
const { account } = (0, react_1.useB3)();
|
|
78
79
|
const activeWallet = (0, react_3.useActiveWallet)();
|
|
79
80
|
const connectedWallets = (0, react_3.useConnectedWallets)();
|
|
80
81
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === constants_1.ecosystemWalletId);
|
|
@@ -87,6 +88,6 @@ function useAccountWalletImage() {
|
|
|
87
88
|
? in_app_1.socialIcons[lastAuthProvider]
|
|
88
89
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
89
90
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
90
|
-
const avatarUrl =
|
|
91
|
+
const avatarUrl = profileData?.avatar;
|
|
91
92
|
return avatarUrl || (isActiveSmartWallet ? smartWalletIcon : walletImage) || "";
|
|
92
93
|
}
|
|
@@ -17,6 +17,7 @@ import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodStat
|
|
|
17
17
|
import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
|
|
18
18
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
19
19
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
20
|
+
import { CryptoPaymentMethodDisplay } from "./common/CryptoPaymentMethodDisplay.js";
|
|
20
21
|
import { FeeBreakDown } from "./common/FeeBreakDown.js";
|
|
21
22
|
import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
22
23
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
@@ -298,7 +299,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
298
299
|
},
|
|
299
300
|
});
|
|
300
301
|
const isCreatingOrder = isCreatingRegularOrder || isCreatingOnrampOrder;
|
|
301
|
-
const { address: connectedAddress, name: connectedName } = useConnectedUserProfile();
|
|
302
|
+
const { address: connectedAddress, name: connectedName } = useConnectedUserProfile(effectiveCryptoPaymentMethod);
|
|
302
303
|
const recipientProfile = useProfile({ address: recipientAddress });
|
|
303
304
|
const recipientName = recipientProfile.data?.name;
|
|
304
305
|
const handleCreateOrder = async (recipientAddress, onramp) => {
|
|
@@ -520,7 +521,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
520
521
|
opacity: hasMounted ? 1 : 0,
|
|
521
522
|
y: hasMounted ? 0 : 20,
|
|
522
523
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
523
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children:
|
|
524
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: _jsx(CryptoPaymentMethodDisplay, { paymentMethod: effectiveCryptoPaymentMethod, connectedAddress: connectedAddress, connectedName: connectedName }) })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
524
525
|
opacity: hasMounted ? 1 : 0,
|
|
525
526
|
y: hasMounted ? 0 : 20,
|
|
526
527
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useProfile, useTokenData } from "../../../../global-account/react/index.js";
|
|
3
|
-
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
4
|
-
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
5
3
|
import { formatDisplayNumber } from "../../../../shared/utils/number.js";
|
|
6
|
-
import {
|
|
4
|
+
import { Info } from "lucide-react";
|
|
7
5
|
import { motion } from "motion/react";
|
|
8
6
|
import { useEffect, useRef } from "react";
|
|
9
7
|
import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay.js";
|
|
10
|
-
import {
|
|
8
|
+
import { CryptoPaymentMethodDisplay } from "./CryptoPaymentMethodDisplay.js";
|
|
11
9
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
12
10
|
import { TokenBalance } from "./TokenBalance.js";
|
|
13
11
|
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, }) {
|
|
@@ -40,7 +38,7 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
40
38
|
useEffect(() => {
|
|
41
39
|
appliedSrcMetadataRef.current = false;
|
|
42
40
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
43
|
-
return (_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: "pay-section 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: [_jsxs("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children:
|
|
41
|
+
return (_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: "pay-section 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: [_jsxs("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: _jsx(CryptoPaymentMethodDisplay, { paymentMethod: selectedCryptoPaymentMethod, connectedAddress: walletAddress, connectedName: connectedName }) })] }), _jsx(OrderTokenAmount, { address: walletAddress, walletAddress: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
44
42
|
setIsSrcInputDirty(true);
|
|
45
43
|
setSrcAmount(value);
|
|
46
44
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }), _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, {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
2
|
+
interface CryptoPaymentMethodDisplayProps {
|
|
3
|
+
paymentMethod: CryptoPaymentMethodType;
|
|
4
|
+
connectedAddress?: string | null;
|
|
5
|
+
connectedName?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Displays the selected crypto payment method with appropriate label
|
|
9
|
+
* - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
|
|
10
|
+
* - GLOBAL_WALLET: Shows "Global Account"
|
|
11
|
+
* - TRANSFER_CRYPTO: Shows "Transfer crypto"
|
|
12
|
+
* - NONE: Shows "Select payment method"
|
|
13
|
+
*/
|
|
14
|
+
export declare function CryptoPaymentMethodDisplay({ paymentMethod, connectedAddress, connectedName, }: CryptoPaymentMethodDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
3
|
+
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
4
|
+
import { ChevronRight } from "lucide-react";
|
|
5
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod.js";
|
|
6
|
+
/**
|
|
7
|
+
* Displays the selected crypto payment method with appropriate label
|
|
8
|
+
* - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
|
|
9
|
+
* - GLOBAL_WALLET: Shows "Global Account"
|
|
10
|
+
* - TRANSFER_CRYPTO: Shows "Transfer crypto"
|
|
11
|
+
* - NONE: Shows "Select payment method"
|
|
12
|
+
*/
|
|
13
|
+
export function CryptoPaymentMethodDisplay({ paymentMethod, connectedAddress, connectedName, }) {
|
|
14
|
+
if (paymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
15
|
+
return (_jsxs(_Fragment, { children: [connectedAddress ? (_jsx("span", { className: "text-as-tertiarry whitespace-nowrap", children: connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress) })) : (_jsx("span", { className: "whitespace-nowrap", children: "Connect wallet" })), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
16
|
+
}
|
|
17
|
+
if (paymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Global Account" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
19
|
+
}
|
|
20
|
+
if (paymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Transfer crypto" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
22
|
+
}
|
|
23
|
+
// NONE or any other case
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap", children: "Select payment method" }), _jsx(ChevronRight, { className: "h-4 w-4 shrink-0" })] }));
|
|
25
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
1
2
|
/**
|
|
2
3
|
* Hook that provides connected user's address, profile, and cleaned display name
|
|
3
4
|
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
4
5
|
*/
|
|
5
|
-
export declare function useConnectedUserProfile(): {
|
|
6
|
+
export declare function useConnectedUserProfile(selectedCryptoPaymentMethod?: CryptoPaymentMethodType): {
|
|
6
7
|
address: string | undefined;
|
|
7
8
|
profile: import("@tanstack/react-query").UseQueryResult<import("../../../global-account/react").CombinedProfile, Error>;
|
|
8
9
|
name: string | null | undefined;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useProfile } from "../../../global-account/react/index.js";
|
|
2
|
+
import { useConnectedWalletDisplay } from "./useConnectedWalletDisplay.js";
|
|
3
3
|
/**
|
|
4
4
|
* Hook that provides connected user's address, profile, and cleaned display name
|
|
5
5
|
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
6
6
|
*/
|
|
7
|
-
export function useConnectedUserProfile() {
|
|
8
|
-
const {
|
|
9
|
-
const connectedWallets = useConnectedWallets();
|
|
10
|
-
// Get connected address from global account or first connected wallet
|
|
11
|
-
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
7
|
+
export function useConnectedUserProfile(selectedCryptoPaymentMethod) {
|
|
8
|
+
const { walletAddress } = useConnectedWalletDisplay(selectedCryptoPaymentMethod);
|
|
12
9
|
// Fetch profile data for the connected address with cleaned name
|
|
13
|
-
const connectedProfile = useProfile({ address:
|
|
10
|
+
const connectedProfile = useProfile({ address: walletAddress });
|
|
14
11
|
return {
|
|
15
|
-
address:
|
|
12
|
+
address: walletAddress,
|
|
16
13
|
profile: connectedProfile,
|
|
17
14
|
name: connectedProfile.data?.name,
|
|
18
15
|
isLoading: connectedProfile.isLoading,
|
|
@@ -2,8 +2,6 @@ import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMetho
|
|
|
2
2
|
interface UseConnectedWalletDisplayResult {
|
|
3
3
|
walletAddress: string | undefined;
|
|
4
4
|
shouldShowConnectedEOA: boolean;
|
|
5
|
-
shouldShowWagmiWallet: boolean;
|
|
6
|
-
isWalletDuplicated: boolean;
|
|
7
5
|
suggestedPaymentMethod: CryptoPaymentMethodType;
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
@@ -9,23 +9,15 @@ export function useConnectedWalletDisplay(selectedCryptoPaymentMethod) {
|
|
|
9
9
|
const { connectedEOAWallet, connectedSmartWallet } = useAccountWallet();
|
|
10
10
|
const { address: wagmiAddress } = useAccount();
|
|
11
11
|
const globalWalletAddress = connectedSmartWallet?.getAccount()?.address;
|
|
12
|
-
// Helper function to check if two addresses are the same
|
|
13
|
-
const isSameAddress = (addr1, addr2) => {
|
|
14
|
-
if (!addr1 || !addr2)
|
|
15
|
-
return false;
|
|
16
|
-
return addr1.toLowerCase() === addr2.toLowerCase();
|
|
17
|
-
};
|
|
18
12
|
// Check if connectedEOAWallet and wagmi wallet represent the same wallet
|
|
19
13
|
const connectedEOAAddress = connectedEOAWallet?.getAccount()?.address;
|
|
20
|
-
const isWalletDuplicated = isSameAddress(connectedEOAAddress, wagmiAddress) || isSameAddress(globalWalletAddress, wagmiAddress);
|
|
21
14
|
// Determine which wallet to show (prefer connectedEOAWallet if both exist and are the same)
|
|
22
15
|
const shouldShowConnectedEOA = !!connectedEOAWallet;
|
|
23
16
|
// this is disabled because we don't want to display In-App Wallet as a payment method
|
|
24
|
-
const shouldShowWagmiWallet = false; // wagmiWalletIsConnected && (!isWalletDuplicated || !connectedEOAWallet);
|
|
25
17
|
// Determine which address to use based on payment method
|
|
26
18
|
let walletAddress;
|
|
27
19
|
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET) {
|
|
28
|
-
walletAddress =
|
|
20
|
+
walletAddress = globalWalletAddress;
|
|
29
21
|
}
|
|
30
22
|
else if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
31
23
|
// Prefer connectedEOAWallet, fallback to wagmi wallet
|
|
@@ -42,15 +34,13 @@ export function useConnectedWalletDisplay(selectedCryptoPaymentMethod) {
|
|
|
42
34
|
// If there's a connected EOA or wagmi wallet, suggest CONNECT_WALLET
|
|
43
35
|
suggestedPaymentMethod = CryptoPaymentMethodType.CONNECT_WALLET;
|
|
44
36
|
}
|
|
45
|
-
else if (
|
|
37
|
+
else if (globalWalletAddress) {
|
|
46
38
|
// If only global wallet is available, suggest that
|
|
47
39
|
suggestedPaymentMethod = CryptoPaymentMethodType.GLOBAL_WALLET;
|
|
48
40
|
}
|
|
49
41
|
return {
|
|
50
42
|
walletAddress,
|
|
51
43
|
shouldShowConnectedEOA,
|
|
52
|
-
shouldShowWagmiWallet,
|
|
53
|
-
isWalletDuplicated,
|
|
54
44
|
suggestedPaymentMethod,
|
|
55
45
|
};
|
|
56
46
|
}
|
|
@@ -5,13 +5,13 @@ import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
|
5
5
|
import { cn, truncateAddress } from "../../../../shared/utils/index.js";
|
|
6
6
|
import { Menu, MenuButton, MenuItems, Transition } from "@headlessui/react";
|
|
7
7
|
import { useEffect } from "react";
|
|
8
|
-
import { useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
9
|
-
import { useAccountWalletImage } from "../../hooks/useAccountWallet.js";
|
|
8
|
+
import { useConnectedWallets, useSetActiveWallet, useWalletImage } from "thirdweb/react";
|
|
10
9
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
11
10
|
export function SignIn(props) {
|
|
12
11
|
const { className } = props;
|
|
13
12
|
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
14
|
-
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon,
|
|
13
|
+
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, } = useAccountWallet();
|
|
14
|
+
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
15
15
|
const isMobile = useIsMobile();
|
|
16
16
|
const { logout } = useAuthentication(partnerId);
|
|
17
17
|
const onDisconnect = async () => {
|
|
@@ -34,11 +34,10 @@ export function SignIn(props) {
|
|
|
34
34
|
setActiveWallet(connectedEOAWallet);
|
|
35
35
|
}
|
|
36
36
|
}, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
|
|
37
|
-
const walletImage = useAccountWalletImage();
|
|
38
37
|
// Desktop version - original dropdown menu
|
|
39
38
|
return (_jsx(StyleRoot, { children: _jsx(Menu, { className: `relative flex items-center ${className || ""}`, as: "div", children: globalAddress ? (_jsxs(_Fragment, { children: [_jsxs(MenuButton, { className: "bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3 focus:outline-none", children: [!!walletImage && (_jsx(IPFSMediaRenderer, { src: walletImage, alt: "Wallet Image", className: "bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100" })), _jsx("div", { className: "text-as-primary", children: ensName ? ensName : truncateAddress(globalAddress) })] }), _jsx(Transition, { enter: "duration-200 ease-out", enterFrom: "scale-95 opacity-0", enterTo: "scale-100 opacity-100", leave: "duration-300 ease-out", leaveFrom: "scale-100 opacity-100", leaveTo: "scale-95 opacity-0", children: _jsx(MenuItems, { className: "b3-root absolute -right-4 top-full min-w-64 rounded-2xl border focus:outline-none lg:right-0", modal: false,
|
|
40
39
|
// TODO: Figure out why setting anchor on mobile causes z-index issues where it appears under elements
|
|
41
|
-
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src:
|
|
40
|
+
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: walletImage, alt: connectedEOAWallet?.id }), _jsxs("div", { className: "ml-4 grow", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) })] })] }), isActiveEOAWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] })) : (connectedSmartWallet && (_jsxs("div", { className: cn("mb-2 flex cursor-pointer items-center justify-between rounded-xl p-3", isActiveSmartWallet
|
|
42
41
|
? "bg-b3-react-background"
|
|
43
42
|
: "bg-b3-react-background hover:bg-b3-react-background"), onClick: () => handleSetActiveAccount(connectedSmartWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: smartWalletIcon, alt: connectedSmartWallet?.id }), _jsxs("div", { className: "grow pl-4", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) }), _jsx("div", { children: "Smart wallet" })] })] }), isActiveSmartWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] }))), _jsx("div", { className: "ml-3", children: _jsx(ManageAccountButton, { ...props, className: "w-[calc(100%-12px)]" }) }), _jsx("button", { className: "mb-2 w-full space-y-1", onClick: onDisconnect, children: _jsxs("div", { className: "hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors", children: [_jsx(Icon, { className: "fill-b3-react-primary mr-4 shrink-0 transition-colors", name: "logout" }), _jsx("div", { className: "text-b3-react-primary mr-auto transition-colors", children: "Disconnect" })] }) })] }) }) })] })) : (_jsx(SignInWithB3, { closeAfterLogin: true, onLoginSuccess: async (globalAccount) => {
|
|
44
43
|
console.log("User authenticated with Global Account!", globalAccount);
|