@b3dotfun/sdk 0.0.19 → 0.0.20-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +18 -15
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +42 -95
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +0 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +0 -4
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +1 -2
- package/dist/cjs/anyspend/types/api.d.ts +1 -16
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +18 -11
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -2
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +12 -1
- package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +19 -16
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -98
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +0 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +0 -4
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +1 -2
- package/dist/esm/anyspend/types/api.d.ts +1 -16
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +19 -12
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +12 -1
- package/dist/esm/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +1 -16
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/types/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +57 -23
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +61 -96
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +0 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +0 -1
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +0 -6
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +0 -1
- package/src/anyspend/react/hooks/useStripeSupport.ts +3 -4
- package/src/anyspend/services/anyspend.ts +0 -2
- package/src/anyspend/types/api.ts +1 -16
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +19 -11
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -2
- package/src/global-account/react/hooks/index.ts +1 -1
- package/src/global-account/react/hooks/useAuthentication.ts +12 -1
- package/src/global-account/react/stores/useAuthStore.ts +8 -0
|
@@ -18,9 +18,9 @@ const lucide_react_1 = require("lucide-react");
|
|
|
18
18
|
const react_3 = require("motion/react");
|
|
19
19
|
const react_4 = require("react");
|
|
20
20
|
const sonner_1 = require("sonner");
|
|
21
|
+
const react_5 = require("thirdweb/react");
|
|
21
22
|
const viem_1 = require("viem");
|
|
22
23
|
const chains_1 = require("viem/chains");
|
|
23
|
-
const wagmi_1 = require("wagmi");
|
|
24
24
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
25
25
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
26
26
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
@@ -51,7 +51,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
51
51
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
52
52
|
const router = (0, react_2.useRouter)();
|
|
53
53
|
// Get wagmi account state for wallet connection
|
|
54
|
-
const
|
|
54
|
+
const connectedWallets = (0, react_5.useConnectedWallets)();
|
|
55
55
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
56
56
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
57
57
|
// Add refs to track URL state
|
|
@@ -343,6 +343,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
343
343
|
amount: srcAmountOnrampInWei,
|
|
344
344
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
345
345
|
});
|
|
346
|
+
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
347
|
+
const connectedProfile = (0, react_2.useProfile)({ address: connectedAddress });
|
|
348
|
+
const connectedName = connectedProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
346
349
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
347
350
|
const recipientName = recipientProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
348
351
|
// Load custom recipients from local storage on mount
|
|
@@ -725,7 +728,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
725
728
|
vendor: vendor,
|
|
726
729
|
paymentMethod: paymentMethodString,
|
|
727
730
|
country: geoData?.country || "US",
|
|
728
|
-
ipAddress: geoData?.ip,
|
|
729
731
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
730
732
|
},
|
|
731
733
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -808,7 +810,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
808
810
|
setActiveTab("fiat");
|
|
809
811
|
setSelectedPaymentMethod(CryptoPaymentMethod_1.PaymentMethod.NONE); // Reset crypto payment method when switching to fiat
|
|
810
812
|
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
|
|
811
|
-
}, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-
|
|
813
|
+
}, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalWallet?.meta?.icon && ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry", children: connectedName || (0, formatAddress_1.shortenAddress)(connectedAddress || "") })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
812
814
|
setIsSrcInputDirty(true);
|
|
813
815
|
setSrcAmount(value);
|
|
814
816
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
|
|
@@ -833,7 +835,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
833
835
|
const tempDstAmount = dstAmount;
|
|
834
836
|
setSrcAmount(tempDstAmount);
|
|
835
837
|
setDstAmount(tempSrcAmount);
|
|
836
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-
|
|
838
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [globalAddress && recipientAddress === globalAddress && globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet?.meta?.icon, alt: "Current wallet", className: "bg-as-primary h-6 w-6 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs text-white", children: "\uD83E\uDD8A" })), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: recipientName ? recipientName : (0, formatAddress_1.shortenAddress)(recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-3 w-3" })] }))] }), isBuyMode ? (
|
|
837
839
|
// Fixed destination token display in buy mode
|
|
838
840
|
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : ((0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
|
|
839
841
|
setIsSrcInputDirty(false);
|
|
@@ -892,26 +894,27 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
892
894
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
893
895
|
}, srcAmountOnRamp: srcAmountOnRamp, isMainnet: isMainnet }));
|
|
894
896
|
// Add tabs to the main component when no order is loaded
|
|
895
|
-
return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
897
|
+
return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
898
|
+
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: (0, jsx_runtime_1.jsx)(react_2.TransitionPanel, { activeIndex: orderId
|
|
896
899
|
? oat
|
|
897
900
|
? PanelView.ORDER_DETAILS
|
|
898
901
|
: PanelView.LOADING
|
|
899
902
|
: activePanel === PanelView.ORDER_DETAILS
|
|
900
903
|
? PanelView.MAIN
|
|
901
|
-
: activePanel, className: (0, cn_1.cn)("
|
|
904
|
+
: activePanel, className: (0, cn_1.cn)("rounded-2xl", {
|
|
902
905
|
"mt-0": mode === "modal",
|
|
903
906
|
}), variants: {
|
|
904
907
|
enter: { x: 300, opacity: 0 },
|
|
905
908
|
center: { x: 0, opacity: 1 },
|
|
906
909
|
exit: { x: -300, opacity: 0 },
|
|
907
910
|
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
908
|
-
(0, jsx_runtime_1.jsx)("div", { children: mainView }, "main-view"),
|
|
909
|
-
(0, jsx_runtime_1.jsx)("div", { children: historyView }, "history-view"),
|
|
910
|
-
(0, jsx_runtime_1.jsx)("div", { children: orderDetailsView }, "order-details-view"),
|
|
911
|
-
(0, jsx_runtime_1.jsx)("div", { children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
|
|
912
|
-
(0, jsx_runtime_1.jsx)("div", { children: onrampPaymentView }, "fiat-payment-view"),
|
|
913
|
-
(0, jsx_runtime_1.jsx)("div", { children: recipientSelectionView }, "recipient-selection-view"),
|
|
914
|
-
(0, jsx_runtime_1.jsx)("div", { children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
915
|
-
(0, jsx_runtime_1.jsx)("div", { children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
911
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
912
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: historyView }, "history-view"),
|
|
913
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
|
|
914
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
|
|
915
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: onrampPaymentView }, "fiat-payment-view"),
|
|
916
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
917
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
918
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
916
919
|
] }) }) }));
|
|
917
920
|
}
|
|
@@ -306,7 +306,6 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
306
306
|
vendor: onramp.vendor,
|
|
307
307
|
paymentMethod: onramp.paymentMethod,
|
|
308
308
|
country: geoData?.country || "US",
|
|
309
|
-
ipAddress: geoData?.ip,
|
|
310
309
|
redirectUrl: window.location.origin === "https://basement.fun"
|
|
311
310
|
? "https://basement.fun/deposit"
|
|
312
311
|
: window.location.origin,
|
|
@@ -5,12 +5,16 @@ exports.PaymentMethod = void 0;
|
|
|
5
5
|
exports.CryptoPaymentMethod = CryptoPaymentMethod;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
|
+
const b3Chain_1 = require("../../../../shared/constants/chains/b3Chain");
|
|
8
9
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
9
10
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
11
|
+
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
10
12
|
const lucide_react_1 = require("lucide-react");
|
|
11
13
|
const react_2 = require("react");
|
|
14
|
+
const react_dom_1 = require("react-dom");
|
|
12
15
|
const sonner_1 = require("sonner");
|
|
13
16
|
const react_3 = require("thirdweb/react");
|
|
17
|
+
const wallets_1 = require("thirdweb/wallets");
|
|
14
18
|
const wagmi_1 = require("wagmi");
|
|
15
19
|
var PaymentMethod;
|
|
16
20
|
(function (PaymentMethod) {
|
|
@@ -19,100 +23,43 @@ var PaymentMethod;
|
|
|
19
23
|
PaymentMethod["TRANSFER_CRYPTO"] = "transfer_crypto";
|
|
20
24
|
})(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
|
|
21
25
|
function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
22
|
-
const {
|
|
23
|
-
const wagmiAccount = (0, wagmi_1.useAccount)();
|
|
24
|
-
const { address: globalAddress, connectedEOAWallet, isActiveEOAWallet, wallet: globalWallet } = (0, react_1.useAccountWallet)();
|
|
26
|
+
const { address: globalAddress, wallet: globalWallet } = (0, react_1.useAccountWallet)();
|
|
25
27
|
const { disconnect } = (0, wagmi_1.useDisconnect)();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
sonner_1.toast.error(`Failed to connect wallet: ${connectError.message}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, [connectError, globalAddress, wagmiAccount.address, setSelectedPaymentMethod, onSelectPaymentMethod]);
|
|
70
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("relative flex flex-col gap-10"), children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-around gap-4", children: (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-center", children: (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [!globalAddress ? (
|
|
71
|
-
// Not connected - show single connect button
|
|
72
|
-
(0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
73
|
-
// Prevent connecting if already connecting or if there's already a connection
|
|
74
|
-
if (isConnecting)
|
|
75
|
-
return;
|
|
76
|
-
try {
|
|
77
|
-
// Check if wagmi already has a connection
|
|
78
|
-
if (wagmiAccount.isConnected && wagmiAccount.address) {
|
|
79
|
-
// Already connected via wagmi, just proceed with selection
|
|
80
|
-
console.log("Wagmi already connected, proceeding with selection");
|
|
81
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
82
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// Check if global address exists (b3 account system)
|
|
86
|
-
if (globalAddress) {
|
|
87
|
-
// Already connected via global account, just proceed with selection
|
|
88
|
-
console.log("Global address already exists, proceeding with selection");
|
|
89
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
90
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Use the first available connector or a preferred one
|
|
94
|
-
const preferredConnector = connectors.find(c => c.name.toLowerCase().includes("metamask")) || connectors[0];
|
|
95
|
-
if (preferredConnector) {
|
|
96
|
-
connect({ connector: preferredConnector });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
console.error("Connection error:", error);
|
|
101
|
-
sonner_1.toast.error("Failed to connect wallet. Please try again.");
|
|
102
|
-
}
|
|
103
|
-
}, disabled: isConnecting, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: "Connect your wallet to continue" })] })] }), isConnecting ? ((0, jsx_runtime_1.jsx)("div", { className: "border-as-primary/20 border-t-as-primary h-5 w-5 animate-spin rounded-full border-2" })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" }))] })) : (
|
|
104
|
-
// Connected - show wallet info
|
|
105
|
-
(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-green-600" }) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
106
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
107
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
108
|
-
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
109
|
-
disconnect();
|
|
110
|
-
sonner_1.toast.success("Wallet disconnected");
|
|
111
|
-
if (selectedPaymentMethod === PaymentMethod.CONNECT_WALLET) {
|
|
112
|
-
setSelectedPaymentMethod(PaymentMethod.NONE);
|
|
113
|
-
}
|
|
114
|
-
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
115
|
-
setSelectedPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
116
|
-
onSelectPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
117
|
-
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }) }));
|
|
28
|
+
const [showWalletModal, setShowWalletModal] = (0, react_2.useState)(false);
|
|
29
|
+
// Define available wallets for the modal
|
|
30
|
+
const availableWallets = [
|
|
31
|
+
(0, wallets_1.createWallet)("io.metamask"),
|
|
32
|
+
// createWallet("com.coinbase.wallet"),
|
|
33
|
+
(0, wallets_1.createWallet)("me.rainbow"),
|
|
34
|
+
(0, wallets_1.createWallet)("walletConnect"),
|
|
35
|
+
(0, wallets_1.createWallet)("io.rabby"),
|
|
36
|
+
(0, wallets_1.createWallet)("app.phantom"),
|
|
37
|
+
];
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto h-fit w-[460px] max-w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("relative flex flex-col gap-10"), children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-around gap-4", children: (0, jsx_runtime_1.jsx)("div", { className: "flex-1 text-center", children: (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [!globalAddress ? (
|
|
39
|
+
// Not connected - show single connect button
|
|
40
|
+
(0, jsx_runtime_1.jsxs)("button", { onClick: () => setShowWalletModal(true), className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-blue-600" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start text-left", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: "Choose from multiple wallet options" })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })) : (
|
|
41
|
+
// Connected - show wallet info
|
|
42
|
+
(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-4 w-4 text-green-600" }) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/60 text-sm", children: (0, formatAddress_1.shortenAddress)(globalAddress) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
43
|
+
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
44
|
+
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
45
|
+
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: async () => {
|
|
46
|
+
disconnect();
|
|
47
|
+
sonner_1.toast.success("Wallet disconnected");
|
|
48
|
+
if (selectedPaymentMethod === PaymentMethod.CONNECT_WALLET) {
|
|
49
|
+
setSelectedPaymentMethod(PaymentMethod.NONE);
|
|
50
|
+
}
|
|
51
|
+
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] })] }) })), (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
52
|
+
setSelectedPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
53
|
+
onSelectPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
54
|
+
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start text-left", children: (0, jsx_runtime_1.jsx)("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }), showWalletModal &&
|
|
55
|
+
(0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { className: "pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: (0, jsx_runtime_1.jsxs)("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: "Connect Wallet" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => setShowWalletModal(false), className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-5 w-5" }) })] }), (0, jsx_runtime_1.jsx)(react_3.ConnectEmbed, { client: thirdweb_1.client, chain: b3Chain_1.thirdwebB3Mainnet, wallets: availableWallets, showThirdwebBranding: false, theme: (0, react_3.lightTheme)(), onConnect: async (wallet) => {
|
|
56
|
+
console.log("Wallet connected:", wallet);
|
|
57
|
+
// setShowWalletModal(false);
|
|
58
|
+
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
59
|
+
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
60
|
+
setShowWalletModal(false);
|
|
61
|
+
}, style: {
|
|
62
|
+
width: "100%",
|
|
63
|
+
minHeight: "300px",
|
|
64
|
+
} })] }) }), typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body)] }));
|
|
118
65
|
}
|
|
@@ -79,7 +79,6 @@ function PanelOnrampPaymentInner(props) {
|
|
|
79
79
|
vendor: vendor,
|
|
80
80
|
paymentMethod: paymentMethod || "",
|
|
81
81
|
country: geoData?.country || "US",
|
|
82
|
-
ipAddress: geoData?.ip,
|
|
83
82
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
84
83
|
},
|
|
85
84
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -134,7 +134,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
134
134
|
vendor: "stripe-web2",
|
|
135
135
|
paymentMethod: "",
|
|
136
136
|
country: geoData.country || "US",
|
|
137
|
-
ipAddress: geoData.ip,
|
|
138
137
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
139
138
|
},
|
|
140
139
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -24,10 +24,6 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
24
24
|
mutationFn: async (params) => {
|
|
25
25
|
const { isMainnet, recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
26
26
|
try {
|
|
27
|
-
// Validate Stripe onramp options
|
|
28
|
-
if (onramp.vendor === "stripe" && !onramp.ipAddress) {
|
|
29
|
-
throw new Error("IP address is required for Stripe onramp");
|
|
30
|
-
}
|
|
31
27
|
// Validate required onramp fields
|
|
32
28
|
if (!onramp.vendor || !onramp.country) {
|
|
33
29
|
throw new Error("Missing required onramp fields: vendor, country");
|
|
@@ -16,7 +16,7 @@ function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
|
16
16
|
// Use existing hooks
|
|
17
17
|
const { geoData, loading: isLoadingGeo, error: geoError } = (0, useGetGeo_1.useGetGeo)();
|
|
18
18
|
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(isMainnet, geoData?.country, visitorData);
|
|
19
|
-
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet,
|
|
19
|
+
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet, srcFiatAmount, visitorData);
|
|
20
20
|
// Calculate available payment methods based on the amount
|
|
21
21
|
const coinbaseAvailablePaymentMethods = (0, react_1.useMemo)(() => {
|
|
22
22
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
|
-
export declare function useStripeSupport(isMainnet: boolean,
|
|
2
|
+
export declare function useStripeSupport(isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
3
|
isStripeOnrampSupported: boolean;
|
|
4
4
|
stripeWeb2Support: {
|
|
5
5
|
isSupport: false;
|
|
@@ -4,11 +4,11 @@ exports.useStripeSupport = useStripeSupport;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useStripeSupport(isMainnet,
|
|
7
|
+
function useStripeSupport(isMainnet, usdAmount, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["useStripeSupport", isMainnet,
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet,
|
|
11
|
-
enabled:
|
|
9
|
+
queryKey: ["useStripeSupport", isMainnet, usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, usdAmount, visitorData),
|
|
11
|
+
enabled: !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
14
14
|
isStripeOnrampSupported: data?.stripeOnramp || false,
|
|
@@ -30,7 +30,7 @@ export declare const anyspendService: {
|
|
|
30
30
|
getOrderAndTransactions: (isMainnet: boolean, orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
|
|
31
31
|
getOrderHistory: (isMainnet: boolean, creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
|
|
32
32
|
getCoinbaseOnrampOptions: (isMainnet: boolean, country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
33
|
-
checkStripeSupport: (isMainnet: boolean,
|
|
33
|
+
checkStripeSupport: (isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData) => Promise<{
|
|
34
34
|
stripeOnramp: boolean;
|
|
35
35
|
stripeWeb2: components["schemas"]["StripeWeb2Support"];
|
|
36
36
|
}>;
|
|
@@ -96,9 +96,8 @@ exports.anyspendService = {
|
|
|
96
96
|
const data = await response.json();
|
|
97
97
|
return data;
|
|
98
98
|
},
|
|
99
|
-
checkStripeSupport: async (isMainnet,
|
|
99
|
+
checkStripeSupport: async (isMainnet, usdAmount, visitorData) => {
|
|
100
100
|
const params = new URLSearchParams({
|
|
101
|
-
ipAddress,
|
|
102
101
|
usdAmount: usdAmount || "",
|
|
103
102
|
});
|
|
104
103
|
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
@@ -238,12 +238,7 @@ export interface paths {
|
|
|
238
238
|
*/
|
|
239
239
|
get: {
|
|
240
240
|
parameters: {
|
|
241
|
-
query
|
|
242
|
-
/**
|
|
243
|
-
* @description IP address to check location-based support
|
|
244
|
-
* @example 192.168.1.1
|
|
245
|
-
*/
|
|
246
|
-
ipAddress: string;
|
|
241
|
+
query?: {
|
|
247
242
|
/**
|
|
248
243
|
* @description Optional USD amount for transaction limit checks
|
|
249
244
|
* @example 100.00
|
|
@@ -903,11 +898,6 @@ export interface components {
|
|
|
903
898
|
* @example
|
|
904
899
|
*/
|
|
905
900
|
paymentMethod?: string;
|
|
906
|
-
/**
|
|
907
|
-
* @description User's IP address
|
|
908
|
-
* @example 96.225.86.216
|
|
909
|
-
*/
|
|
910
|
-
ipAddress?: string;
|
|
911
901
|
/**
|
|
912
902
|
* @description Redirect URL after payment
|
|
913
903
|
* @example https://www.anyspend.com
|
|
@@ -936,11 +926,6 @@ export interface components {
|
|
|
936
926
|
* @example SG
|
|
937
927
|
*/
|
|
938
928
|
country?: string;
|
|
939
|
-
/**
|
|
940
|
-
* @description User's IP address
|
|
941
|
-
* @example 149.88.23.87
|
|
942
|
-
*/
|
|
943
|
-
ipAddress?: string;
|
|
944
929
|
/**
|
|
945
930
|
* @description URL to redirect after payment
|
|
946
931
|
* @example https://www.anyspend.com
|
|
@@ -9,7 +9,7 @@ const Loading_1 = require("../ui/Loading");
|
|
|
9
9
|
function SignInWithB3(props) {
|
|
10
10
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = (0, react_1.useModalStore)();
|
|
11
11
|
const { account } = (0, react_1.useB3)();
|
|
12
|
-
const { isAuthenticating,
|
|
12
|
+
const { isAuthenticating, isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
|
|
13
13
|
const isMobile = (0, react_1.useIsMobile)();
|
|
14
14
|
(0, react_2.useEffect)(() => {
|
|
15
15
|
if (account) {
|
|
@@ -24,7 +24,7 @@ function SignInWithB3(props) {
|
|
|
24
24
|
});
|
|
25
25
|
setB3ModalOpen(true);
|
|
26
26
|
};
|
|
27
|
-
if (
|
|
27
|
+
if (isConnected) {
|
|
28
28
|
return (0, jsx_runtime_1.jsx)(ManageAccountButton_1.ManageAccountButton, { ...props });
|
|
29
29
|
}
|
|
30
30
|
if (isAuthenticating) {
|
|
@@ -19,9 +19,12 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
19
19
|
const { setUser, automaticallySetFirstEoa } = (0, react_1.useB3)();
|
|
20
20
|
const [step, setStep] = (0, react_2.useState)(source === "requestPermissions" ? null : "login");
|
|
21
21
|
const [sessionKeyAdded, setSessionKeyAdded] = (0, react_2.useState)(source === "requestPermissions" ? true : false);
|
|
22
|
-
const { setB3ModalContentType, setB3ModalOpen } = (0, react_1.useModalStore)();
|
|
22
|
+
const { setB3ModalContentType, setB3ModalOpen, isOpen } = (0, react_1.useModalStore)();
|
|
23
23
|
const account = (0, react_3.useActiveAccount)();
|
|
24
|
-
const
|
|
24
|
+
const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
25
|
+
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
26
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
27
|
+
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
25
28
|
const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
|
|
26
29
|
const [refetchError, setRefetchError] = (0, react_2.useState)(null);
|
|
27
30
|
const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = (0, react_1.useGetAllTWSigners)({
|
|
@@ -32,7 +35,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
32
35
|
},
|
|
33
36
|
});
|
|
34
37
|
const { authenticate } = (0, react_1.useSiwe)();
|
|
35
|
-
const [authenticatingWithB3, setAuthenticatingWithB3] = (0, react_2.useState)(false);
|
|
36
38
|
const [refetchQueued, setRefetchQueued] = (0, react_2.useState)(false);
|
|
37
39
|
// Enhanced refetchSigners function that tracks number of attempts
|
|
38
40
|
const handleRefetchSigners = (0, react_2.useCallback)(() => {
|
|
@@ -58,11 +60,14 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
58
60
|
// Handle post-login flow after signers are loaded
|
|
59
61
|
(0, react_2.useEffect)(() => {
|
|
60
62
|
debug("@@SignInWithB3Flow:useEffect", {
|
|
61
|
-
|
|
63
|
+
isConnected,
|
|
64
|
+
isAuthenticating,
|
|
62
65
|
isFetchingSigners,
|
|
66
|
+
closeAfterLogin,
|
|
67
|
+
isOpen,
|
|
63
68
|
source,
|
|
64
69
|
});
|
|
65
|
-
if (
|
|
70
|
+
if (isConnected) {
|
|
66
71
|
// Check if we already have a signer for this partner
|
|
67
72
|
const hasExistingSigner = signers?.some(signer => signer.partner.id === partnerId);
|
|
68
73
|
if (hasExistingSigner) {
|
|
@@ -102,7 +107,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
102
107
|
signers,
|
|
103
108
|
isFetchingSigners,
|
|
104
109
|
partnerId,
|
|
105
|
-
loginComplete,
|
|
106
110
|
handleRefetchSigners,
|
|
107
111
|
source,
|
|
108
112
|
closeAfterLogin,
|
|
@@ -111,6 +115,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
111
115
|
onSessionKeySuccess,
|
|
112
116
|
setB3ModalOpen,
|
|
113
117
|
signersEnabled,
|
|
118
|
+
isConnected,
|
|
119
|
+
isAuthenticating,
|
|
120
|
+
isOpen,
|
|
114
121
|
]);
|
|
115
122
|
debug("render", {
|
|
116
123
|
step,
|
|
@@ -155,16 +162,16 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
155
162
|
]);
|
|
156
163
|
const handleLoginSuccess = (0, react_2.useCallback)(async (account) => {
|
|
157
164
|
debug("Authenticating with B3 via SIWE");
|
|
165
|
+
setIsConnected(true);
|
|
158
166
|
if (loginWithSiwe) {
|
|
159
|
-
|
|
167
|
+
setIsAuthenticating(true);
|
|
160
168
|
const userAuth = await authenticate(account, partnerId);
|
|
161
169
|
setUser(userAuth.user);
|
|
162
170
|
}
|
|
163
171
|
debug("handleLoginSuccess:account", account);
|
|
164
172
|
onLoginSuccess?.(account);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}, [authenticate, loginWithSiwe, onLoginSuccess, setUser, partnerId]);
|
|
173
|
+
setIsAuthenticating(false);
|
|
174
|
+
}, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
|
|
168
175
|
(0, react_2.useEffect)(() => {
|
|
169
176
|
if (step === "permissions") {
|
|
170
177
|
setB3ModalContentType({
|
|
@@ -180,7 +187,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
180
187
|
if (refetchError) {
|
|
181
188
|
return ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
182
189
|
}
|
|
183
|
-
if (
|
|
190
|
+
if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
184
191
|
return ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "mt-8 flex items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
|
|
185
192
|
}
|
|
186
193
|
if (step === "login") {
|
|
@@ -6,7 +6,7 @@ const react_1 = require("../../../../global-account/react");
|
|
|
6
6
|
const utils_1 = require("../../../../shared/utils");
|
|
7
7
|
function ManageAccountButton(props) {
|
|
8
8
|
const { setB3ModalOpen, setB3ModalContentType } = (0, react_1.useModalStore)();
|
|
9
|
-
const {
|
|
9
|
+
const { isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
|
|
10
10
|
const handleClickManageAccount = () => {
|
|
11
11
|
setB3ModalContentType({
|
|
12
12
|
...props,
|
|
@@ -14,7 +14,7 @@ function ManageAccountButton(props) {
|
|
|
14
14
|
});
|
|
15
15
|
setB3ModalOpen(true);
|
|
16
16
|
};
|
|
17
|
-
if (!
|
|
17
|
+
if (!isConnected)
|
|
18
18
|
return null;
|
|
19
19
|
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)(react_1.Button, { onClick: handleClickManageAccount, style: { backgroundColor: "#3368ef" }, className: (0, utils_1.cn)("b3-manage-account-button flex items-center gap-2 text-white", props.className), children: [props.withLogo !== false && ((0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo_white.svg", alt: "B3 Logo", className: "h-5 w-5" })), props.loggedInButtonText || "Manage Account"] }) }));
|
|
20
20
|
}
|
|
@@ -18,7 +18,7 @@ export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
|
18
18
|
export { useMediaQuery } from "./useMediaQuery";
|
|
19
19
|
export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
|
|
20
20
|
export { useOneBalance } from "./useOneBalance";
|
|
21
|
-
export { useProfile, useProfilePreference, type
|
|
21
|
+
export { useProfile, useProfilePreference, type CombinedProfile, type PreferenceRequestBody, type Profile, } from "./useProfile";
|
|
22
22
|
export { useQueryB3 } from "./useQueryB3";
|
|
23
23
|
export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
24
24
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
@@ -4,6 +4,8 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
|
|
|
4
4
|
isAuthenticating: boolean;
|
|
5
5
|
isAuthenticated: boolean;
|
|
6
6
|
isReady: boolean;
|
|
7
|
+
isConnecting: boolean;
|
|
8
|
+
isConnected: boolean;
|
|
7
9
|
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
8
10
|
preAuthenticate: typeof preAuthenticate;
|
|
9
11
|
connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|