@b3dotfun/sdk 0.0.14-alpha.2 → 0.0.14-alpha.3
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 +38 -38
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +18 -18
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +22 -22
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +22 -22
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +7 -7
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +21 -21
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -24
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -4
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +6 -6
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +12 -12
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +1 -1
- package/dist/cjs/global-account/react/components/custom/StaggeredFadeLoader.js +2 -2
- package/dist/cjs/global-account/react/components/magicui/AnimatedLottie.js +12 -12
- package/dist/cjs/global-account/react/components/ui/TabSystem.js +11 -11
- package/dist/cjs/global-account/react/components/ui/text-loop.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/text-loop.js +6 -6
- package/dist/cjs/global-account/react/components/ui/text-shimmer.js +4 -4
- package/dist/cjs/global-account/react/components/ui/transition-panel.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/transition-panel.js +2 -2
- package/dist/cjs/global-account/react/hooks/useChainSwitchWithAction.js +6 -6
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -1
- package/dist/esm/global-account/react/components/ProfileAvatar.js +1 -1
- package/dist/esm/global-account/react/components/custom/StaggeredFadeLoader.js +1 -1
- package/dist/esm/global-account/react/components/magicui/AnimatedLottie.js +1 -1
- package/dist/esm/global-account/react/components/ui/TabSystem.js +1 -1
- package/dist/esm/global-account/react/components/ui/text-loop.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/text-loop.js +1 -1
- package/dist/esm/global-account/react/components/ui/text-shimmer.js +1 -1
- package/dist/esm/global-account/react/components/ui/transition-panel.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/transition-panel.js +1 -1
- package/dist/esm/global-account/react/hooks/useChainSwitchWithAction.js +1 -1
- package/dist/types/global-account/react/components/ui/text-loop.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/transition-panel.d.ts +1 -1
- package/package.json +3 -4
- package/src/anyspend/react/components/AnySpend.tsx +1 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +1 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnySpendNFT.tsx +1 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +1 -1
- package/src/anyspend/react/components/AnySpendTournament.tsx +3 -3
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -1
- package/src/global-account/react/components/ProfileAvatar.tsx +1 -1
- package/src/global-account/react/components/custom/StaggeredFadeLoader.tsx +1 -1
- package/src/global-account/react/components/magicui/AnimatedLottie.tsx +1 -1
- package/src/global-account/react/components/ui/TabSystem.tsx +1 -1
- package/src/global-account/react/components/ui/text-loop.tsx +1 -1
- package/src/global-account/react/components/ui/text-shimmer.tsx +1 -1
- package/src/global-account/react/components/ui/transition-panel.tsx +1 -1
- package/src/global-account/react/hooks/useChainSwitchWithAction.ts +1 -1
|
@@ -13,10 +13,10 @@ const utils_1 = require("../../../shared/utils");
|
|
|
13
13
|
const centerTruncate_1 = __importDefault(require("../../../shared/utils/centerTruncate"));
|
|
14
14
|
const number_1 = require("../../../shared/utils/number");
|
|
15
15
|
const simplehash_1 = require("../../../shared/utils/simplehash");
|
|
16
|
-
const framer_motion_1 = require("framer-motion");
|
|
17
16
|
const invariant_1 = __importDefault(require("invariant"));
|
|
18
17
|
const lucide_react_1 = require("lucide-react");
|
|
19
|
-
const react_3 = require("react");
|
|
18
|
+
const react_3 = require("motion/react");
|
|
19
|
+
const react_4 = require("react");
|
|
20
20
|
const sonner_1 = require("sonner");
|
|
21
21
|
const chains_1 = require("viem/chains");
|
|
22
22
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
@@ -92,23 +92,23 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
92
92
|
const hasMounted = (0, react_2.useHasMounted)();
|
|
93
93
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
94
94
|
const router = (0, react_2.useRouter)();
|
|
95
|
-
const [activePanel, setActivePanel] = (0,
|
|
96
|
-
const [activeTab, setActiveTab] = (0,
|
|
95
|
+
const [activePanel, setActivePanel] = (0, react_4.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
96
|
+
const [activeTab, setActiveTab] = (0, react_4.useState)("crypto");
|
|
97
97
|
// Get current user's wallet
|
|
98
98
|
const currentWallet = (0, react_2.useAccountWallet)();
|
|
99
99
|
// Add state for recipient modal
|
|
100
|
-
const [isRecipientModalOpen, setIsRecipientModalOpen] = (0,
|
|
100
|
+
const [isRecipientModalOpen, setIsRecipientModalOpen] = (0, react_4.useState)(false);
|
|
101
101
|
// Add state for custom recipient
|
|
102
|
-
const [customRecipientAddress, setCustomRecipientAddress] = (0,
|
|
102
|
+
const [customRecipientAddress, setCustomRecipientAddress] = (0, react_4.useState)(recipientAddressProps);
|
|
103
103
|
// Update recipient logic to use custom recipient
|
|
104
104
|
const recipientAddress = customRecipientAddress || currentWallet.address;
|
|
105
105
|
const recipientPropsProfile = (0, react_2.useProfile)({ address: recipientAddress });
|
|
106
106
|
const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
107
107
|
const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
|
|
108
|
-
const [orderId, setOrderId] = (0,
|
|
109
|
-
const [srcChainId, setSrcChainId] = (0,
|
|
108
|
+
const [orderId, setOrderId] = (0, react_4.useState)(loadOrder);
|
|
109
|
+
const [srcChainId, setSrcChainId] = (0, react_4.useState)(isMainnet ? chains_1.base.id : chains_1.baseSepolia.id);
|
|
110
110
|
// Get token list for token balance check
|
|
111
|
-
const chainName = (0,
|
|
111
|
+
const chainName = (0, react_4.useMemo)(() => (0, simplehash_1.simpleHashChainToChainName)(srcChainId), [srcChainId]);
|
|
112
112
|
const { data: tokenList } = (0, react_1.useAnyspendTokenList)(isMainnet, srcChainId, "");
|
|
113
113
|
// Get token balances for the selected chain
|
|
114
114
|
const { nativeTokens, fungibleTokens } = (0, react_2.useTokenBalancesByChain)({
|
|
@@ -117,7 +117,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
117
117
|
enabled: !!currentWallet?.wallet?.address && !!chainName,
|
|
118
118
|
});
|
|
119
119
|
// Find a token with a balance, prioritizing tokens the user already owns
|
|
120
|
-
const getTokenWithBalance = (0,
|
|
120
|
+
const getTokenWithBalance = (0, react_4.useCallback)(() => {
|
|
121
121
|
if (!currentWallet?.wallet?.address || (!nativeTokens && !fungibleTokens) || !tokenList) {
|
|
122
122
|
return (0, anyspend_1.getDefaultToken)(srcChainId);
|
|
123
123
|
}
|
|
@@ -147,10 +147,10 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
147
147
|
return (0, anyspend_1.getDefaultToken)(srcChainId);
|
|
148
148
|
}, [currentWallet?.wallet?.address, nativeTokens, fungibleTokens, tokenList, srcChainId]);
|
|
149
149
|
// Set the selected token with preference for tokens user owns
|
|
150
|
-
const [srcToken, setSrcToken] = (0,
|
|
151
|
-
const [dirtySelectSrcToken, setDirtySelectSrcToken] = (0,
|
|
150
|
+
const [srcToken, setSrcToken] = (0, react_4.useState)((0, anyspend_1.getDefaultToken)(srcChainId));
|
|
151
|
+
const [dirtySelectSrcToken, setDirtySelectSrcToken] = (0, react_4.useState)(false);
|
|
152
152
|
// Update token when chain changes or token balances are loaded
|
|
153
|
-
(0,
|
|
153
|
+
(0, react_4.useEffect)(() => {
|
|
154
154
|
if (tokenList?.length && !dirtySelectSrcToken) {
|
|
155
155
|
const tokenWithBalance = getTokenWithBalance();
|
|
156
156
|
if ((0, anyspend_1.eqci)(tokenWithBalance.address, dstToken.address) === false) {
|
|
@@ -159,7 +159,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
159
159
|
}
|
|
160
160
|
}, [srcChainId, tokenList, getTokenWithBalance, nativeTokens, fungibleTokens, dirtySelectSrcToken, dstToken.address]);
|
|
161
161
|
// const { account: isAuthenticated } = useB3();
|
|
162
|
-
const getRelayQuoteRequest = (0,
|
|
162
|
+
const getRelayQuoteRequest = (0, react_4.useMemo)(() => {
|
|
163
163
|
return generateGetRelayQuoteRequest({
|
|
164
164
|
orderType: orderType,
|
|
165
165
|
srcChainId: srcChainId,
|
|
@@ -197,11 +197,11 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
197
197
|
params.set("orderId", selectedOrderId);
|
|
198
198
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
199
199
|
};
|
|
200
|
-
const [srcAmount, setSrcAmount] = (0,
|
|
200
|
+
const [srcAmount, setSrcAmount] = (0, react_4.useState)(null);
|
|
201
201
|
const formattedSrcAmount = srcAmount ? (0, number_1.formatTokenAmount)(srcAmount, srcToken.decimals, 6, false) : null;
|
|
202
202
|
// Update the selected src token to USDC and chain to base when the active tab is fiat,
|
|
203
203
|
// also force not to update srcToken by setting dirtySelectSrcToken to true.
|
|
204
|
-
(0,
|
|
204
|
+
(0, react_4.useEffect)(() => {
|
|
205
205
|
if (activeTab === "fiat") {
|
|
206
206
|
setSrcChainId(chains_1.base.id);
|
|
207
207
|
setSrcToken(constants_1.USDC_BASE);
|
|
@@ -209,7 +209,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
209
209
|
}
|
|
210
210
|
}, [activeTab]);
|
|
211
211
|
// Update dependent amount when relay price changes
|
|
212
|
-
(0,
|
|
212
|
+
(0, react_4.useEffect)(() => {
|
|
213
213
|
if (anyspendQuote?.data &&
|
|
214
214
|
anyspendQuote.data.currencyIn?.amount &&
|
|
215
215
|
anyspendQuote.data.currencyIn?.currency?.decimals) {
|
|
@@ -221,7 +221,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
221
221
|
setSrcAmount(null);
|
|
222
222
|
}
|
|
223
223
|
}, [anyspendQuote?.data]);
|
|
224
|
-
(0,
|
|
224
|
+
(0, react_4.useEffect)(() => {
|
|
225
225
|
if (oat?.data?.order.status === "executed") {
|
|
226
226
|
console.log("Calling onSuccess");
|
|
227
227
|
const txHash = oat?.data?.executeTx?.txHash;
|
|
@@ -355,7 +355,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
|
-
const recipientSection = showRecipient ? ((0, jsx_runtime_1.jsxs)(
|
|
358
|
+
const recipientSection = showRecipient ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: false, animate: {
|
|
359
359
|
opacity: hasMounted ? 1 : 0,
|
|
360
360
|
y: hasMounted ? 0 : 20,
|
|
361
361
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -379,18 +379,18 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
379
379
|
} })] })), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }));
|
|
380
380
|
const loadingView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [(0, jsx_runtime_1.jsxs)(react_2.Badge, { variant: "default", className: "bg-b3-react-muted/30 border-b3-react-border hover:bg-b3-react-muted/50 flex items-center gap-3 px-4 py-1 text-base transition-all", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-react-foreground size-4 animate-spin" }), (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-8 w-48" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "ml-4 h-8 w-32" })] }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mt-4 h-8 w-24" })] }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mb-4 h-12 w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)(react_2.Skeleton, { className: "rounded-lg bg-white/5 p-6 pb-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "size-[200px]" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-3 flex items-center justify-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "size-5 rounded-full" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => ((0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 w-full" }, i))) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-muted/30 mt-8 w-full rounded-lg p-4", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "mb-3 h-4 w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 flex-1" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 flex-1" })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col gap-3", children: [1, 2, 3, 4, 5].map(i => ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between", children: [(0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-4 w-32" })] }, i))) }), (0, jsx_runtime_1.jsx)(react_2.Skeleton, { className: "h-10 w-full" }), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }));
|
|
381
381
|
// Confirm order view.
|
|
382
|
-
const confirmOrderView = ((0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(react_2.Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5", children: [(0, jsx_runtime_1.jsxs)(react_2.TabsList, { hideGradient: true, className: "justify-center", children: [(0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "crypto", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with crypto" }) }), isOnrampSupported ? ((0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "fiat", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with fiat" }) })) : ((0, jsx_runtime_1.jsxs)(react_2.Tooltip, { children: [(0, jsx_runtime_1.jsx)(react_2.TooltipTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "fiat", disabled: true, children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with fiat" }) }) }), (0, jsx_runtime_1.jsx)(react_2.TooltipContent, { children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Fiat payments are not supported for this amount" }) })] }))] }), (0, jsx_runtime_1.jsx)(react_2.TabsContent, { value: "crypto", children: (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)(
|
|
382
|
+
const confirmOrderView = ((0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(react_2.Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5", children: [(0, jsx_runtime_1.jsxs)(react_2.TabsList, { hideGradient: true, className: "justify-center", children: [(0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "crypto", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with crypto" }) }), isOnrampSupported ? ((0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "fiat", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with fiat" }) })) : ((0, jsx_runtime_1.jsxs)(react_2.Tooltip, { children: [(0, jsx_runtime_1.jsx)(react_2.TooltipTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)(react_2.TabTrigger, { value: "fiat", disabled: true, children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with fiat" }) }) }), (0, jsx_runtime_1.jsx)(react_2.TooltipContent, { children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Fiat payments are not supported for this amount" }) })] }))] }), (0, jsx_runtime_1.jsx)(react_2.TabsContent, { value: "crypto", children: (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: false, animate: {
|
|
383
383
|
opacity: hasMounted ? 1 : 0,
|
|
384
384
|
y: hasMounted ? 0 : 20,
|
|
385
385
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
386
386
|
}, 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: "font-medium", children: "Pay with" }), (0, jsx_runtime_1.jsx)(OrderToken_1.OrderToken, { address: currentWallet?.wallet?.address, context: "from", chainId: srcChainId, setChainId: setSrcChainId, token: srcToken, setToken: token => {
|
|
387
387
|
setDirtySelectSrcToken(true);
|
|
388
388
|
setSrcToken(token);
|
|
389
|
-
}, requiredAmount: srcAmount || undefined })] }), (0, jsx_runtime_1.jsxs)(
|
|
389
|
+
}, requiredAmount: srcAmount || undefined })] }), (0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: false, animate: {
|
|
390
390
|
opacity: hasMounted ? 1 : 0,
|
|
391
391
|
y: hasMounted ? 0 : 20,
|
|
392
392
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
393
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-medium", children: ["Total ", (0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500", children: "(with fee)" })] }), (0, jsx_runtime_1.jsxs)("h2", { className: (0, utils_1.cn)("text-as-primary text-2xl font-semibold"), children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("flex w-full flex-col items-center justify-between gap-2"), children: (0, jsx_runtime_1.jsx)(
|
|
393
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-medium", children: ["Total ", (0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500", children: "(with fee)" })] }), (0, jsx_runtime_1.jsxs)("h2", { className: (0, utils_1.cn)("text-as-primary text-2xl font-semibold"), children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("flex w-full flex-col items-center justify-between gap-2"), children: (0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: false, animate: {
|
|
394
394
|
opacity: hasMounted ? 1 : 0,
|
|
395
395
|
y: hasMounted ? 0 : 20,
|
|
396
396
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -7,9 +7,9 @@ const react_1 = require("../../../global-account/react");
|
|
|
7
7
|
const utils_1 = require("../../../shared/utils");
|
|
8
8
|
const ipfs_1 = require("../../../shared/utils/ipfs");
|
|
9
9
|
const number_1 = require("../../../shared/utils/number");
|
|
10
|
-
const framer_motion_1 = require("framer-motion");
|
|
11
10
|
const lucide_react_1 = require("lucide-react");
|
|
12
|
-
const react_2 = require("react");
|
|
11
|
+
const react_2 = require("motion/react");
|
|
12
|
+
const react_3 = require("react");
|
|
13
13
|
const chains_1 = require("viem/chains");
|
|
14
14
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
15
15
|
// ABI for contractURI and uri functions
|
|
@@ -30,10 +30,10 @@ const CONTRACT_URI_ABI = [
|
|
|
30
30
|
},
|
|
31
31
|
];
|
|
32
32
|
function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, }) {
|
|
33
|
-
const [imageUrlWithFallback, setFallbackImageUrl] = (0,
|
|
34
|
-
const [isLoadingFallback, setIsLoadingFallback] = (0,
|
|
33
|
+
const [imageUrlWithFallback, setFallbackImageUrl] = (0, react_3.useState)(nftContract.imageUrl);
|
|
34
|
+
const [isLoadingFallback, setIsLoadingFallback] = (0, react_3.useState)(false);
|
|
35
35
|
// Fetch contract metadata when imageUrl is empty
|
|
36
|
-
(0,
|
|
36
|
+
(0, react_3.useEffect)(() => {
|
|
37
37
|
async function fetchContractMetadata() {
|
|
38
38
|
// fetch image Uri if not provided
|
|
39
39
|
if (nftContract.imageUrl || isLoadingFallback) {
|
|
@@ -83,7 +83,7 @@ function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAdd
|
|
|
83
83
|
}
|
|
84
84
|
fetchContractMetadata();
|
|
85
85
|
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
86
|
-
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && ((0, jsx_runtime_1.jsx)("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(
|
|
86
|
+
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && ((0, jsx_runtime_1.jsx)("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(react_2.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
87
87
|
"opacity-0": isLoadingAnyspendPrice,
|
|
88
88
|
}), children: (0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
89
89
|
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
@@ -92,7 +92,7 @@ function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAdd
|
|
|
92
92
|
}, header: header, onSuccess: onSuccess }));
|
|
93
93
|
}
|
|
94
94
|
function DropdownMenu({ nftContract }) {
|
|
95
|
-
const [open, setOpen] = (0,
|
|
95
|
+
const [open, setOpen] = (0, react_3.useState)(false);
|
|
96
96
|
const chain = anyspend_1.ALL_CHAINS[nftContract.chainId];
|
|
97
97
|
const nftUrl = (0, anyspend_1.getExplorerAddressUrl)(nftContract.chainId, nftContract.contractAddress);
|
|
98
98
|
return ((0, jsx_runtime_1.jsxs)(react_1.Popover, { open: open, onOpenChange: setOpen, children: [(0, jsx_runtime_1.jsx)(react_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { className: "absolute bottom-3 right-3 z-10 flex items-center justify-center rounded-full bg-black/20 p-1 text-white hover:bg-black/30", "aria-label": "Open NFT menu", children: (0, jsx_runtime_1.jsx)(lucide_react_1.MoreVertical, { className: "h-3 w-3" }) }) }), (0, jsx_runtime_1.jsx)(react_1.PopoverContent, { align: "end", className: "bg-b3-react-background border-b3-react-border min-w-48 rounded-lg border p-0 shadow-md backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "pointer-events-auto flex w-full flex-col gap-2 py-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2 text-sm", children: ["Native mint price:", (0, jsx_runtime_1.jsxs)("span", { className: "font-semibold", children: [(0, number_1.formatTokenAmount)(BigInt(nftContract.price), nftContract.currency.decimals, 6, false), " ", nftContract.currency.symbol] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2", children: [(0, jsx_runtime_1.jsx)("img", { src: chain?.logoUrl, className: (0, utils_1.cn)("h-5 w-5", nftContract.chainId !== chains_1.b3.id && "rounded-full") }), (0, jsx_runtime_1.jsxs)("span", { className: "text-sm", children: ["Minted on ", (0, jsx_runtime_1.jsx)("span", { className: "font-semibold", children: chain ? (0, anyspend_1.getChainName)(nftContract.chainId) : "Unknown" })] })] }), (0, jsx_runtime_1.jsx)("a", { href: nftUrl, target: "_blank", rel: "noopener noreferrer", className: "hover:bg-as-on-surface-3 text-as-primary flex items-center gap-2 rounded px-2 text-sm", children: "View NFT onchain" })] }) })] }));
|
|
@@ -8,10 +8,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const anyspend_1 = require("../../../anyspend");
|
|
9
9
|
const react_1 = require("../../../global-account/react");
|
|
10
10
|
const number_1 = require("../../../shared/utils/number");
|
|
11
|
-
const framer_motion_1 = require("framer-motion");
|
|
12
11
|
const invariant_1 = __importDefault(require("invariant"));
|
|
13
12
|
const lucide_react_1 = require("lucide-react");
|
|
14
|
-
const react_2 = require("react");
|
|
13
|
+
const react_2 = require("motion/react");
|
|
14
|
+
const react_3 = require("react");
|
|
15
15
|
const sonner_1 = require("sonner");
|
|
16
16
|
const viem_1 = require("viem");
|
|
17
17
|
const chains_1 = require("viem/chains");
|
|
@@ -46,9 +46,9 @@ function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", recipien
|
|
|
46
46
|
const { writeContractAsync } = (0, wagmi_1.useWriteContract)();
|
|
47
47
|
const { switchChainAndExecute } = (0, react_1.useChainSwitchWithAction)();
|
|
48
48
|
// State for direct staking flow
|
|
49
|
-
const [isStaking, setIsStaking] = (0,
|
|
50
|
-
const [stakingTxHash, setStakingTxHash] = (0,
|
|
51
|
-
const [showSuccessModal, setShowSuccessModal] = (0,
|
|
49
|
+
const [isStaking, setIsStaking] = (0, react_3.useState)(false);
|
|
50
|
+
const [stakingTxHash, setStakingTxHash] = (0, react_3.useState)("");
|
|
51
|
+
const [showSuccessModal, setShowSuccessModal] = (0, react_3.useState)(false);
|
|
52
52
|
// Wait for transaction confirmation
|
|
53
53
|
const { isLoading: isTxPending, isSuccess: isTxSuccess } = (0, wagmi_1.useWaitForTransactionReceipt)({
|
|
54
54
|
hash: stakingTxHash,
|
|
@@ -57,31 +57,31 @@ function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", recipien
|
|
|
57
57
|
},
|
|
58
58
|
});
|
|
59
59
|
// Show success modal when transaction is confirmed
|
|
60
|
-
(0,
|
|
60
|
+
(0, react_3.useEffect)(() => {
|
|
61
61
|
if (isTxSuccess && stakingTxHash) {
|
|
62
62
|
setShowAmountPrompt(false);
|
|
63
63
|
setShowSuccessModal(true);
|
|
64
64
|
setIsStaking(false);
|
|
65
65
|
}
|
|
66
66
|
}, [isTxSuccess, stakingTxHash]);
|
|
67
|
-
const [userStakeAmount, setUserStakeAmount] = (0,
|
|
68
|
-
const [showAmountPrompt, setShowAmountPrompt] = (0,
|
|
69
|
-
const [isAmountValid, setIsAmountValid] = (0,
|
|
70
|
-
const [validationError, setValidationError] = (0,
|
|
67
|
+
const [userStakeAmount, setUserStakeAmount] = (0, react_3.useState)(stakeAmount || "");
|
|
68
|
+
const [showAmountPrompt, setShowAmountPrompt] = (0, react_3.useState)(!stakeAmount);
|
|
69
|
+
const [isAmountValid, setIsAmountValid] = (0, react_3.useState)(!!stakeAmount);
|
|
70
|
+
const [validationError, setValidationError] = (0, react_3.useState)("");
|
|
71
71
|
// Store display amount for UI
|
|
72
|
-
const [displayAmount, setDisplayAmount] = (0,
|
|
72
|
+
const [displayAmount, setDisplayAmount] = (0, react_3.useState)("");
|
|
73
73
|
// Debounced state for balance checks and messaging
|
|
74
|
-
const [debouncedAmount, setDebouncedAmount] = (0,
|
|
75
|
-
const [debouncedUserStakeAmount, setDebouncedUserStakeAmount] = (0,
|
|
74
|
+
const [debouncedAmount, setDebouncedAmount] = (0, react_3.useState)("");
|
|
75
|
+
const [debouncedUserStakeAmount, setDebouncedUserStakeAmount] = (0, react_3.useState)("");
|
|
76
76
|
// Debounce the amount for balance checks
|
|
77
|
-
(0,
|
|
77
|
+
(0, react_3.useEffect)(() => {
|
|
78
78
|
const timer = setTimeout(() => {
|
|
79
79
|
setDebouncedAmount(displayAmount);
|
|
80
80
|
setDebouncedUserStakeAmount(userStakeAmount);
|
|
81
81
|
}, 500);
|
|
82
82
|
return () => clearTimeout(timer);
|
|
83
83
|
}, [displayAmount, userStakeAmount]);
|
|
84
|
-
(0,
|
|
84
|
+
(0, react_3.useEffect)(() => {
|
|
85
85
|
if (stakeAmount) {
|
|
86
86
|
setUserStakeAmount(stakeAmount);
|
|
87
87
|
setShowAmountPrompt(false);
|
|
@@ -211,18 +211,18 @@ function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", recipien
|
|
|
211
211
|
};
|
|
212
212
|
// Render amount input prompt if no stake amount is provided
|
|
213
213
|
if (showAmountPrompt) {
|
|
214
|
-
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full px-4", children: [(0, jsx_runtime_1.jsx)(
|
|
214
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full px-4", children: [(0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: false, animate: {
|
|
215
215
|
opacity: hasMounted ? 1 : 0,
|
|
216
216
|
y: hasMounted ? 0 : 20,
|
|
217
217
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
218
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative mx-auto size-48", children: (0, jsx_runtime_1.jsx)("video", { autoPlay: true, muted: true, playsInline: true, className: "size-full", src: "https://cdn.b3.fun/b3-sphere-to-coin.mp4" }) }), (0, jsx_runtime_1.jsx)(
|
|
218
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative mx-auto size-48", children: (0, jsx_runtime_1.jsx)("video", { autoPlay: true, muted: true, playsInline: true, className: "size-full", src: "https://cdn.b3.fun/b3-sphere-to-coin.mp4" }) }), (0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: false, animate: {
|
|
219
219
|
opacity: hasMounted ? 1 : 0,
|
|
220
220
|
y: hasMounted ? 0 : 20,
|
|
221
221
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
222
222
|
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)("h2", { className: "font-sf-rounded font-neue-montreal-medium mb-1 text-center text-2xl font-semibold", children: (() => {
|
|
223
223
|
const hasEnoughBalance = b3RawBalance && BigInt(debouncedUserStakeAmount || "0") <= b3RawBalance;
|
|
224
224
|
return hasEnoughBalance || !debouncedAmount ? "Stake B3" : "Swap & Stake B3";
|
|
225
|
-
})() }) })] }), (0, jsx_runtime_1.jsxs)(
|
|
225
|
+
})() }) })] }), (0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: false, animate: {
|
|
226
226
|
opacity: hasMounted ? 1 : 0,
|
|
227
227
|
y: hasMounted ? 0 : 20,
|
|
228
228
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -237,15 +237,15 @@ function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", recipien
|
|
|
237
237
|
}
|
|
238
238
|
// Success Modal for Direct Staking
|
|
239
239
|
if (showSuccessModal) {
|
|
240
|
-
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full p-4", children: [(0, jsx_runtime_1.jsxs)(
|
|
240
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full p-4", children: [(0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: false, animate: {
|
|
241
241
|
opacity: hasMounted ? 1 : 0,
|
|
242
242
|
y: hasMounted ? 0 : 20,
|
|
243
243
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
244
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative mx-auto mb-4 size-[120px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCardRounded, { className: "overflow-hidden rounded-full border-none", children: [(0, jsx_runtime_1.jsx)("img", { alt: "b3 coin", loading: "lazy", width: "64", height: "64", decoding: "async", "data-nimg": "1", className: "size-full shrink-0 bg-transparent text-transparent", src: "https://cdn.b3.fun/b3-coin-3d.png" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-[50%] border border-white/10" })] })] }), (0, jsx_runtime_1.jsx)(
|
|
244
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative mx-auto mb-4 size-[120px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCardRounded, { className: "overflow-hidden rounded-full border-none", children: [(0, jsx_runtime_1.jsx)("img", { alt: "b3 coin", loading: "lazy", width: "64", height: "64", decoding: "async", "data-nimg": "1", className: "size-full shrink-0 bg-transparent text-transparent", src: "https://cdn.b3.fun/b3-coin-3d.png" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-[50%] border border-white/10" })] })] }), (0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: false, animate: {
|
|
245
245
|
opacity: hasMounted ? 1 : 0,
|
|
246
246
|
y: hasMounted ? 0 : 20,
|
|
247
247
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
248
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsxs)("h2", { className: "font-sf-rounded mb-1 text-center text-2xl font-semibold", children: ["Staked ", (0, number_1.formatTokenAmount)(BigInt(userStakeAmount), 18), " B3"] }) })] }), (0, jsx_runtime_1.jsxs)(
|
|
248
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsxs)("h2", { className: "font-sf-rounded mb-1 text-center text-2xl font-semibold", children: ["Staked ", (0, number_1.formatTokenAmount)(BigInt(userStakeAmount), 18), " B3"] }) })] }), (0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: false, animate: {
|
|
249
249
|
opacity: hasMounted ? 1 : 0,
|
|
250
250
|
y: hasMounted ? 0 : 20,
|
|
251
251
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -4,13 +4,13 @@ exports.AnySpendTournament = AnySpendTournament;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const utils_1 = require("../../../shared/utils");
|
|
6
6
|
const number_1 = require("../../../shared/utils/number");
|
|
7
|
-
const
|
|
7
|
+
const react_1 = require("motion/react");
|
|
8
8
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
9
9
|
function AnySpendTournament(props) {
|
|
10
10
|
const { isMainnet = true, mode = "modal", action, loadOrder, tournamentChainId, tournamentContractAddress, tournamentMetadata, onSuccess, } = props;
|
|
11
11
|
const dstToken = action === "join" ? props.tournamentEntryToken : props.tournamentFundToken;
|
|
12
12
|
const dstAmount = action === "join" ? props.tournamentEntryFee : props.tournamentFundAmount;
|
|
13
|
-
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "z-10 mt-[-100px] flex h-[270px] w-full items-end justify-center", children: (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/tournament-play.svg", alt: "Tournament Play", className: "h-[200px] w-[360px] object-cover object-center" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-1 p-6 pt-0", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-center text-lg font-semibold", children: [action === "join" ? "Pay entry fee to join " : "Pay to fund ", " ", tournamentMetadata.name] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2 flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(
|
|
13
|
+
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "z-10 mt-[-100px] flex h-[270px] w-full items-end justify-center", children: (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/tournament-play.svg", alt: "Tournament Play", className: "h-[200px] w-[360px] object-cover object-center" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-1 p-6 pt-0", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-center text-lg font-semibold", children: [action === "join" ? "Pay entry fee to join " : "Pay to fund ", " ", tournamentMetadata.name] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2 flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-2xl font-semibold transition-all", {
|
|
14
14
|
"opacity-0": isLoadingAnyspendPrice,
|
|
15
15
|
}), children: [(0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }), " (", (0, number_1.formatTokenAmount)(BigInt(dstAmount), dstToken.decimals, 6, true), " ", dstToken.symbol, ")"] }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[32px] w-full" })) })] })] })] }));
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? "join_tournament" : "fund_tournament", dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
@@ -16,10 +16,10 @@ const react_2 = require("@chakra-ui/react");
|
|
|
16
16
|
const spl_token_1 = require("@solana/spl-token");
|
|
17
17
|
const web3_js_1 = require("@solana/web3.js");
|
|
18
18
|
const react_3 = require("@web3icons/react");
|
|
19
|
-
const framer_motion_1 = require("framer-motion");
|
|
20
19
|
const lucide_react_1 = require("lucide-react");
|
|
20
|
+
const react_4 = require("motion/react");
|
|
21
21
|
const qrcode_react_1 = require("qrcode.react");
|
|
22
|
-
const
|
|
22
|
+
const react_5 = require("react");
|
|
23
23
|
const react_timeago_1 = __importDefault(require("react-timeago"));
|
|
24
24
|
const sonner_1 = require("sonner");
|
|
25
25
|
const viem_1 = require("viem");
|
|
@@ -122,7 +122,7 @@ function roundTokenAmount(amount) {
|
|
|
122
122
|
const roundedDecimalPart = digits.join("");
|
|
123
123
|
return `${wholePart}.${roundedDecimalPart}`;
|
|
124
124
|
}
|
|
125
|
-
exports.OrderDetails = (0,
|
|
125
|
+
exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ isMainnet, mode = "modal", order, depositTxs, relayTx, executeTx, refundTxs, onBack, }) {
|
|
126
126
|
const router = (0, hooks_1.useRouter)();
|
|
127
127
|
const searchParams = (0, hooks_1.useSearchParams)();
|
|
128
128
|
const setB3ModalOpen = (0, react_1.useModalStore)(state => state.setB3ModalOpen);
|
|
@@ -134,12 +134,12 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
134
134
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
135
135
|
const account = (0, react_1.useAccountWallet)();
|
|
136
136
|
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
137
|
-
const [txHash, setTxHash] = (0,
|
|
138
|
-
const [showQRCode, setShowQRCode] = (0,
|
|
137
|
+
const [txHash, setTxHash] = (0, react_5.useState)();
|
|
138
|
+
const [showQRCode, setShowQRCode] = (0, react_5.useState)(false);
|
|
139
139
|
const { isLoading: txLoading, isSuccess: txSuccess } = (0, wagmi_1.useWaitForTransactionReceipt)({ hash: txHash });
|
|
140
140
|
const { switchChainAndExecute, isSwitchingOrExecuting } = (0, react_1.useChainSwitchWithAction)();
|
|
141
141
|
const { colorMode } = (0, react_2.useColorMode)();
|
|
142
|
-
const roundedUpSrcAmount = (0,
|
|
142
|
+
const roundedUpSrcAmount = (0, react_5.useMemo)(() => {
|
|
143
143
|
// Display the full transfer amount without rounding since users need to see the exact value they're transferring.
|
|
144
144
|
// Use 21 significant digits (max allowed by Intl.NumberFormat)
|
|
145
145
|
const formattedSrcAmount = srcToken
|
|
@@ -148,7 +148,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
148
148
|
return roundTokenAmount(formattedSrcAmount);
|
|
149
149
|
}, [order.srcAmount, srcToken]);
|
|
150
150
|
// This function handles the actual payment process
|
|
151
|
-
const handlePaymentProcess = (0,
|
|
151
|
+
const handlePaymentProcess = (0, react_5.useCallback)(async (currentWalletClient) => {
|
|
152
152
|
if (!currentWalletClient || !currentWalletClient?.chain?.id) {
|
|
153
153
|
sonner_1.toast.error("Please connect your wallet");
|
|
154
154
|
return;
|
|
@@ -188,13 +188,13 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
// When waitingForDeposit is true, we show a message to the user to wait for the deposit to be processed.
|
|
191
|
-
const setWaitingForDeposit = (0,
|
|
191
|
+
const setWaitingForDeposit = (0, react_5.useCallback)(() => {
|
|
192
192
|
const params = new URLSearchParams(searchParams.toString());
|
|
193
193
|
params.set("waitingForDeposit", "true");
|
|
194
194
|
router.push(`?${params}`);
|
|
195
195
|
}, [router, searchParams]);
|
|
196
196
|
// Clean up URL parameters before closing modal or navigating back
|
|
197
|
-
const cleanupUrlParams = (0,
|
|
197
|
+
const cleanupUrlParams = (0, react_5.useCallback)(() => {
|
|
198
198
|
const params = new URLSearchParams(searchParams.toString());
|
|
199
199
|
params.delete("waitingForDeposit");
|
|
200
200
|
params.delete("orderId");
|
|
@@ -204,26 +204,26 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
204
204
|
}
|
|
205
205
|
}, [router, searchParams]);
|
|
206
206
|
// Helper functions that clean up URL params before executing actions
|
|
207
|
-
const handleCloseModal = (0,
|
|
207
|
+
const handleCloseModal = (0, react_5.useCallback)(() => {
|
|
208
208
|
cleanupUrlParams();
|
|
209
209
|
setB3ModalOpen(false);
|
|
210
210
|
}, [cleanupUrlParams, setB3ModalOpen]);
|
|
211
|
-
const handleBack = (0,
|
|
211
|
+
const handleBack = (0, react_5.useCallback)(() => {
|
|
212
212
|
cleanupUrlParams();
|
|
213
213
|
onBack?.();
|
|
214
214
|
}, [cleanupUrlParams, onBack]);
|
|
215
|
-
(0,
|
|
215
|
+
(0, react_5.useEffect)(() => {
|
|
216
216
|
if (txSuccess) {
|
|
217
217
|
sonner_1.toast.success("Transaction successful! We are processing your order.", { duration: 10000 });
|
|
218
218
|
setWaitingForDeposit();
|
|
219
219
|
setTxHash(undefined);
|
|
220
220
|
}
|
|
221
221
|
}, [setWaitingForDeposit, txSuccess]);
|
|
222
|
-
const [showOrderDetails, setShowOrderDetails] = (0,
|
|
223
|
-
const isPhantomMobile = (0,
|
|
224
|
-
const isPhantomBrowser = (0,
|
|
222
|
+
const [showOrderDetails, setShowOrderDetails] = (0, react_5.useState)(false);
|
|
223
|
+
const isPhantomMobile = (0, react_5.useMemo)(() => navigator.userAgent.includes("Phantom"), []);
|
|
224
|
+
const isPhantomBrowser = (0, react_5.useMemo)(() => window.phantom?.solana?.isPhantom, []);
|
|
225
225
|
// Get connected Phantom wallet address if available
|
|
226
|
-
const phantomWalletAddress = (0,
|
|
226
|
+
const phantomWalletAddress = (0, react_5.useMemo)(() => {
|
|
227
227
|
const phantom = window.phantom?.solana;
|
|
228
228
|
if (phantom?.isConnected && phantom?.publicKey) {
|
|
229
229
|
return phantom.publicKey.toString();
|
|
@@ -395,7 +395,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
395
395
|
}
|
|
396
396
|
};
|
|
397
397
|
if (refundTxs) {
|
|
398
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(
|
|
398
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
399
399
|
? depositTxs.map(dTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
400
400
|
? `Received payment`
|
|
401
401
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTx, isProcessing: false }, dTx.txHash)))
|
|
@@ -404,7 +404,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
404
404
|
: null] }), order.errorDetails && ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: (0, anyspend_1.getErrorDisplay)(order.errorDetails) }) })), (0, jsx_runtime_1.jsx)("button", { className: "bg-as-on-surface-2 text-as-secondary flex w-full items-center justify-center gap-2 rounded-lg p-2", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
|
|
405
405
|
}
|
|
406
406
|
if (executeTx) {
|
|
407
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(
|
|
407
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
408
408
|
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
409
409
|
? `Received payment`
|
|
410
410
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
@@ -426,7 +426,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
426
426
|
}), (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { className: "ml-2 h-4 w-4" })] }) }) }), order.type === "join_tournament" && order.status === "executed" && ((0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4", children: "Continue to Tournament" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && ((0, jsx_runtime_1.jsx)("button", { className: "bg-as-on-surface-2 text-as-secondary flex w-full items-center justify-center gap-2 rounded-lg p-2", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
|
|
427
427
|
}
|
|
428
428
|
if (relayTx && relayTx.status === "success") {
|
|
429
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(
|
|
429
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
430
430
|
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
431
431
|
? `Received payment`
|
|
432
432
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
@@ -458,7 +458,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
458
458
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
459
459
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
460
460
|
if (depositTxs?.length || waitingForDeposit) {
|
|
461
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(
|
|
461
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
462
462
|
? `Received payment`
|
|
463
463
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap"
|
|
464
464
|
? "Processing Swap"
|
|
@@ -480,7 +480,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
480
480
|
? "Pay from Phantom Wallet"
|
|
481
481
|
: "Pay from Connected Wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) }), (0, jsx_runtime_1.jsxs)("span", { className: "label-style text-as-primary/50 text-xs", children: ["Connected to:", " ", order.srcChain === anyspend_1.RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
482
482
|
? (0, centerTruncate_1.default)(phantomWalletAddress, 6)
|
|
483
|
-
: (0, centerTruncate_1.default)(account?.address || "", 6)] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] })) : ((0, jsx_runtime_1.jsxs)(
|
|
483
|
+
: (0, centerTruncate_1.default)(account?.address || "", 6)] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] })) : ((0, jsx_runtime_1.jsxs)(react_4.motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress), className: "max-w-[200px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletWalletConnect, { className: "h-5 w-5", variant: "branded" })] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2", children: [account && ((0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "ghost", className: "text-as-primary w-full", onClick: handlePayment, children: ["Send Transaction ", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "ml-2 h-4 w-4" })] })), anyspend_1.EVM_CHAINS[order.srcChain] ? ((0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full", onClick: handlePayment, children: ["Open Metamask", (0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "ml-2 h-5 w-5", variant: "branded" })] })) : null, (0, jsx_runtime_1.jsx)("a", { href: handleCoinbaseRedirect(), children: (0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full", children: ["Open Coinbase", (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "ml-2 h-5 w-5", variant: "branded" })] }) }), (0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full", onClick: () => initiatePhantomTransfer(order.srcAmount, order.srcTokenAddress, order.globalAddress), children: ["Open Phantom", (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "ml-2 h-5 w-5", variant: "branded" })] })] })] }))] })), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-light-brand/30 w-full rounded-lg p-4 sm:p-2 sm:px-4", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-secondary mb-3 text-sm", children: "Continue on another device?" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: permalink, onCopy: () => {
|
|
484
484
|
sonner_1.toast.success("Copied to clipboard");
|
|
485
485
|
}, children: (0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full", children: ["Copy Link", (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "ml-2 h-3 w-3" })] }) }), (0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full", onClick: () => {
|
|
486
486
|
if (navigator.share) {
|
|
@@ -495,7 +495,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
495
495
|
else {
|
|
496
496
|
sonner_1.toast.error("Web Share API is not supported on this browser");
|
|
497
497
|
}
|
|
498
|
-
}, children: ["Send Link ", (0, jsx_runtime_1.jsx)(lucide_react_1.SquareArrowOutUpRight, { className: "ml-2 h-3 w-3" })] })] })] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30", children: "Time remaining:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : ((0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.expiredAt), live: true })) })] }), showOrderDetails ? ((0, jsx_runtime_1.jsx)(
|
|
498
|
+
}, children: ["Send Link ", (0, jsx_runtime_1.jsx)(lucide_react_1.SquareArrowOutUpRight, { className: "ml-2 h-3 w-3" })] })] })] })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30", children: "Time remaining:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : ((0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.expiredAt), live: true })) })] }), showOrderDetails ? ((0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "w-full", initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-3 whitespace-nowrap py-2 text-sm", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30", children: order.type === "swap" || order.type === "mint_nft"
|
|
499
499
|
? "Expected to receive"
|
|
500
500
|
: order.type === "join_tournament"
|
|
501
501
|
? "Join tournament"
|
|
@@ -510,8 +510,8 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
510
510
|
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary flex items-center gap-2", children: [(0, centerTruncate_1.default)(order.recipientAddress, 10), (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 cursor-pointer transition-all duration-200" })] }) })] })] })] }) })) : ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsx)("button", { className: "whitespace-nowrap text-sm", onClick: () => setShowOrderDetails(true), children: "Order Details" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "text-as-primary mx-1 h-4 min-h-4 w-4 min-w-4" }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" })] })), (0, jsx_runtime_1.jsxs)("button", { className: "bg-as-on-surface-2 text-as-secondary flex w-full items-center justify-center gap-2 rounded-lg p-2", onClick: handleBack, children: ["Cancel and start over ", (0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "ml-2 h-4 w-4" })] })] }));
|
|
511
511
|
});
|
|
512
512
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
513
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex grow items-center gap-4", children: [(0, jsx_runtime_1.jsx)(
|
|
513
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex grow items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "bg-b3-react-background relative h-10 w-10 rounded-full", children: isProcessing ? ((0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full bg-black/70 shadow-lg backdrop-blur-sm", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : ((0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-brand/70 absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg shadow-purple-500/30 backdrop-blur-sm", style: {
|
|
514
514
|
boxShadow: "0 0 15px 5px rgba(138, 43, 226, 0.2)",
|
|
515
|
-
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.CheckIcon, { className: "text-as-primary h-3 w-3" }) })) }), (0, jsx_runtime_1.jsx)(
|
|
515
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.CheckIcon, { className: "text-as-primary h-3 w-3" }) })) }), (0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay }, className: "shrink-0 text-base", children: isProcessing ? ((0, jsx_runtime_1.jsx)(react_1.TextShimmer, { duration: 1, children: title })) : ((0, jsx_runtime_1.jsx)("span", { className: "text-as-primary", children: title })) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-1", children: tx ? ((0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay: (delay || 0) + 0.3 }, className: "flex items-center gap-3", children: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chainId, tx.txHash), target: "_blank", children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30 font-mono text-xs", children: (0, centerTruncate_1.default)(tx?.txHash, 6) }) }) })) : null })] }));
|
|
516
516
|
}
|
|
517
517
|
exports.OrderDetailsLoadingView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-4", children: [(0, jsx_runtime_1.jsxs)(react_1.Badge, { variant: "default", className: "hover:bg-b3-react-background flex items-center gap-3 border-white/20 bg-white/10 px-4 py-1 text-base transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }), (0, jsx_runtime_1.jsx)(react_1.TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-8 w-48" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "ml-4 h-8 w-32" })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mt-4 h-8 w-24" })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mb-4 h-12 w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)(react_1.Skeleton, { className: "rounded-lg p-6 pb-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[200px] w-[200px]" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-3 flex items-center justify-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "h-5 w-5 rounded-full" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => ((0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 w-full" }, i))) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background mt-8 w-full rounded-lg p-4", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mb-3 h-4 w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 flex-1" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 flex-1" })] })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 w-full" })] }));
|
|
@@ -4,15 +4,15 @@ exports.PanelOnramp = PanelOnramp;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("../../../../anyspend/react");
|
|
6
6
|
const react_2 = require("../../../../global-account/react");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const react_3 = require("motion/react");
|
|
8
|
+
const react_4 = require("react");
|
|
9
9
|
const sonner_1 = require("sonner");
|
|
10
10
|
const PaymentOptions_1 = require("./PaymentOptions");
|
|
11
11
|
function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, }) {
|
|
12
12
|
// Get geo data for onramp availability
|
|
13
13
|
const { geoData } = (0, react_2.useGetGeo)();
|
|
14
14
|
const { coinbaseOnrampOptions } = (0, react_1.useCoinbaseOnrampOptions)(true, geoData?.country || "US");
|
|
15
|
-
const amountInputRef = (0,
|
|
15
|
+
const amountInputRef = (0, react_4.useRef)(null);
|
|
16
16
|
const handleAmountChange = (e) => {
|
|
17
17
|
// Only allow numbers and decimal points
|
|
18
18
|
const value = e.target.value.replace(/[^0-9.]/g, "");
|
|
@@ -36,7 +36,7 @@ function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, }) {
|
|
|
36
36
|
"25,000"] })) : ((0, jsx_runtime_1.jsx)("p", { className: "label-style text-b3-react-foreground/60 -mb-3 mt-3 text-xs dark:bg-transparent", children: "Buy amount in USD" })), (0, jsx_runtime_1.jsxs)("div", { className: "relative inline-flex items-center dark:bg-transparent", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-b3-react-foreground/60 -ms-3 -mt-2 text-2xl font-semibold dark:bg-transparent", children: "$" }), (0, jsx_runtime_1.jsx)(react_2.Input, { ref: amountInputRef, type: "text", value: srcAmountOnRamp, onChange: handleAmountChange, placeholder: "0.00", className: "placeholder:text-b3-react-foreground/60 h-auto min-w-[70px] border-0 bg-transparent py-6 text-center text-4xl font-semibold focus-visible:ring-0 focus-visible:ring-offset-0 dark:bg-transparent", style: {
|
|
37
37
|
width: `${Math.max(50, srcAmountOnRamp.length * 34)}px`,
|
|
38
38
|
minWidth: srcAmountOnRamp ? `auto` : "105px",
|
|
39
|
-
} }), (0, jsx_runtime_1.jsx)(
|
|
39
|
+
} }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)(react_3.motion.div, { animate: { opacity: !srcAmountOnRamp || parseFloat(srcAmountOnRamp) <= 0 ? 1 : 0 }, exit: { opacity: 0 }, transition: { duration: 0.5, ease: "easeInOut" }, className: "border-b3-react-foreground/10 absolute bottom-3 left-1 h-1 w-[90%] rounded-full border-t-2 border-dashed bg-transparent" }) })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-4 gap-4", children: ["5", "10", "25", "100"].map(value => ((0, jsx_runtime_1.jsxs)("button", { onClick: () => handleQuickAmount(value), className: `rounded-lg border px-4 py-3 ${srcAmountOnRamp === value
|
|
40
40
|
? "border-as-brand bg-as-brand/30"
|
|
41
41
|
: "border-as-stroke hover:border-as-brand hover:bg-as-brand/30"} transition-all duration-200`, children: ["$", value] }, value))) })] }));
|
|
42
42
|
}
|