@b3dotfun/sdk 0.1.69-alpha.7 → 0.1.69-alpha.9
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/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.js +57 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/app.shared.ts +9 -8
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/shared/utils/session-duration.ts +64 -0
|
@@ -268,7 +268,7 @@ function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmo
|
|
|
268
268
|
opacity: hasMounted ? 1 : 0,
|
|
269
269
|
y: hasMounted ? 0 : 20,
|
|
270
270
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
271
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href:
|
|
271
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chains_1.base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
272
272
|
setB3ModalOpen(false);
|
|
273
273
|
onSuccess?.();
|
|
274
274
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -278,7 +278,7 @@ function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenAddress,
|
|
|
278
278
|
opacity: hasMounted ? 1 : 0,
|
|
279
279
|
y: hasMounted ? 0 : 20,
|
|
280
280
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
281
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href:
|
|
281
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chains_1.base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
282
282
|
setB3ModalOpen(false);
|
|
283
283
|
onSuccess?.((0, number_1.formatTokenAmount)(BigInt(userStakeAmount), 18) ?? "");
|
|
284
284
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
2
|
interface CheckoutSuccessProps {
|
|
3
3
|
txHash?: string;
|
|
4
|
+
dstChainId?: number;
|
|
4
5
|
orderId?: string;
|
|
5
6
|
returnUrl?: string;
|
|
6
7
|
returnLabel?: string;
|
|
7
8
|
classes?: AnySpendCheckoutClasses;
|
|
8
9
|
}
|
|
9
|
-
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.CheckoutSuccess = CheckoutSuccess;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const anyspend_1 = require("../../../../anyspend");
|
|
7
|
+
const chains_1 = require("viem/chains");
|
|
6
8
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
9
|
const lucide_react_1 = require("lucide-react");
|
|
8
10
|
const react_1 = require("motion/react");
|
|
9
11
|
const AnySpendCustomizationContext_1 = require("../context/AnySpendCustomizationContext");
|
|
10
12
|
const AnimatedCheckmark_1 = require("../icons/AnimatedCheckmark");
|
|
11
|
-
function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
13
|
+
function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }) {
|
|
12
14
|
const { content, slots } = (0, AnySpendCustomizationContext_1.useAnySpendCustomization)();
|
|
13
15
|
if (slots.successScreen) {
|
|
14
16
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: slots.successScreen({
|
|
@@ -18,7 +20,7 @@ function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
|
18
20
|
: "Your payment has been processed successfully.",
|
|
19
21
|
txHash,
|
|
20
22
|
orderId,
|
|
21
|
-
explorerUrl: txHash ?
|
|
23
|
+
explorerUrl: txHash ? (0, anyspend_1.getExplorerTxUrl)(dstChainId ?? chains_1.b3.id, txHash) : undefined,
|
|
22
24
|
onDone: () => {
|
|
23
25
|
if (returnUrl)
|
|
24
26
|
window.location.href = returnUrl;
|
|
@@ -27,5 +29,5 @@ function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
|
27
29
|
returnLabel: content.returnButtonLabel || returnLabel,
|
|
28
30
|
}) }));
|
|
29
31
|
}
|
|
30
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-success-icon mb-4", children: (0, jsx_runtime_1.jsx)(AnimatedCheckmark_1.AnimatedCheckmark, { className: "h-16 w-16" }) }), (0, jsx_runtime_1.jsx)(react_1.motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), (0, jsx_runtime_1.jsx)(react_1.motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && ((0, jsx_runtime_1.jsxs)(react_1.motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href:
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-success-icon mb-4", children: (0, jsx_runtime_1.jsx)(AnimatedCheckmark_1.AnimatedCheckmark, { className: "h-16 w-16" }) }), (0, jsx_runtime_1.jsx)(react_1.motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), (0, jsx_runtime_1.jsx)(react_1.motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && ((0, jsx_runtime_1.jsxs)(react_1.motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: (0, anyspend_1.getExplorerTxUrl)(dstChainId ?? chains_1.b3.id, txHash), target: "_blank", rel: "noopener noreferrer", className: "anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", children: ["View Transaction", (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && ((0, jsx_runtime_1.jsxs)(react_1.motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, className: "anyspend-success-order-id mt-4 text-xs text-gray-400 dark:text-gray-500", children: ["Order ID: ", orderId] })), returnUrl && ((0, jsx_runtime_1.jsx)(react_1.motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: (0, cn_1.cn)("anyspend-success-return-btn mt-6 inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" }))] }));
|
|
31
33
|
}
|
package/dist/cjs/app.shared.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.clientOptions = exports.MyAuthenticationClient = exports.authenticate =
|
|
|
7
7
|
const authentication_client_1 = require("@feathersjs/authentication-client");
|
|
8
8
|
const js_cookie_1 = __importDefault(require("js-cookie"));
|
|
9
9
|
const constants_1 = require("./shared/constants");
|
|
10
|
+
const session_duration_1 = require("./shared/utils/session-duration");
|
|
10
11
|
exports.B3_API_URL = process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
|
|
11
|
-
const DEV_USER_GROUP = 4;
|
|
12
12
|
const authenticate = async (app, accessToken, identityToken, params) => {
|
|
13
13
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
14
14
|
// Do not authenticate if there is no token
|
|
@@ -23,12 +23,14 @@ const authenticate = async (app, accessToken, identityToken, params) => {
|
|
|
23
23
|
}, {
|
|
24
24
|
query: params || {},
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const token = js_cookie_1.default.get(constants_1.B3_AUTH_COOKIE_NAME);
|
|
27
|
+
if (token) {
|
|
28
|
+
const days = (0, session_duration_1.getSessionDurationDays)(response?.user?.preferences, params?.partnerId);
|
|
29
|
+
js_cookie_1.default.set(constants_1.B3_AUTH_COOKIE_NAME, token, {
|
|
30
|
+
...(days > 0 ? { expires: days } : {}),
|
|
31
|
+
secure: true,
|
|
32
|
+
sameSite: "Lax",
|
|
33
|
+
});
|
|
32
34
|
}
|
|
33
35
|
return response;
|
|
34
36
|
}
|
|
@@ -23,6 +23,7 @@ const LinkAccount_1 = require("./LinkAccount/LinkAccount");
|
|
|
23
23
|
const LinkNewAccount_1 = require("./LinkAccount/LinkNewAccount");
|
|
24
24
|
const ManageAccount_1 = require("./ManageAccount/ManageAccount");
|
|
25
25
|
const NotificationsContent_1 = __importDefault(require("./ManageAccount/NotificationsContent"));
|
|
26
|
+
const SessionDurationContent_1 = __importDefault(require("./ManageAccount/SessionDurationContent"));
|
|
26
27
|
const RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
|
|
27
28
|
const Send_1 = require("./Send/Send");
|
|
28
29
|
const SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
|
|
@@ -146,6 +147,8 @@ function B3DynamicModal() {
|
|
|
146
147
|
return (0, jsx_runtime_1.jsx)(Send_1.Send, { ...contentType });
|
|
147
148
|
case "notifications":
|
|
148
149
|
return (0, jsx_runtime_1.jsx)(NotificationsContent_1.default, { ...contentType });
|
|
150
|
+
case "sessionDuration":
|
|
151
|
+
return (0, jsx_runtime_1.jsx)(SessionDurationContent_1.default, { partnerId: contentType.partnerId });
|
|
149
152
|
// Add other modal types here
|
|
150
153
|
default:
|
|
151
154
|
return null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const app_1 = __importDefault(require("../../../../global-account/app"));
|
|
8
|
+
const react_1 = require("../../../../global-account/react");
|
|
9
|
+
const session_duration_1 = require("../../../../shared/utils/session-duration");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
const ModalHeader_1 = __importDefault(require("../ModalHeader/ModalHeader"));
|
|
12
|
+
const DESCRIPTIONS = {
|
|
13
|
+
0: "Sign out when browser closes",
|
|
14
|
+
1: "Stay signed in for 1 day",
|
|
15
|
+
7: "Stay signed in for 7 days",
|
|
16
|
+
14: "Stay signed in for 2 weeks",
|
|
17
|
+
30: "Stay signed in for 30 days",
|
|
18
|
+
};
|
|
19
|
+
const SessionDurationContent = ({ partnerId }) => {
|
|
20
|
+
const { user, setUser } = (0, react_1.useAuthentication)(partnerId);
|
|
21
|
+
const navigateBack = (0, react_1.useModalStore)(state => state.navigateBack);
|
|
22
|
+
const [sessionDays, setSessionDays] = (0, react_2.useState)(() => (0, session_duration_1.getSessionDurationDays)(user?.preferences, partnerId));
|
|
23
|
+
const [saving, setSaving] = (0, react_2.useState)(false);
|
|
24
|
+
const handleSelect = async (days) => {
|
|
25
|
+
const previous = sessionDays;
|
|
26
|
+
(0, session_duration_1.setSessionDurationDays)(days, partnerId);
|
|
27
|
+
setSessionDays(days);
|
|
28
|
+
if (user?.userId) {
|
|
29
|
+
setSaving(true);
|
|
30
|
+
try {
|
|
31
|
+
const updated = await app_1.default.service("users").patch(user.userId, {
|
|
32
|
+
preferences: {
|
|
33
|
+
...user.preferences,
|
|
34
|
+
[partnerId]: {
|
|
35
|
+
...((user.preferences ?? {})[partnerId] ?? {}),
|
|
36
|
+
sessionDuration: days,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
setUser(updated);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error("Failed to save session duration preference:", error);
|
|
44
|
+
// Revert optimistic update so UI stays consistent with server state
|
|
45
|
+
setSessionDays(previous);
|
|
46
|
+
(0, session_duration_1.setSessionDurationDays)(previous, partnerId);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
setSaving(false);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-[470px] flex-col", children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.default, { showBackButton: true, showCloseButton: false, title: "Stay signed in", handleBack: navigateBack }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-2 p-5", children: session_duration_1.SESSION_DURATION_OPTIONS.map(days => ((0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => handleSelect(days), disabled: saving, className: `flex items-center justify-between rounded-xl border px-4 py-3 transition-colors ${sessionDays === days
|
|
54
|
+
? "border-[#3f3f46] bg-[#f4f4f5] dark:border-white dark:bg-white/10"
|
|
55
|
+
: "border-[#e4e4e7] bg-transparent hover:bg-[#f4f4f5] dark:border-white/10 dark:hover:bg-white/5"}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-0.5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-neue-montreal-semibold text-[14px] leading-none tracking-[-0.28px] text-[#3f3f46] dark:text-white", children: session_duration_1.SESSION_DURATION_LABELS[days] }), (0, jsx_runtime_1.jsx)("span", { className: "font-neue-montreal-medium text-[13px] leading-none tracking-[-0.26px] text-[#70707b] dark:text-white/50", children: DESCRIPTIONS[days] })] }), sessionDays === days && ((0, jsx_runtime_1.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full bg-[#3f3f46] dark:bg-white", children: (0, jsx_runtime_1.jsx)("svg", { width: "10", height: "8", viewBox: "0 0 10 8", fill: "none", children: (0, jsx_runtime_1.jsx)("path", { d: "M1 4L3.5 6.5L9 1", stroke: "white", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", className: "dark:stroke-[#3f3f46]" }) }) }))] }, days))) })] }));
|
|
56
|
+
};
|
|
57
|
+
exports.default = SessionDurationContent;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
8
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
9
|
+
const session_duration_1 = require("../../../../shared/utils/session-duration");
|
|
9
10
|
const lucide_react_1 = require("lucide-react");
|
|
10
11
|
const react_2 = require("react");
|
|
11
12
|
const react_3 = require("thirdweb/react");
|
|
@@ -16,47 +17,29 @@ const SettingsProfileCard_1 = __importDefault(require("./SettingsProfileCard"));
|
|
|
16
17
|
const SettingsContent = ({ partnerId, onLogout, chain, }) => {
|
|
17
18
|
const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
|
|
18
19
|
const setB3ModalOpen = (0, react_1.useModalStore)(state => state.setB3ModalOpen);
|
|
19
|
-
const { logout } = (0, react_1.useAuthentication)(partnerId);
|
|
20
|
+
const { logout, user } = (0, react_1.useAuthentication)(partnerId);
|
|
20
21
|
const [logoutLoading, setLogoutLoading] = (0, react_2.useState)(false);
|
|
22
|
+
const sessionDays = (0, session_duration_1.getSessionDurationDays)(user?.preferences, partnerId);
|
|
21
23
|
const { data: profilesRaw = [] } = (0, react_3.useProfiles)({ client: thirdweb_1.client });
|
|
22
24
|
const profiles = profilesRaw.filter((profile) => !["custom_auth_endpoint"].includes(profile.type));
|
|
23
25
|
const handleNavigate = (type) => {
|
|
24
26
|
if (type === "home") {
|
|
25
|
-
setB3ModalContentType({
|
|
26
|
-
type: "manageAccount",
|
|
27
|
-
chain,
|
|
28
|
-
partnerId,
|
|
29
|
-
onLogout,
|
|
30
|
-
activeTab: "home",
|
|
31
|
-
});
|
|
27
|
+
setB3ModalContentType({ type: "manageAccount", chain, partnerId, onLogout, activeTab: "home" });
|
|
32
28
|
}
|
|
33
29
|
else if (type === "swap") {
|
|
34
|
-
setB3ModalContentType({
|
|
35
|
-
type: "manageAccount",
|
|
36
|
-
chain,
|
|
37
|
-
partnerId,
|
|
38
|
-
onLogout,
|
|
39
|
-
activeTab: "tokens",
|
|
40
|
-
});
|
|
30
|
+
setB3ModalContentType({ type: "manageAccount", chain, partnerId, onLogout, activeTab: "tokens" });
|
|
41
31
|
}
|
|
42
32
|
else if (type === "linkAccount") {
|
|
43
|
-
setB3ModalContentType({
|
|
44
|
-
type: "linkAccount",
|
|
45
|
-
chain,
|
|
46
|
-
partnerId,
|
|
47
|
-
});
|
|
33
|
+
setB3ModalContentType({ type: "linkAccount", chain, partnerId });
|
|
48
34
|
}
|
|
49
35
|
else if (type === "notifications") {
|
|
50
|
-
setB3ModalContentType({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
36
|
+
setB3ModalContentType({ type: "notifications", chain, partnerId });
|
|
37
|
+
}
|
|
38
|
+
else if (type === "sessionDuration") {
|
|
39
|
+
setB3ModalContentType({ type: "sessionDuration", chain, partnerId });
|
|
55
40
|
}
|
|
56
41
|
else {
|
|
57
|
-
setB3ModalContentType({
|
|
58
|
-
type: "avatarEditor",
|
|
59
|
-
});
|
|
42
|
+
setB3ModalContentType({ type: "avatarEditor" });
|
|
60
43
|
}
|
|
61
44
|
setB3ModalOpen(true);
|
|
62
45
|
};
|
|
@@ -67,7 +50,7 @@ const SettingsContent = ({ partnerId, onLogout, chain, }) => {
|
|
|
67
50
|
setB3ModalOpen(false);
|
|
68
51
|
setLogoutLoading(false);
|
|
69
52
|
};
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-[470px] flex-col", children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.default, { showBackButton: false, showCloseButton: false, title: "Settings" }), (0, jsx_runtime_1.jsx)("div", { className: "p-5", children: (0, jsx_runtime_1.jsx)("div", { className: "b3-modal-settings-profile-card dark:border-b3-line dark:bg-b3-background flex items-center rounded-xl border border-[#e4e4e7] bg-[#f4f4f5] p-4", children: (0, jsx_runtime_1.jsx)(SettingsProfileCard_1.default, {}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3 px-5", children: [(0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Linked Accounts", subtitle: `${profiles.length} connected account${profiles.length > 1 ? "s" : ""}`, onClick: () => handleNavigate("linkAccount") }), (0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Notifications", subtitle: "Manage your notifications", onClick: () => handleNavigate("notifications") })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-auto px-5 pb-5", children: (0, jsx_runtime_1.jsxs)("button", { className: "b3-modal-sign-out-button border-b3-line hover:bg-b3-line bg-b3-background dark:bg-b3-background dark:border-b3-line dark:hover:bg-b3-line/80 flex w-full items-center justify-center gap-1.5 rounded-xl border border-solid p-3 transition-colors", onClick: onLogoutEnhanced, disabled: logoutLoading, style: {
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-[470px] flex-col", children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.default, { showBackButton: false, showCloseButton: false, title: "Settings" }), (0, jsx_runtime_1.jsx)("div", { className: "p-5", children: (0, jsx_runtime_1.jsx)("div", { className: "b3-modal-settings-profile-card dark:border-b3-line dark:bg-b3-background flex items-center rounded-xl border border-[#e4e4e7] bg-[#f4f4f5] p-4", children: (0, jsx_runtime_1.jsx)(SettingsProfileCard_1.default, {}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3 px-5", children: [(0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Linked Accounts", subtitle: `${profiles.length} connected account${profiles.length > 1 ? "s" : ""}`, onClick: () => handleNavigate("linkAccount") }), (0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Notifications", subtitle: "Manage your notifications", onClick: () => handleNavigate("notifications") }), (0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Stay signed in", subtitle: session_duration_1.SESSION_DURATION_LABELS[sessionDays] ?? `${sessionDays} days`, onClick: () => handleNavigate("sessionDuration") })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-auto px-5 pb-5", children: (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "b3-modal-sign-out-button border-b3-line hover:bg-b3-line bg-b3-background dark:bg-b3-background dark:border-b3-line dark:hover:bg-b3-line/80 flex w-full items-center justify-center gap-1.5 rounded-xl border border-solid p-3 transition-colors", onClick: onLogoutEnhanced, disabled: logoutLoading, style: {
|
|
71
54
|
boxShadow: "inset 0px 0px 0px 1px rgba(10,13,18,0.18), inset 0px -2px 0px 0px rgba(10,13,18,0.05)",
|
|
72
55
|
}, children: [logoutLoading ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-grey animate-spin", size: 20 })) : ((0, jsx_runtime_1.jsx)(SignOutIcon_1.default, { size: 20, className: "text-b3-grey", color: "currentColor" })), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-grey dark:text-b3-foreground-muted font-neue-montreal-semibold text-base", children: "Sign out" })] }) })] }));
|
|
73
56
|
};
|
|
@@ -7451,8 +7451,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7451
7451
|
[x: `bool[${string}]`]: undefined;
|
|
7452
7452
|
[x: `bytes[${string}]`]: undefined;
|
|
7453
7453
|
[x: `bytes1[${string}]`]: undefined;
|
|
7454
|
-
[x: `
|
|
7454
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
7455
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
7455
7456
|
[x: `bytes30[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
7456
7458
|
[x: `bytes18[${string}]`]: undefined;
|
|
7457
7459
|
[x: `bytes6[${string}]`]: undefined;
|
|
7458
7460
|
[x: `bytes9[${string}]`]: undefined;
|
|
@@ -7460,12 +7462,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7460
7462
|
[x: `bytes10[${string}]`]: undefined;
|
|
7461
7463
|
[x: `bytes2[${string}]`]: undefined;
|
|
7462
7464
|
[x: `bytes3[${string}]`]: undefined;
|
|
7463
|
-
[x: `
|
|
7464
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
7465
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
7465
7466
|
[x: `bytes11[${string}]`]: undefined;
|
|
7466
7467
|
[x: `bytes12[${string}]`]: undefined;
|
|
7467
7468
|
[x: `bytes13[${string}]`]: undefined;
|
|
7468
|
-
[x: `bytes14[${string}]`]: undefined;
|
|
7469
7469
|
[x: `bytes15[${string}]`]: undefined;
|
|
7470
7470
|
[x: `bytes16[${string}]`]: undefined;
|
|
7471
7471
|
[x: `bytes17[${string}]`]: undefined;
|
|
@@ -7553,8 +7553,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7553
7553
|
bool?: undefined;
|
|
7554
7554
|
bytes?: undefined;
|
|
7555
7555
|
bytes1?: undefined;
|
|
7556
|
-
|
|
7556
|
+
bytes7?: undefined;
|
|
7557
|
+
bytes14?: undefined;
|
|
7557
7558
|
bytes30?: undefined;
|
|
7559
|
+
bytes5?: undefined;
|
|
7558
7560
|
bytes18?: undefined;
|
|
7559
7561
|
bytes6?: undefined;
|
|
7560
7562
|
bytes9?: undefined;
|
|
@@ -7562,12 +7564,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7562
7564
|
bytes10?: undefined;
|
|
7563
7565
|
bytes2?: undefined;
|
|
7564
7566
|
bytes3?: undefined;
|
|
7565
|
-
|
|
7566
|
-
bytes7?: undefined;
|
|
7567
|
+
bytes4?: undefined;
|
|
7567
7568
|
bytes11?: undefined;
|
|
7568
7569
|
bytes12?: undefined;
|
|
7569
7570
|
bytes13?: undefined;
|
|
7570
|
-
bytes14?: undefined;
|
|
7571
7571
|
bytes15?: undefined;
|
|
7572
7572
|
bytes16?: undefined;
|
|
7573
7573
|
bytes17?: undefined;
|
|
@@ -425,6 +425,15 @@ export interface SendModalProps extends BaseModalProps {
|
|
|
425
425
|
/** Callback function called when send is successful */
|
|
426
426
|
onSuccess?: (txHash?: string) => void;
|
|
427
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Props for the Session Duration modal
|
|
430
|
+
* Allows users to configure how long they stay signed in
|
|
431
|
+
*/
|
|
432
|
+
export interface SessionDurationModalProps extends BaseModalProps {
|
|
433
|
+
type: "sessionDuration";
|
|
434
|
+
partnerId: string;
|
|
435
|
+
chain: Chain;
|
|
436
|
+
}
|
|
428
437
|
/**
|
|
429
438
|
* Props for the Notifications modal
|
|
430
439
|
* Allows users to manage notification settings and channels
|
|
@@ -626,7 +635,7 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
626
635
|
/**
|
|
627
636
|
* Union type of all possible modal content types
|
|
628
637
|
*/
|
|
629
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
638
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | SessionDurationModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
630
639
|
/**
|
|
631
640
|
* State interface for the modal store
|
|
632
641
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const SESSION_DURATION_OPTIONS: readonly [0, 1, 7, 14, 30];
|
|
2
|
+
export type SessionDurationDays = (typeof SESSION_DURATION_OPTIONS)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Read session duration for a specific partner.
|
|
5
|
+
*
|
|
6
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
7
|
+
*
|
|
8
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
9
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
10
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSessionDurationDays(userPreferences?: Record<string, any>, partnerId?: string): SessionDurationDays;
|
|
13
|
+
export declare const SESSION_DURATION_LABELS: Record<SessionDurationDays, string>;
|
|
14
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
15
|
+
export declare function setSessionDurationDays(days: SessionDurationDays, partnerId?: string): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SESSION_DURATION_LABELS = exports.SESSION_DURATION_OPTIONS = void 0;
|
|
4
|
+
exports.getSessionDurationDays = getSessionDurationDays;
|
|
5
|
+
exports.setSessionDurationDays = setSessionDurationDays;
|
|
6
|
+
const STORAGE_KEY_PREFIX = "b3-session-duration";
|
|
7
|
+
const DEFAULT_DAYS = 7;
|
|
8
|
+
// 0 = session cookie (expires when browser closes)
|
|
9
|
+
exports.SESSION_DURATION_OPTIONS = [0, 1, 7, 14, 30];
|
|
10
|
+
function storageKey(partnerId) {
|
|
11
|
+
return partnerId ? `${STORAGE_KEY_PREFIX}_${partnerId}` : STORAGE_KEY_PREFIX;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read session duration for a specific partner.
|
|
15
|
+
*
|
|
16
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
17
|
+
*
|
|
18
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
19
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
20
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
21
|
+
*/
|
|
22
|
+
function getSessionDurationDays(userPreferences, partnerId) {
|
|
23
|
+
if (userPreferences) {
|
|
24
|
+
if (partnerId) {
|
|
25
|
+
const v = userPreferences[partnerId]?.sessionDuration;
|
|
26
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(v))
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
const v = userPreferences["sessionDuration"];
|
|
30
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(v))
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
if (partnerId) {
|
|
35
|
+
const stored = localStorage.getItem(storageKey(partnerId));
|
|
36
|
+
if (stored !== null) {
|
|
37
|
+
const parsed = Number(stored);
|
|
38
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(parsed))
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const stored = localStorage.getItem(STORAGE_KEY_PREFIX);
|
|
43
|
+
if (stored !== null) {
|
|
44
|
+
const parsed = Number(stored);
|
|
45
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(parsed))
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// localStorage unavailable (e.g. SSR)
|
|
51
|
+
}
|
|
52
|
+
return DEFAULT_DAYS;
|
|
53
|
+
}
|
|
54
|
+
exports.SESSION_DURATION_LABELS = {
|
|
55
|
+
0: "Session only",
|
|
56
|
+
1: "1 day",
|
|
57
|
+
7: "7 days",
|
|
58
|
+
14: "14 days",
|
|
59
|
+
30: "30 days",
|
|
60
|
+
};
|
|
61
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
62
|
+
function setSessionDurationDays(days, partnerId) {
|
|
63
|
+
try {
|
|
64
|
+
localStorage.setItem(storageKey(partnerId), String(days));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
4
4
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
5
5
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -262,7 +262,7 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
|
|
|
262
262
|
opacity: hasMounted ? 1 : 0,
|
|
263
263
|
y: hasMounted ? 0 : 20,
|
|
264
264
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
265
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
265
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), _jsx(Button, { onClick: () => {
|
|
266
266
|
setB3ModalOpen(false);
|
|
267
267
|
onSuccess?.();
|
|
268
268
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
4
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
5
5
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
@@ -275,7 +275,7 @@ export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenA
|
|
|
275
275
|
opacity: hasMounted ? 1 : 0,
|
|
276
276
|
y: hasMounted ? 0 : 20,
|
|
277
277
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
278
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
278
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), _jsx(Button, { onClick: () => {
|
|
279
279
|
setB3ModalOpen(false);
|
|
280
280
|
onSuccess?.(formatTokenAmount(BigInt(userStakeAmount), 18) ?? "");
|
|
281
281
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
2
|
interface CheckoutSuccessProps {
|
|
3
3
|
txHash?: string;
|
|
4
|
+
dstChainId?: number;
|
|
4
5
|
orderId?: string;
|
|
5
6
|
returnUrl?: string;
|
|
6
7
|
returnLabel?: string;
|
|
7
8
|
classes?: AnySpendCheckoutClasses;
|
|
8
9
|
}
|
|
9
|
-
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getExplorerTxUrl } from "../../../../anyspend/index.js";
|
|
4
|
+
import { b3 } from "viem/chains";
|
|
3
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
6
|
import { ExternalLink } from "lucide-react";
|
|
5
7
|
import { motion } from "motion/react";
|
|
6
8
|
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
7
9
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
8
|
-
export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
10
|
+
export function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }) {
|
|
9
11
|
const { content, slots } = useAnySpendCustomization();
|
|
10
12
|
if (slots.successScreen) {
|
|
11
13
|
return (_jsx(_Fragment, { children: slots.successScreen({
|
|
@@ -15,7 +17,7 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
15
17
|
: "Your payment has been processed successfully.",
|
|
16
18
|
txHash,
|
|
17
19
|
orderId,
|
|
18
|
-
explorerUrl: txHash ?
|
|
20
|
+
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ?? b3.id, txHash) : undefined,
|
|
19
21
|
onDone: () => {
|
|
20
22
|
if (returnUrl)
|
|
21
23
|
window.location.href = returnUrl;
|
|
@@ -24,5 +26,5 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
24
26
|
returnLabel: content.returnButtonLabel || returnLabel,
|
|
25
27
|
}) }));
|
|
26
28
|
}
|
|
27
|
-
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href:
|
|
29
|
+
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: getExplorerTxUrl(dstChainId ?? b3.id, txHash), target: "_blank", rel: "noopener noreferrer", className: "anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", children: ["View Transaction", _jsx(ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && (_jsxs(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, className: "anyspend-success-order-id mt-4 text-xs text-gray-400 dark:text-gray-500", children: ["Order ID: ", orderId] })), returnUrl && (_jsx(motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: cn("anyspend-success-return-btn mt-6 inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" }))] }));
|
|
28
30
|
}
|
package/dist/esm/app.shared.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AuthenticationClient } from "@feathersjs/authentication-client";
|
|
2
2
|
import Cookies from "js-cookie";
|
|
3
3
|
import { B3_AUTH_COOKIE_NAME } from "./shared/constants/index.js";
|
|
4
|
+
import { getSessionDurationDays } from "./shared/utils/session-duration.js";
|
|
4
5
|
export const B3_API_URL = process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
|
|
5
|
-
const DEV_USER_GROUP = 4;
|
|
6
6
|
export const authenticate = async (app, accessToken, identityToken, params) => {
|
|
7
7
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
8
8
|
// Do not authenticate if there is no token
|
|
@@ -17,12 +17,14 @@ export const authenticate = async (app, accessToken, identityToken, params) => {
|
|
|
17
17
|
}, {
|
|
18
18
|
query: params || {},
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const token = Cookies.get(B3_AUTH_COOKIE_NAME);
|
|
21
|
+
if (token) {
|
|
22
|
+
const days = getSessionDurationDays(response?.user?.preferences, params?.partnerId);
|
|
23
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, token, {
|
|
24
|
+
...(days > 0 ? { expires: days } : {}),
|
|
25
|
+
secure: true,
|
|
26
|
+
sameSite: "Lax",
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
return response;
|
|
28
30
|
}
|
|
@@ -17,6 +17,7 @@ import { LinkAccount } from "./LinkAccount/LinkAccount.js";
|
|
|
17
17
|
import { LinkNewAccount } from "./LinkAccount/LinkNewAccount.js";
|
|
18
18
|
import { ManageAccount } from "./ManageAccount/ManageAccount.js";
|
|
19
19
|
import NotificationsContent from "./ManageAccount/NotificationsContent.js";
|
|
20
|
+
import SessionDurationContent from "./ManageAccount/SessionDurationContent.js";
|
|
20
21
|
import { RequestPermissions } from "./RequestPermissions/RequestPermissions.js";
|
|
21
22
|
import { Send } from "./Send/Send.js";
|
|
22
23
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow.js";
|
|
@@ -140,6 +141,8 @@ export function B3DynamicModal() {
|
|
|
140
141
|
return _jsx(Send, { ...contentType });
|
|
141
142
|
case "notifications":
|
|
142
143
|
return _jsx(NotificationsContent, { ...contentType });
|
|
144
|
+
case "sessionDuration":
|
|
145
|
+
return _jsx(SessionDurationContent, { partnerId: contentType.partnerId });
|
|
143
146
|
// Add other modal types here
|
|
144
147
|
default:
|
|
145
148
|
return null;
|