@ab-org/predicate-market-sdk 2.2.0-beta.6 → 2.2.0-beta.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.
@@ -1,6 +1,5 @@
1
- import { chainConfig } from './chunk-SV3NR2LW.js';
1
+ import { chainConfig, getChainInfo } from './chunk-BDZKYFL5.js';
2
2
  import { getSDKConfig } from './chunk-UPMVYXZ6.js';
3
- import { getChainInfo } from './chunk-YX56ZGDB.js';
4
3
  import { sessionStore, getSupportedChainFromEvmChainId } from '@ab-org/sdk-core';
5
4
  import { CubeSignerAuth, createCubistEvmWalletProvider } from '@ab-org/sdk-core/social/auth';
6
5
 
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-DESvmgWG.js';
1
+ export { G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-Cr3RzByV.js';
2
2
  import 'react';
3
3
  import '@ab-org/sdk-core';
4
4
 
@@ -1,5 +1,5 @@
1
- import { getSDKConfig } from './chunk-BWKDIOBB.js';
2
- import './chunk-CGP7TSLF.js';
1
+ import { getSDKConfig } from './chunk-E3UPFA4K.js';
2
+ import './chunk-R2D3SM4S.js';
3
3
  import './chunk-UPMVYXZ6.js';
4
4
  import { sessionStore, createDefaultInjectedWalletRegistry, WalletConnector } from '@ab-org/sdk-core';
5
5
  import { CubistSocialProvider } from '@ab-org/sdk-core/social/provider';
@@ -1,6 +1,6 @@
1
- import { getChainInfo, getFundingTokenAddress, DEFAULT_FUNDING_CHAIN_ID } from './chunk-NTFBZNCV.js';
2
- import { getChains, createOrder } from './chunk-HNL3SLGU.js';
3
- import { getEnv } from './chunk-CGP7TSLF.js';
1
+ import { getChainInfo, getFundingTokenAddress, DEFAULT_FUNDING_CHAIN_ID } from './chunk-6AZQBNMY.js';
2
+ import { getChains, createOrder } from './chunk-E65LLR2W.js';
3
+ import { getEnv } from './chunk-R2D3SM4S.js';
4
4
  import { sessionStore, createSessionCapabilityPolicy } from '@ab-org/sdk-core';
5
5
  import { formatUnits } from 'viem';
6
6
 
@@ -246,9 +246,11 @@ async function fetchFundingTokenBalance(walletAddress, options) {
246
246
  const FUNDING_TOKEN_SYMBOL = getEnv("FUNDING_TOKEN_SYMBOL");
247
247
  const displaySymbol = options?.displaySymbol ?? (FUNDING_TOKEN_SYMBOL || "Funding");
248
248
  const raw = await fetchErc20Balance(rpcUrl, tokenAddress, walletAddress);
249
+ const fullPrecision = formatUnits2(raw, decimals);
249
250
  return {
250
251
  raw,
251
252
  formatted: formatBalanceDisplay(raw, decimals),
253
+ fullPrecision,
252
254
  symbol: displaySymbol
253
255
  };
254
256
  }
@@ -1,4 +1,4 @@
1
- import { getEnv } from './chunk-CGP7TSLF.js';
1
+ import { getEnv } from './chunk-R2D3SM4S.js';
2
2
 
3
3
  // src/constants/chains.ts
4
4
  var TENDERLY_BSC_3131 = {
@@ -271,4 +271,15 @@ getFundingTokenAddress(DEFAULT_FUNDING_CHAIN_ID);
271
271
  });
272
272
  new TextEncoder();
273
273
 
274
- export { cache_exports, getChainInfo, getEnv };
274
+ // ../sign_in_sdk/dist/config.js
275
+ var stage = getEnv("STAGE") || "dev";
276
+ var clientIds = {
277
+ google: getEnv("GOOGLE_CLIENT_ID"),
278
+ x: getEnv("X_CLIENT_ID")
279
+ };
280
+ var chainConfig = {
281
+ chainType: "evm",
282
+ chainId: getChainInfo().chainId
283
+ };
284
+
285
+ export { cache_exports, chainConfig, clientIds, getChainInfo, getEnv, stage };
@@ -1,8 +1,7 @@
1
- import { getOptionalEnv, setMerchantBaseUrl } from './chunk-CGP7TSLF.js';
1
+ import { getOptionalEnv, setMerchantBaseUrl } from './chunk-R2D3SM4S.js';
2
2
  import { getSDKConfig, initSDK } from './chunk-UPMVYXZ6.js';
3
- import { sessionStore } from '@ab-org/sdk-core';
4
- import { refreshCubeSignerSessionData } from '@ab-org/sdk-core/social/auth';
5
3
  import axios from 'axios';
4
+ import { sessionStore } from '@ab-org/sdk-core';
6
5
 
7
6
  // src/auth/bundledConfig.ts
8
7
  function getBundledAuthConfig() {
@@ -10,6 +9,7 @@ function getBundledAuthConfig() {
10
9
  const cubeEnv = getOptionalEnv("CUBE_SIGNER_ENV");
11
10
  const cubeOrgId = getOptionalEnv("CUBE_SIGNER_ORG_ID");
12
11
  const cubeLifetimes = getOptionalEnv("CUBE_SIGNER_LIFETIMES");
12
+ const lifetime = cubeLifetimes ? parseInt(cubeLifetimes) : 604800;
13
13
  return {
14
14
  googleClientId: getOptionalEnv("GOOGLE_CLIENT_ID"),
15
15
  twitterClientId: getOptionalEnv("X_CLIENT_ID"),
@@ -18,9 +18,10 @@ function getBundledAuthConfig() {
18
18
  env: cubeEnv,
19
19
  orgId: cubeOrgId,
20
20
  lifetimes: cubeLifetimes == void 0 ? void 0 : {
21
- session: parseInt(cubeLifetimes),
22
- auth: parseInt(cubeLifetimes),
23
- refresh: parseInt(cubeLifetimes) * 2
21
+ session: lifetime,
22
+ auth: Math.min(86400, lifetime),
23
+ refresh: lifetime,
24
+ grace: 30
24
25
  }
25
26
  } : void 0
26
27
  };
@@ -89,62 +90,35 @@ async function defaultRegisterUser(oidcToken) {
89
90
  throw new Error(`User register failed: ${body?.message || body?.error || body.code}`);
90
91
  }
91
92
  }
92
-
93
- // src/auth/config.ts
94
93
  function getFixedAuthConfig() {
95
94
  const bundled = getBundledAuthConfig();
96
95
  return bundled;
97
96
  }
98
- var CUBE_KEEPALIVE_INTERVAL_MS = 5 * 60 * 1e3;
99
- function getCubistKeepAliveIntervalMs() {
100
- const rawValue = getOptionalEnv("CUBE_KEEPALIVE_INTERVAL_MS");
101
- if (!rawValue) return CUBE_KEEPALIVE_INTERVAL_MS;
102
- const parsed = Number.parseInt(rawValue, 10);
103
- return Number.isFinite(parsed) && parsed > 0 ? parsed : CUBE_KEEPALIVE_INTERVAL_MS;
104
- }
105
- var cubistKeepAliveTimer = null;
106
- var cubistKeepAlivePending = null;
107
97
  function isCubistSession(session) {
108
- if (!session?.sessionData) return false;
109
- return session.walletType === "social" || session.authSource === "google" || session.authSource === "twitter";
98
+ return Boolean(
99
+ session && session.sessionData && (session.walletType === "social" || session.authSource === "google" || session.authSource === "twitter")
100
+ );
110
101
  }
111
- function isAuthorizationError(error) {
112
- return error instanceof Error && /\(401\)|\(403\)/.test(error.message);
102
+ function notifyCubistSessionExpired(session) {
103
+ cubistSessionExpiredCallback?.(session);
113
104
  }
114
- async function refreshActiveCubistSession() {
115
- const session = sessionStore.getState().session;
116
- if (!isCubistSession(session)) return;
117
- try {
118
- const refreshedSessionData = await refreshCubeSignerSessionData(session.sessionData);
119
- const latestSession = sessionStore.getState().session;
120
- if (!latestSession || latestSession.sessionId !== session.sessionId) return;
121
- sessionStore.setSession({
122
- ...latestSession,
123
- sessionData: refreshedSessionData
124
- });
125
- } catch (error) {
126
- if (isAuthorizationError(error)) {
127
- sessionStore.clearSession();
128
- }
129
- }
105
+ var cubistSessionExpiredListenerCleanup = null;
106
+ var cubistSessionExpiredCallback;
107
+ function ensureCubistSessionExpiredListener() {
108
+ if (cubistSessionExpiredListenerCleanup) return;
109
+ cubistSessionExpiredListenerCleanup = sessionStore.on("session:expired", (session) => {
110
+ if (!isCubistSession(session)) return;
111
+ notifyCubistSessionExpired(session);
112
+ });
130
113
  }
131
114
  function scheduleAutoReconnect() {
132
115
  if (typeof window === "undefined") return;
133
- void import('./autoReconnect-STOYP7SX.js').then(({ tryAutoReconnect }) => tryAutoReconnect()).catch(() => {
116
+ void import('./autoReconnect-GHZLB233.js').then(({ tryAutoReconnect }) => tryAutoReconnect()).catch(() => {
134
117
  });
135
118
  }
136
- function scheduleCubistKeepAlive() {
137
- if (typeof window === "undefined") return;
138
- if (cubistKeepAliveTimer !== null) return;
139
- const keepAliveIntervalMs = getCubistKeepAliveIntervalMs();
140
- cubistKeepAliveTimer = window.setInterval(() => {
141
- cubistKeepAlivePending ?? (cubistKeepAlivePending = refreshActiveCubistSession().finally(() => {
142
- cubistKeepAlivePending = null;
143
- }));
144
- }, keepAliveIntervalMs);
145
- }
146
119
  function initSDK2(config = {}) {
147
- const { merchantBaseUrl, registerUser, ...rest } = config;
120
+ const { merchantBaseUrl, registerUser, onSessionExpired, ...rest } = config;
121
+ cubistSessionExpiredCallback = onSessionExpired;
148
122
  const fixed = getFixedAuthConfig();
149
123
  const prev = getSDKConfig();
150
124
  const merged = {
@@ -179,8 +153,10 @@ function initSDK2(config = {}) {
179
153
  setMerchantBaseUrl(merchantBaseUrl);
180
154
  }
181
155
  initSDK(merged);
156
+ ensureCubistSessionExpiredListener();
157
+ sessionStore.flushPendingExpiry();
158
+ sessionStore.startExpiryTimer();
182
159
  scheduleAutoReconnect();
183
- scheduleCubistKeepAlive();
184
160
  }
185
161
  function getSDKConfig2() {
186
162
  return getSDKConfig();
@@ -1,4 +1,4 @@
1
- import { setMerchantBaseUrl, getMerchantBaseUrl } from './chunk-CGP7TSLF.js';
1
+ import { setMerchantBaseUrl, getMerchantBaseUrl } from './chunk-R2D3SM4S.js';
2
2
  import axios from 'axios';
3
3
 
4
4
  var merchantApiConfig = {};
@@ -1,6 +1,6 @@
1
1
  // src/core.ts
2
2
  function tryAutoReconnect() {
3
- return import('./autoReconnect-STOYP7SX.js').then(({ tryAutoReconnect: reconnect }) => reconnect());
3
+ return import('./autoReconnect-GHZLB233.js').then(({ tryAutoReconnect: reconnect }) => reconnect());
4
4
  }
5
5
 
6
6
  export { tryAutoReconnect };
@@ -1,9 +1,8 @@
1
1
  import { getExplorerUrl } from './chunk-XB2DFS2W.js';
2
- import { getChains, registerPlatform, quote, getWithdrawOrder } from './chunk-HNL3SLGU.js';
3
- import { getEnv } from './chunk-CGP7TSLF.js';
4
- import { clientIds, stage } from './chunk-SV3NR2LW.js';
2
+ import { getChains, registerPlatform, quote, getWithdrawOrder } from './chunk-E65LLR2W.js';
3
+ import { getEnv as getEnv$1 } from './chunk-R2D3SM4S.js';
4
+ import { getEnv, cache_exports, clientIds, stage } from './chunk-BDZKYFL5.js';
5
5
  import { getSDKConfig } from './chunk-UPMVYXZ6.js';
6
- import { cache_exports } from './chunk-YX56ZGDB.js';
7
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
7
  import { useEffect, useState, useRef, useMemo, useCallback } from 'react';
9
8
  import { sessionStore, getSupportedChainFromEvmChainId, createSessionCapabilityPolicy, createChainContext, CUBIST_CAPABILITIES, createDefaultInjectedWalletRegistry, WalletConnector } from '@ab-org/sdk-core';
@@ -19,6 +18,7 @@ var colors = {
19
18
  accent: "#29FF9B",
20
19
  danger: "#FF6B6B"};
21
20
  var radii = {
21
+ md: "14px",
22
22
  pill: "99px",
23
23
  card: "12px"};
24
24
  var fonts = {
@@ -221,38 +221,89 @@ var ModalFrame = ({ onClose, width = 500, cardStyle, contentStyle, children }) =
221
221
  };
222
222
 
223
223
  // ../sign_in_sdk/dist/ui/SignInModal.sections.js
224
- async function loadWalletAccount() {
225
- return import('./account-6PGNCFOX.js');
226
- }
227
- async function loadOidcAuth() {
228
- return import('./dist-Q2PDXT2F.js');
229
- }
230
- var SignInModalFrame = ({ id, title, onClose, footer, children }) => {
224
+ var SignInModalFrame = ({ id, title, onClose, onBack, footer, children }) => {
231
225
  const isMobile = useIsMobileViewport();
232
- return jsx(ModalFrame, { onClose, cardStyle: { padding: isMobile ? "24px 16px" : "32px 24px" }, contentStyle: { alignItems: "center" }, children: jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24, alignItems: "center" }, id, className: `absdk-predicate-signin-modal ${isMobile ? "absdk-predicate-signin-modal--mobile" : "absdk-predicate-signin-modal--desktop"}`, children: [jsx("h2", { className: "absdk-predicate-signin-modal__title", style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" }, children: title }), jsx("div", { className: "absdk-predicate-signin-modal__content", style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }), footer] }) });
226
+ return jsx(ModalFrame, { onClose, cardStyle: { padding: isMobile ? "24px 16px" : "32px 24px" }, contentStyle: { alignItems: "center" }, children: jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: isMobile ? 20 : 24, alignItems: "center" }, id, className: `absdk-predicate-signin-modal ${isMobile ? "absdk-predicate-signin-modal--mobile" : "absdk-predicate-signin-modal--desktop"}`, children: [jsxs("div", { style: { width: "100%", display: "flex", alignItems: "center", justifyContent: "center", position: "relative" }, children: [onBack && jsx("button", { type: "button", onClick: onBack, "aria-label": "Back", style: { position: "absolute", left: 0, background: "transparent", border: "none", cursor: "pointer", padding: 4, display: "flex", alignItems: "center", color: colors.textPrimary }, children: jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: jsx("path", { d: "M12 4L6 10L12 16", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), jsx("h2", { className: "absdk-predicate-signin-modal__title", style: { margin: 0, fontSize: isMobile ? 22 : 24, fontWeight: 600, lineHeight: 1.4, textAlign: "center" }, children: title })] }), jsx("div", { className: "absdk-predicate-signin-modal__content", style: { width: "100%", display: "flex", flexDirection: "column", gap: 12, alignItems: "center" }, children }), footer] }) });
233
227
  };
234
- var SignInWithEmailSection = () => {
228
+ var EmailIcon = () => jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [jsx("path", { d: "M3 4h14c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2H3c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }), jsx("path", { d: "M19 6l-9 5-9-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", fill: "none" })] });
229
+ var SignInWithEmailSection = ({ isBusy, onSendCode, onVerifyCode, onEmailChange }) => {
235
230
  const [email, setEmail] = useState("");
236
- const [partialOidcToken, setPartialOidcToken] = useState("");
237
- const [emailCode, setEmailCode] = useState("");
238
- return jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, children: [jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), style: { color: "black" } }) }), jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [jsx("input", { type: "text", className: "absdk-predicate-signin-modal__email-code-input", style: { color: "black" }, value: emailCode, placeholder: "emailCode", onChange: (e) => setEmailCode(e.target.value) }), " "] }), jsx("button", { disabled: !email, onClick: async () => {
239
- const { OidcAuth } = await loadOidcAuth();
240
- const { loginByEmail } = OidcAuth({
241
- stage: "dev",
242
- xClientId: clientIds.x ?? "",
243
- googleClientId: clientIds.google ?? ""
244
- });
245
- const { partialOidcToken: partialOidcToken2 } = await loginByEmail(email);
246
- setPartialOidcToken(partialOidcToken2);
247
- }, children: "send code" }), jsx("button", { disabled: !partialOidcToken || !emailCode, onClick: async () => {
248
- const oidcToken = `${partialOidcToken}${emailCode}`;
249
- const { default: WalletAccount2 } = await loadWalletAccount();
250
- await WalletAccount2.getInstance(oidcToken);
251
- }, children: "sign in" })] });
252
- };
253
- var SignInModalSocialSection = ({ id, socialProviders, isBusy, loadingProvider, onSocialClick }) => jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, id, className: "absdk-predicate-signin-modal__social", children: [jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: socialProviders.map((provider) => {
254
- const isLoading = loadingProvider === provider.id;
255
- return jsxs("button", { id: `absdk-predicate-signin-modal-social-provider-${provider.id}`, className: `absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--${provider.id}`, type: "button", disabled: isBusy, onClick: () => onSocialClick(provider.id), style: {
231
+ const [code, setCode] = useState("");
232
+ const [step, setStep] = useState("email");
233
+ const [loading, setLoading] = useState(false);
234
+ const handleEmailChange = (value) => {
235
+ setEmail(value);
236
+ onEmailChange?.(value);
237
+ };
238
+ const handleSendCode = async () => {
239
+ if (!email || loading)
240
+ return;
241
+ setLoading(true);
242
+ try {
243
+ await onSendCode(email);
244
+ setStep("code");
245
+ } catch (error) {
246
+ console.error("Send code failed:", error);
247
+ } finally {
248
+ setLoading(false);
249
+ }
250
+ };
251
+ const handleVerifyCode = async () => {
252
+ if (!code || loading)
253
+ return;
254
+ setLoading(true);
255
+ try {
256
+ await onVerifyCode(code);
257
+ } catch (error) {
258
+ console.error("Verify code failed:", error);
259
+ setLoading(false);
260
+ }
261
+ };
262
+ if (step === "code") {
263
+ return jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 16 }, children: [jsx("input", { type: "text", placeholder: "Enter verification code", value: code, onChange: (e) => setCode(e.target.value), onKeyDown: (e) => e.key === "Enter" && handleVerifyCode(), disabled: isBusy || loading, style: {
264
+ width: "100%",
265
+ height: 48,
266
+ borderRadius: radii.md,
267
+ border: `1px solid ${colors.border}`,
268
+ background: colors.card,
269
+ color: colors.textPrimary,
270
+ fontSize: 16,
271
+ padding: "0 16px",
272
+ fontFamily: fonts.family,
273
+ outline: "none"
274
+ } }), jsxs("button", { onClick: handleVerifyCode, disabled: !code || isBusy || loading, style: {
275
+ width: "100%",
276
+ height: 48,
277
+ borderRadius: radii.pill,
278
+ border: `1px solid ${colors.border}`,
279
+ background: "transparent",
280
+ display: "flex",
281
+ alignItems: "center",
282
+ justifyContent: "center",
283
+ gap: 12,
284
+ cursor: isBusy || loading || !code ? "not-allowed" : "pointer",
285
+ opacity: isBusy || loading || !code ? 0.5 : 1
286
+ }, children: [loading ? jsx(SpinnerIcon, {}) : jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, color: colors.textPrimary, fontFamily: fonts.family }, children: loading ? "Verifying..." : "Verify Code" })] }), jsx("button", { onClick: () => setStep("email"), disabled: isBusy || loading, style: {
287
+ background: "transparent",
288
+ border: "none",
289
+ color: colors.textSecondary,
290
+ fontSize: 14,
291
+ cursor: "pointer",
292
+ fontFamily: fonts.family
293
+ }, children: "Back to email" })] });
294
+ }
295
+ return jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 16 }, children: [jsx("input", { type: "email", placeholder: "Enter your email", value: email, onChange: (e) => handleEmailChange(e.target.value), onKeyDown: (e) => e.key === "Enter" && handleSendCode(), disabled: isBusy || loading, style: {
296
+ width: "100%",
297
+ height: 48,
298
+ borderRadius: radii.md,
299
+ border: `1px solid ${colors.border}`,
300
+ background: colors.card,
301
+ color: colors.textPrimary,
302
+ fontSize: 16,
303
+ padding: "0 16px",
304
+ fontFamily: fonts.family,
305
+ outline: "none"
306
+ } }), jsxs("button", { onClick: handleSendCode, disabled: !email || isBusy || loading, style: {
256
307
  width: "100%",
257
308
  height: 48,
258
309
  borderRadius: radii.pill,
@@ -262,13 +313,30 @@ var SignInModalSocialSection = ({ id, socialProviders, isBusy, loadingProvider,
262
313
  alignItems: "center",
263
314
  justifyContent: "center",
264
315
  gap: 12,
265
- cursor: isBusy ? "wait" : "pointer",
266
- padding: 12,
267
- boxSizing: "border-box",
268
- opacity: isLoading ? 0.6 : isBusy ? 0.8 : 1,
269
- transition: "opacity .15s"
270
- }, children: [isLoading ? jsx(SpinnerIcon, {}) : provider.icon, jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: isLoading ? "Signing in..." : provider.label })] }, provider.id);
271
- }) }), typeof window !== "undefined" && window.location.href.indexOf("emailSignIn") !== -1 && jsx(SignInWithEmailSection, {}), jsxs("div", { style: { display: "flex", alignItems: "center", gap: 20, width: "100%" }, children: [jsx("div", { style: { flex: 1, height: 1, background: colors.border } }), jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors.textPrimary, opacity: 0.4, whiteSpace: "nowrap" }, children: "Or connect a wallet" }), jsx("div", { style: { flex: 1, height: 1, background: colors.border } })] })] });
316
+ cursor: isBusy || loading || !email ? "not-allowed" : "pointer",
317
+ opacity: isBusy || loading || !email ? 0.5 : 1
318
+ }, children: [loading ? jsx(SpinnerIcon, {}) : jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, color: colors.textPrimary, fontFamily: fonts.family }, children: loading ? "Sending..." : "Continue with Email" })] })] });
319
+ };
320
+ var socialButtonStyle = (isBusy, isLoading) => ({
321
+ width: "100%",
322
+ height: 48,
323
+ borderRadius: radii.pill,
324
+ border: `1px solid ${colors.border}`,
325
+ background: "transparent",
326
+ display: "flex",
327
+ alignItems: "center",
328
+ justifyContent: "center",
329
+ gap: 12,
330
+ cursor: isBusy ? "wait" : "pointer",
331
+ padding: 12,
332
+ boxSizing: "border-box",
333
+ opacity: isLoading ? 0.6 : isBusy ? 0.8 : 1,
334
+ transition: "opacity .15s"
335
+ });
336
+ var SignInModalSocialSection = ({ id, socialProviders, isBusy, loadingProvider, onSocialClick, onEmailClick }) => jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: 24 }, id, className: "absdk-predicate-signin-modal__social", children: [jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [socialProviders.map((provider) => {
337
+ const isLoading = loadingProvider === provider.id;
338
+ return jsxs("button", { id: `absdk-predicate-signin-modal-social-provider-${provider.id}`, className: `absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--${provider.id}`, type: "button", disabled: isBusy, onClick: () => onSocialClick(provider.id), style: socialButtonStyle(isBusy, isLoading), children: [isLoading ? jsx(SpinnerIcon, {}) : provider.icon, jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: isLoading ? "Signing in..." : provider.label })] }, provider.id);
339
+ }), onEmailClick && jsxs("button", { id: "absdk-predicate-signin-modal-social-provider-email", className: "absdk-predicate-signin-modal__social-button absdk-predicate-signin-modal__social-button--email", type: "button", disabled: isBusy, onClick: onEmailClick, style: socialButtonStyle(isBusy, false), children: [jsx(EmailIcon, {}), jsx("span", { style: { fontSize: 16, fontWeight: 500, lineHeight: 1.4, color: colors.textPrimary, fontFamily: fonts.family }, children: "Continue with Email" })] })] }), jsxs("div", { style: { display: "flex", alignItems: "center", gap: 20, width: "100%" }, children: [jsx("div", { style: { flex: 1, height: 1, background: colors.border } }), jsx("span", { style: { fontSize: 14, lineHeight: 1.4, color: colors.textPrimary, opacity: 0.4, whiteSpace: "nowrap" }, children: "Or connect a wallet" }), jsx("div", { style: { flex: 1, height: 1, background: colors.border } })] })] });
272
340
  var SignInModalWalletGrid = ({ wallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick, onToggleExpanded }) => {
273
341
  const isMobile = useIsMobileViewport();
274
342
  return jsxs("div", { className: "absdk-predicate-signin-modal__wallets", style: { width: "100%", display: "flex", flexDirection: "column", gap: 8, alignItems: "center", paddingTop: 12 }, children: [jsx("div", { className: "absdk-predicate-signin-modal__wallet-grid", style: { width: "100%", display: "flex", flexWrap: "wrap", gap: "14px 0" }, children: wallets.map((wallet) => jsxs("button", { id: `absdk-predicate-signin-modal-wallet-${wallet.id}`, className: `absdk-predicate-signin-modal__wallet-button absdk-predicate-signin-modal__wallet-button--${wallet.id}`, type: "button", disabled: isBusy, onClick: () => onWalletClick(wallet.id), style: {
@@ -293,6 +361,90 @@ var SignInModalWalletGrid = ({ wallets, isBusy, loadingWalletId, expanded, showE
293
361
  }, children: jsx(ExpandIcon, { expanded }) })] });
294
362
  };
295
363
  var SignInModalFooter = ({ privacyPolicyUrl, termsOfUseUrl }) => jsx("div", { className: "absdk-predicate-signin-modal__footer", style: { padding: "12px 0", display: "flex", justifyContent: "center", width: "100%" }, children: jsxs("p", { style: { margin: 0, fontSize: 14, lineHeight: 1.4, color: colors.textSecondary, fontFamily: fonts.family, textAlign: "center" }, children: ["By continuing, I agree to the", " ", jsx("a", { href: privacyPolicyUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }), " ", "and", " ", jsx("a", { href: termsOfUseUrl, style: { color: colors.textPrimary, textDecoration: "underline" }, target: "_blank", rel: "noopener noreferrer", children: "Terms of Use" })] }) });
364
+
365
+ // ../oidc-auth/dist/index.js
366
+ var x = 60;
367
+ var S = { prod: "prod", dev: "gamma" };
368
+ var w = { prod: { SignerApiRoot: "https://prod.signer.cubist.dev" }, gamma: { SignerApiRoot: "https://gamma.signer.cubist.dev" } };
369
+ var C = L("CUBE_SIGNER_ORG_ID");
370
+ var v = getEnv("RELAY_ORIGIN");
371
+ function L(e) {
372
+ return getEnv(e) || "";
373
+ }
374
+ var f = ({ url: e, name: l, width: r, height: t }) => {
375
+ let i = (window.innerHeight - (t || 400)) / 2 + window.screenY, a = (window.innerWidth - (r || 400)) / 2 + window.screenX;
376
+ try {
377
+ let s = window.open(e, l, `dialog=yes,top=${i}px,left=${a},width=${r !== void 0 ? r : 400}px,height=${t !== void 0 ? t : 600}px`);
378
+ return s || null;
379
+ } catch (s) {
380
+ return console.error("Failed to open window:", s), null;
381
+ }
382
+ };
383
+ var R = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
384
+ function $(e) {
385
+ if (e in w) return w[e].SignerApiRoot;
386
+ if (/^https?:\/\//.test(e)) return e.replace(/\/$/, "");
387
+ throw new Error(`Unsupported CubeSigner env: ${e}`);
388
+ }
389
+ var O = async (e, l, r) => {
390
+ let t = await fetch(`${$(l)}/v0/org/${encodeURIComponent(r)}/oidc/email-otp`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: e }) });
391
+ if (!t.ok) {
392
+ let a = await t.text().catch(() => "");
393
+ throw new Error(a ? `Email login failed (${t.status}): ${a}` : `Email login failed (${t.status})`);
394
+ }
395
+ let i = await t.json();
396
+ if (!i.partial_token) throw new Error("Email login response missing partial_token");
397
+ return i.partial_token;
398
+ };
399
+ var Y = ({ stage: e, xClientId: l, googleClientId: r }) => {
400
+ let t = window.location.origin || v;
401
+ if (!t) throw new Error("Invalid stage");
402
+ let i = `${t}/relay/x`, a = `${t}/relay/google`, s = S[e], E = C;
403
+ if (!E) throw new Error("Invalid cube stage");
404
+ let y = (o, g = 12e4) => new Promise((c, n) => {
405
+ if (!o) {
406
+ n(new Error("Failed to open popup"));
407
+ return;
408
+ }
409
+ let m = setTimeout(() => {
410
+ o.close(), n(new Error("Login timeout"));
411
+ }, g), d = async (p) => {
412
+ if (p.origin !== t || p.data.action !== "login") return;
413
+ let { data: I } = p.data;
414
+ try {
415
+ let { oidcToken: u = "", error: b } = I || {};
416
+ if (b) {
417
+ clearTimeout(m), window.removeEventListener("message", d), o.close(), n(new Error(String(b)));
418
+ return;
419
+ }
420
+ u && (clearTimeout(m), window.removeEventListener("message", d), o.close(), c(u));
421
+ } catch (u) {
422
+ clearTimeout(m), window.removeEventListener("message", d), o.close(), n(u);
423
+ }
424
+ };
425
+ window.addEventListener("message", d);
426
+ let T = setInterval(() => {
427
+ o.closed && (clearTimeout(m), clearInterval(T), window.removeEventListener("message", d), n(new Error("Login cancelled by user")));
428
+ }, 400);
429
+ });
430
+ return { loginByGoogle: async () => {
431
+ let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: r }, c = `${a}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "Google login" });
432
+ return await y(n);
433
+ }, loginByX: async () => {
434
+ let g = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: l }, c = `${i}?${new URLSearchParams(g).toString()}`, n = f({ url: c, name: "X login" });
435
+ return await y(n);
436
+ }, loginByEmail: async (o) => {
437
+ if (!R(o)) throw new Error("Invalid email");
438
+ return { partialOidcToken: await O(o, s, E), lifeTime: x };
439
+ } };
440
+ };
441
+ var emailOtpCache = /* @__PURE__ */ new Map();
442
+ function clearEmailOtpCache(email) {
443
+ if (email)
444
+ emailOtpCache.delete(email);
445
+ else
446
+ emailOtpCache.clear();
447
+ }
296
448
  var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _onGoogleLogin, onTwitterLogin: _onTwitterLogin, onCubeSignerSession: _onCubeSignerSession, onWalletConnected, onSocialLogin: _onSocialLogin, onWalletSelect }) => {
297
449
  const [expanded, setExpanded] = useState(false);
298
450
  const [loadingProvider, setLoadingProvider] = useState(null);
@@ -303,14 +455,10 @@ var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _
303
455
  const showExpandToggle = resolvedWallets.length > initialVisibleCount;
304
456
  const visibleWallets = expanded ? resolvedWallets : resolvedWallets.slice(0, initialVisibleCount);
305
457
  const isBusy = !!loadingProvider || !!loadingWalletId;
306
- async function loadOidcAuth2() {
307
- return import('./dist-Q2PDXT2F.js');
308
- }
309
458
  const handleSocialClick = async (providerId) => {
310
459
  setLoadingProvider(providerId);
311
460
  const cfg = getSDKConfig();
312
- const { OidcAuth } = await loadOidcAuth2();
313
- const { loginByX, loginByGoogle } = OidcAuth({
461
+ const { loginByX, loginByGoogle } = Y({
314
462
  stage,
315
463
  xClientId: cfg.twitterClientId ?? clientIds.x ?? "",
316
464
  googleClientId: cfg.googleClientId ?? clientIds.google ?? ""
@@ -328,6 +476,21 @@ var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _
328
476
  return oidcToken;
329
477
  }
330
478
  };
479
+ const handleEmailSendCode = async (email) => {
480
+ const cached = emailOtpCache.get(email);
481
+ if (cached && cached.expiresAt > Date.now()) {
482
+ return cached.partialOidcToken;
483
+ }
484
+ const cfg = getSDKConfig();
485
+ const { loginByEmail } = Y({
486
+ stage,
487
+ xClientId: cfg.twitterClientId ?? clientIds.x ?? "",
488
+ googleClientId: cfg.googleClientId ?? clientIds.google ?? ""
489
+ });
490
+ const { partialOidcToken } = await loginByEmail(email);
491
+ emailOtpCache.set(email, { partialOidcToken, expiresAt: Date.now() + 6e4 });
492
+ return partialOidcToken;
493
+ };
331
494
  const clearSocialLoading = () => setLoadingProvider(null);
332
495
  const handleWalletClick = async (walletId) => {
333
496
  if (isBusy)
@@ -362,6 +525,7 @@ var useSignInModalController = ({ wallets, initialVisibleCount, onGoogleLogin: _
362
525
  showExpandToggle,
363
526
  isBusy,
364
527
  handleSocialClick,
528
+ handleEmailSendCode,
365
529
  handleWalletClick,
366
530
  clearSocialLoading,
367
531
  toggleExpanded: () => setExpanded((value) => !value)
@@ -417,8 +581,8 @@ var Toast = ({ message, variant = "info", duration, onClose }) => {
417
581
  };
418
582
 
419
583
  // ../sign_in_sdk/dist/ui/SignInModal.js
420
- async function loadWalletAccount2() {
421
- return import('./account-6PGNCFOX.js');
584
+ async function loadWalletAccount() {
585
+ return import('./account-SQGJZOF5.js');
422
586
  }
423
587
  var SOCIAL_ADAPTER_ID = "cubist";
424
588
  function persistSocialAdapterId() {
@@ -428,14 +592,18 @@ function persistSocialAdapterId() {
428
592
  } catch {
429
593
  }
430
594
  }
431
- var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wallets, initialVisibleCount, privacyPolicyUrl = "#", termsOfUseUrl = "#", onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess }) => {
595
+ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wallets, initialVisibleCount, emailLogin, privacyPolicyUrl = "#", termsOfUseUrl = "#", onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess }) => {
432
596
  const sdkConfig = getSDKConfig();
433
597
  const effectiveSocialProviders = resolveSocialProviders(socialProviders ?? sdkConfig.signIn?.socialProviders);
434
598
  const effectiveWallets = wallets ?? sdkConfig.signIn?.wallets;
435
599
  const effectiveInitialVisibleCount = initialVisibleCount ?? sdkConfig.signIn?.initialVisibleCount ?? 5;
600
+ const effectiveEmailLogin = emailLogin ?? sdkConfig.signIn?.emailLogin ?? false;
436
601
  const [toastError, setToastError] = useState(null);
437
602
  const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
438
- const { expanded, loadingProvider, loadingWalletId, visibleWallets, showExpandToggle, isBusy, handleSocialClick, handleWalletClick, clearSocialLoading, toggleExpanded } = useSignInModalController({
603
+ const [view, setView] = useState("main");
604
+ const emailPartialTokenRef = useRef("");
605
+ const emailRef = useRef("");
606
+ const { expanded, loadingProvider, loadingWalletId, visibleWallets, showExpandToggle, isBusy, handleSocialClick, handleEmailSendCode, handleWalletClick, clearSocialLoading, toggleExpanded } = useSignInModalController({
439
607
  wallets: effectiveWallets,
440
608
  initialVisibleCount: effectiveInitialVisibleCount,
441
609
  onGoogleLogin,
@@ -445,11 +613,56 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
445
613
  onSocialLogin,
446
614
  onWalletSelect
447
615
  });
448
- return jsxs(SignInModalFrame, { id: "absdk-predicate-signin-modal-frame", title, onClose: onDismiss, footer: jsx(SignInModalFooter, { privacyPolicyUrl, termsOfUseUrl }), children: [toastError && jsx(Toast, { message: toastError, variant: "error", duration: 5e3, onClose: () => setToastError(null) }), jsx(SignInModalSocialSection, { id: "absdk-predicate-signin-modal-social", socialProviders: effectiveSocialProviders, isBusy: isBusy || !!socialLoadingProvider, loadingProvider: loadingProvider ?? socialLoadingProvider, onSocialClick: async (providerId) => {
616
+ return jsxs(SignInModalFrame, { id: "absdk-predicate-signin-modal-frame", title: view === "email" ? "Sign in with Email" : title, onClose: onDismiss, onBack: view === "email" ? () => setView("main") : void 0, footer: jsx(SignInModalFooter, { privacyPolicyUrl, termsOfUseUrl }), children: [toastError && jsx(Toast, { message: toastError, variant: "error", duration: 5e3, onClose: () => setToastError(null) }), view === "email" ? jsx(SignInWithEmailSection, { isBusy: false, onSendCode: async (email) => {
617
+ emailRef.current = email;
618
+ emailPartialTokenRef.current = await handleEmailSendCode(email);
619
+ }, onEmailChange: (email) => {
620
+ clearEmailOtpCache(emailRef.current);
621
+ emailRef.current = email;
622
+ }, onVerifyCode: async (code) => {
623
+ const oidcToken = `${emailPartialTokenRef.current}${code}`;
624
+ emailPartialTokenRef.current = "";
625
+ sessionStore.clearSession();
626
+ try {
627
+ const { default: WalletAccount2 } = await loadWalletAccount();
628
+ WalletAccount2.clearInstance();
629
+ const walletAccount = await WalletAccount2.getInstance(oidcToken);
630
+ const cubeSignerSession = walletAccount.getCubeSignerSession();
631
+ onCubeSignerSession?.(cubeSignerSession);
632
+ cache_exports.set("oidcToken", oidcToken, false);
633
+ const [address] = await walletAccount.eth_accounts();
634
+ if (!address)
635
+ throw new Error("Email wallet did not return an account");
636
+ const chainId = await walletAccount.eth_chainId();
637
+ const chain = getSupportedChainFromEvmChainId(chainId);
638
+ const capabilityPolicy = sdkConfig.cubeSigner?.defaultSessionPolicy ? createSessionCapabilityPolicy(sdkConfig.cubeSigner.defaultSessionPolicy) : void 0;
639
+ const session = {
640
+ address,
641
+ chain,
642
+ provider: walletAccount,
643
+ walletType: "social",
644
+ authSource: "email",
645
+ sessionId: `email:${address.toLowerCase()}`,
646
+ expiresAt: capabilityPolicy?.expiresAt,
647
+ capabilities: CUBIST_CAPABILITIES,
648
+ sessionData: cubeSignerSession.sessionData,
649
+ chainContext: createChainContext(chain),
650
+ capabilityPolicy,
651
+ userInfo: cubeSignerSession.userInfo
652
+ };
653
+ persistSocialAdapterId();
654
+ sessionStore.setSession(session);
655
+ clearEmailOtpCache(emailRef.current);
656
+ onSuccess?.(session);
657
+ } catch (error) {
658
+ setToastError(error?.message ?? "Email login failed, please try again");
659
+ throw error;
660
+ }
661
+ } }) : jsxs(Fragment, { children: [jsx(SignInModalSocialSection, { id: "absdk-predicate-signin-modal-social", socialProviders: effectiveSocialProviders, isBusy: isBusy || !!socialLoadingProvider, loadingProvider: loadingProvider ?? socialLoadingProvider, onEmailClick: effectiveEmailLogin ? () => setView("email") : void 0, onSocialClick: async (providerId) => {
449
662
  setSocialLoadingProvider(providerId);
450
663
  sessionStore.clearSession();
451
664
  try {
452
- const { default: WalletAccount2 } = await loadWalletAccount2();
665
+ const { default: WalletAccount2 } = await loadWalletAccount();
453
666
  WalletAccount2.clearInstance();
454
667
  const oidcToken = await handleSocialClick(providerId);
455
668
  if (!oidcToken) {
@@ -461,9 +674,8 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
461
674
  onCubeSignerSession?.(cubeSignerSession);
462
675
  cache_exports.set("oidcToken", oidcToken, false);
463
676
  const [address] = await walletAccount.eth_accounts();
464
- if (!address) {
677
+ if (!address)
465
678
  throw new Error("Social wallet did not return an account");
466
- }
467
679
  const chainId = await walletAccount.eth_chainId();
468
680
  const chain = getSupportedChainFromEvmChainId(chainId);
469
681
  const authSource = providerId === "x" ? "twitter" : providerId;
@@ -487,12 +699,11 @@ var SignInModal = ({ title = "Welcome to PredicateMarket", socialProviders, wall
487
699
  onSuccess?.(session);
488
700
  } catch (error) {
489
701
  setToastError(error?.message ?? "Failed to get wallet account, please try again");
490
- return;
491
702
  } finally {
492
703
  setSocialLoadingProvider(null);
493
704
  clearSocialLoading();
494
705
  }
495
- } }), jsx(SignInModalWalletGrid, { wallets: visibleWallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick: handleWalletClick, onToggleExpanded: toggleExpanded })] });
706
+ } }), jsx(SignInModalWalletGrid, { wallets: visibleWallets, isBusy, loadingWalletId, expanded, showExpandToggle, onWalletClick: handleWalletClick, onToggleExpanded: toggleExpanded })] })] });
496
707
  };
497
708
 
498
709
  // src/ui/theme.ts
@@ -1518,7 +1729,7 @@ function getTokenAddressForChain(chains, chainId, tokenSymbol) {
1518
1729
  const chain = chains.find((c) => c.chain_id === chainId);
1519
1730
  return chain?.tokens.find((t) => t.symbol === tokenSymbol)?.address;
1520
1731
  }
1521
- var FUNDING_TOKEN_SYMBOL = getEnv("FUNDING_TOKEN_SYMBOL");
1732
+ var FUNDING_TOKEN_SYMBOL = getEnv$1("FUNDING_TOKEN_SYMBOL");
1522
1733
  var DepositModal = ({
1523
1734
  token,
1524
1735
  chain,
@@ -1635,9 +1846,6 @@ var DepositModal = ({
1635
1846
  onShowToast("Transfer confirmed");
1636
1847
  }
1637
1848
  }, [txHash, chain, onShowToast]);
1638
- if (!session) {
1639
- return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Deposit", onSignIn, onClose });
1640
- }
1641
1849
  const goToEntry = () => {
1642
1850
  setView("entry");
1643
1851
  onBack?.();
@@ -1652,6 +1860,9 @@ var DepositModal = ({
1652
1860
  const t = setTimeout(() => setCopySuccessMessage(null), 2e3);
1653
1861
  return () => clearTimeout(t);
1654
1862
  }, [copySuccessMessage]);
1863
+ if (!session) {
1864
+ return /* @__PURE__ */ jsx(LoginRequiredOverlay, { title: "Deposit", onSignIn, onClose });
1865
+ }
1655
1866
  return /* @__PURE__ */ jsxs(
1656
1867
  ModalFrame2,
1657
1868
  {
@@ -2230,7 +2441,7 @@ function CopyIcon2() {
2230
2441
  /* @__PURE__ */ jsx("path", { className: "absdk-predicate-withdraw-modal__copy-icon-path", d: "M3 11V3a1 1 0 0 1 1-1h8", stroke: "currentColor", strokeWidth: "1.2", fill: "none" })
2231
2442
  ] });
2232
2443
  }
2233
- var FUNDING_TOKEN_SYMBOL2 = getEnv("FUNDING_TOKEN_SYMBOL");
2444
+ var FUNDING_TOKEN_SYMBOL2 = getEnv$1("FUNDING_TOKEN_SYMBOL");
2234
2445
  function chainsToTokenOptions2(chains) {
2235
2446
  const bySymbol = /* @__PURE__ */ new Map();
2236
2447
  for (const c of chains) {
@@ -2328,6 +2539,7 @@ var WithdrawModal = ({
2328
2539
  chain,
2329
2540
  amount = "",
2330
2541
  balance,
2542
+ balanceMax,
2331
2543
  status = "idle",
2332
2544
  receiveAmount: receiveAmountProp,
2333
2545
  txHash,
@@ -2598,7 +2810,7 @@ var WithdrawModal = ({
2598
2810
  const handleAmountChange = useCallback(
2599
2811
  (e) => {
2600
2812
  const raw = e.target.value;
2601
- const maxNum = balance ? parseBalanceNumber(balance) : null;
2813
+ const maxNum = parseBalanceNumber(balanceMax ?? balance ?? "");
2602
2814
  if (maxNum != null && raw !== "" && raw !== ".") {
2603
2815
  const num = Number(raw);
2604
2816
  if (!Number.isNaN(num) && num > maxNum) {
@@ -3350,7 +3562,7 @@ var SubmitButton = ({ id, className, disabled, status, onClick }) => {
3350
3562
 
3351
3563
  // src/react.ts
3352
3564
  async function loadWalletAccountModule() {
3353
- return import('./account-6PGNCFOX.js');
3565
+ return import('./account-SQGJZOF5.js');
3354
3566
  }
3355
3567
  var WalletAccount = {
3356
3568
  async getInstance(oidcToken) {
@@ -34,6 +34,8 @@ function readProcessEnvStatic(key) {
34
34
  process.env.NEXT_PUBLIC_CUBE_KEEPALIVE_INTERVAL_MS,
35
35
  process.env.CUBE_KEEPALIVE_INTERVAL_MS
36
36
  );
37
+ case "FUNDING_CHAIN_ID":
38
+ return pick(process.env.NEXT_PUBLIC_FUNDING_CHAIN_ID, process.env.FUNDING_CHAIN_ID) || "3131";
37
39
  case "FUNDING_TOKEN_SYMBOL":
38
40
  return pick(process.env.NEXT_PUBLIC_FUNDING_TOKEN_SYMBOL, process.env.FUNDING_TOKEN_SYMBOL) || "USDT";
39
41
  default:
package/dist/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { C as ChainInfo, a as CustodyAdapter, D as DepositAddressResult, M as MarketDataProvider, b as ModalController, Q as QuoteRequest, c as QuoteResult, T as TokenInfo } from './types-BFidNjd9.js';
2
2
  import { CubeSignerConfig } from '@ab-org/sdk-core/social/auth';
3
- import { S as SignInUiConfig } from './signInTypes.d-DESvmgWG.js';
3
+ import { S as SignInUiConfig } from './signInTypes.d-Cr3RzByV.js';
4
4
  import { WalletSession } from '@ab-org/sdk-core';
5
5
  import 'react';
6
6
 
@@ -26,6 +26,7 @@ declare function getFixedAuthConfig(): Partial<SDKConfig>;
26
26
  interface PredicateSDKConfig extends Partial<SDKConfig> {
27
27
  merchantBaseUrl?: string;
28
28
  registerUser?: (oidcToken: string) => Promise<void>;
29
+ onSessionExpired?: (session: WalletSession) => void;
29
30
  }
30
31
  declare function initSDK(config?: PredicateSDKConfig): void;
31
32
  declare function getSDKConfig(): Readonly<SDKConfig>;
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- export { tryAutoReconnect } from './chunk-63AEVWHE.js';
2
- export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, getChainInfo, getFundingTokenAddress } from './chunk-NTFBZNCV.js';
1
+ export { tryAutoReconnect } from './chunk-GIPWCNYS.js';
2
+ export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, getChainInfo, getFundingTokenAddress } from './chunk-6AZQBNMY.js';
3
3
  export { getExplorerUrl } from './chunk-XB2DFS2W.js';
4
- export { getFixedAuthConfig, getSDKConfig, initSDK } from './chunk-BWKDIOBB.js';
5
- export { getEnv } from './chunk-CGP7TSLF.js';
4
+ export { getFixedAuthConfig, getSDKConfig, initSDK } from './chunk-E3UPFA4K.js';
5
+ export { getEnv } from './chunk-R2D3SM4S.js';
6
6
  import './chunk-UPMVYXZ6.js';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, EvmChainInfo, PredicateSDKConfig, SDKConfig, getChainInfo, getEnv, getExplorerUrl, getFixedAuthConfig, getFundingTokenAddress, getSDKConfig, initSDK, tryAutoReconnect } from './core.js';
2
2
  export { notifyTwitterCallback } from './auth.js';
3
- export { G as GoogleCredential, S as SignInUiConfig, a as SocialProvider, T as TwitterAuthResult, W as WalletItem } from './signInTypes.d-DESvmgWG.js';
3
+ export { G as GoogleCredential, S as SignInUiConfig, a as SocialProvider, T as TwitterAuthResult, W as WalletItem } from './signInTypes.d-Cr3RzByV.js';
4
4
  export { DepositDetailsPanel, DepositDetailsPanelProps, DepositModal, DepositModalProps, DropdownField, DropdownFieldProps, SelectOption, SignInModal, SignInModalProps, Toast, WalletAccount, WalletOption, WalletSelectionModal, WalletSelectionModalProps, WithdrawModal, WithdrawModalProps, WithdrawUiStatus, clearSocialAccountInstance } from './react.js';
5
5
  export { DepositController, DepositModalConfig, DepositStatus, Erc20BalanceResult, FundingTokenBalanceOptions, FundingWithdrawExecutorOptions, PredicateMarketPolicyAdapterOptions, WithdrawController, WithdrawExecutor, WithdrawModalConfig, WithdrawRequest, WithdrawResult, WithdrawStatus, WithdrawTxRequest, createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './merchant.js';
6
6
  export { A as ApiResponse, C as ChainData, a as ChainsResponseData, b as CreateOrderRequest, c as CreateOrderResponseData, D as DepositOrderResponseData, d as DepositOrderStatus, M as MerchantApiConfig, N as NativeSwapPayload, P as PaymentPairData, e as PaymentSessionResponseData, f as PaymentSessionStatus, g as PlatformRegisterRequest, h as PlatformRegisterResponseData, Q as QuoteDirection, i as QuoteResponseData, T as TokenData, W as WithdrawOrderResponseData, j as WithdrawOrderStatus, k as configureMerchantApi, l as createOrder, m as getChains, n as getDepositOrder, o as getMerchantApiClient, p as getWithdrawOrder, q as quote, r as registerPlatform } from './api-DyQAYQ0i.js';
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  export { notifyTwitterCallback } from './chunk-ZS6FNG2D.js';
2
- export { tryAutoReconnect } from './chunk-63AEVWHE.js';
3
- export { createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './chunk-UMSH3Z43.js';
4
- export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, getChainInfo, getFundingTokenAddress } from './chunk-NTFBZNCV.js';
5
- export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IVPLOLGZ.js';
2
+ export { tryAutoReconnect } from './chunk-GIPWCNYS.js';
3
+ export { createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './chunk-4XO4Z5TC.js';
4
+ export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, getChainInfo, getFundingTokenAddress } from './chunk-6AZQBNMY.js';
5
+ export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IOAGWRWJ.js';
6
6
  export { getExplorerUrl } from './chunk-XB2DFS2W.js';
7
- export { configureMerchantApi, createOrder, getChains, getDepositOrder, getMerchantApiClient, getWithdrawOrder, quote, registerPlatform } from './chunk-HNL3SLGU.js';
8
- export { getFixedAuthConfig, getSDKConfig, initSDK } from './chunk-BWKDIOBB.js';
9
- export { getEnv } from './chunk-CGP7TSLF.js';
10
- import './chunk-SV3NR2LW.js';
7
+ export { configureMerchantApi, createOrder, getChains, getDepositOrder, getMerchantApiClient, getWithdrawOrder, quote, registerPlatform } from './chunk-E65LLR2W.js';
8
+ export { getFixedAuthConfig, getSDKConfig, initSDK } from './chunk-E3UPFA4K.js';
9
+ export { getEnv } from './chunk-R2D3SM4S.js';
10
+ import './chunk-BDZKYFL5.js';
11
11
  import './chunk-UPMVYXZ6.js';
12
- import './chunk-YX56ZGDB.js';
@@ -77,6 +77,7 @@ declare function createMarketDataProvider(): MarketDataProvider;
77
77
  interface Erc20BalanceResult {
78
78
  raw: bigint;
79
79
  formatted: string;
80
+ fullPrecision: string;
80
81
  symbol: string;
81
82
  }
82
83
  /**
package/dist/merchant.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './chunk-UMSH3Z43.js';
2
- import './chunk-NTFBZNCV.js';
3
- export { configureMerchantApi, createOrder, getChains, getDepositOrder, getMerchantApiClient, getWithdrawOrder, quote, registerPlatform } from './chunk-HNL3SLGU.js';
4
- import './chunk-CGP7TSLF.js';
1
+ export { createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, isUsdtWithdrawDirect, parseUnits } from './chunk-4XO4Z5TC.js';
2
+ import './chunk-6AZQBNMY.js';
3
+ export { configureMerchantApi, createOrder, getChains, getDepositOrder, getMerchantApiClient, getWithdrawOrder, quote, registerPlatform } from './chunk-E65LLR2W.js';
4
+ import './chunk-R2D3SM4S.js';
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
2
- import { a as SocialProvider, W as WalletItem, G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-DESvmgWG.js';
2
+ import { a as SocialProvider, W as WalletItem, G as GoogleCredential, T as TwitterAuthResult } from './signInTypes.d-Cr3RzByV.js';
3
3
  import { WalletSession, WalletProviderRequest } from '@ab-org/sdk-core';
4
4
  import { CubeSignerSession } from '@ab-org/sdk-core/social/auth';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -12,6 +12,7 @@ interface SignInModalProps {
12
12
  socialProviders?: SocialProvider[];
13
13
  wallets?: WalletItem[];
14
14
  initialVisibleCount?: number;
15
+ emailLogin?: boolean;
15
16
  privacyPolicyUrl?: string;
16
17
  termsOfUseUrl?: string;
17
18
  onGoogleLogin?: (credential: GoogleCredential) => void;
@@ -25,7 +26,7 @@ interface SignInModalProps {
25
26
  /** 登录成功后调用,传入 session;调用方在此回调里更新 session 并自行关闭弹窗 */
26
27
  onSuccess?: (session: WalletSession) => void;
27
28
  }
28
- declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
29
+ declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, emailLogin, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
29
30
 
30
31
  type ToastVariant = "success" | "error" | "info";
31
32
  interface ToastProps {
@@ -137,6 +138,7 @@ interface WithdrawModalProps {
137
138
  chain?: string;
138
139
  amount?: string;
139
140
  balance?: string;
141
+ balanceMax?: string;
140
142
  status?: WithdrawUiStatus;
141
143
  receiveAmount?: string;
142
144
  txHash?: string;
@@ -182,7 +184,7 @@ interface WithdrawModalProps {
182
184
  onSignIn?: () => void;
183
185
  onClose?: () => void;
184
186
  }
185
- declare const WithdrawModal: ({ address, token, tokenSymbol, chain, amount, balance, status, receiveAmount: receiveAmountProp, txHash, tokenOptions: tokenOptionsProp, chainOptions: chainOptionsProp, useMerchantApi, orderId, withdrawMode, withdrawDirectResult, feeDisplay, fundingChainId, onShowToast, onAddressChange, onTokenSelect, onChainSelect, onAmountChange, onMaxClick, onSubmit, onWithdrawCompleted, onStartAnotherWithdrawal, onSignIn, onClose, }: WithdrawModalProps) => react_jsx_runtime.JSX.Element;
187
+ declare const WithdrawModal: ({ address, token, tokenSymbol, chain, amount, balance, balanceMax, status, receiveAmount: receiveAmountProp, txHash, tokenOptions: tokenOptionsProp, chainOptions: chainOptionsProp, useMerchantApi, orderId, withdrawMode, withdrawDirectResult, feeDisplay, fundingChainId, onShowToast, onAddressChange, onTokenSelect, onChainSelect, onAmountChange, onMaxClick, onSubmit, onWithdrawCompleted, onStartAnotherWithdrawal, onSignIn, onClose, }: WithdrawModalProps) => react_jsx_runtime.JSX.Element;
186
188
 
187
189
  interface DepositDetailsPanelProps {
188
190
  address: string;
package/dist/react.js CHANGED
@@ -1,7 +1,6 @@
1
- export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IVPLOLGZ.js';
1
+ export { DepositDetailsPanel, DepositModal, DropdownField, SignInModal, Toast, WalletAccount, WalletSelectionModal, WithdrawModal, clearSocialAccountInstance } from './chunk-IOAGWRWJ.js';
2
2
  import './chunk-XB2DFS2W.js';
3
- import './chunk-HNL3SLGU.js';
4
- import './chunk-CGP7TSLF.js';
5
- import './chunk-SV3NR2LW.js';
3
+ import './chunk-E65LLR2W.js';
4
+ import './chunk-R2D3SM4S.js';
5
+ import './chunk-BDZKYFL5.js';
6
6
  import './chunk-UPMVYXZ6.js';
7
- import './chunk-YX56ZGDB.js';
@@ -17,6 +17,7 @@ interface SignInUiConfig {
17
17
  socialProviders?: SocialProvider[];
18
18
  wallets?: WalletItem[];
19
19
  initialVisibleCount?: number;
20
+ emailLogin?: boolean;
20
21
  sessionConfirmation?: {
21
22
  enabled?: boolean;
22
23
  title?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ab-org/predicate-market-sdk",
3
- "version": "2.2.0-beta.6",
3
+ "version": "2.2.0-beta.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**/*",
@@ -39,7 +39,7 @@
39
39
  "axios": "^1.13.6",
40
40
  "qrcode-generator": "^2.0.4",
41
41
  "viem": "2.21.54",
42
- "@ab-org/sdk-core": "0.3.0-beta.4"
42
+ "@ab-org/sdk-core": "0.3.0-beta.7"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": ">=18"
@@ -51,7 +51,7 @@
51
51
  "@ab-org/chains-service": "0.0.8",
52
52
  "@ab-org/oidc-auth": "0.0.16",
53
53
  "@ab-org/sign-in-sdk": "0.1.0",
54
- "@ab-org/wallet-utils": "0.0.7"
54
+ "@ab-org/wallet-utils": "0.1.0-beta.1"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "pnpm exec tsup",
@@ -1,14 +0,0 @@
1
- import { getEnv, getChainInfo } from './chunk-YX56ZGDB.js';
2
-
3
- // ../sign_in_sdk/dist/config.js
4
- var stage = getEnv("STAGE") || "dev";
5
- var clientIds = {
6
- google: getEnv("GOOGLE_CLIENT_ID"),
7
- x: getEnv("X_CLIENT_ID")
8
- };
9
- var chainConfig = {
10
- chainType: "evm",
11
- chainId: getChainInfo().chainId
12
- };
13
-
14
- export { chainConfig, clientIds, stage };
@@ -1,81 +0,0 @@
1
- import { getEnv } from './chunk-YX56ZGDB.js';
2
-
3
- // ../oidc-auth/dist/index.js
4
- var _ = { googleAuth: "ab-google-authorized", xAuth: "ab-twitter-authorized", telegramAuth: "ab-telegram-authorized" };
5
- var x = 60;
6
- var S = { prod: "prod", dev: "gamma" };
7
- var w = { prod: { SignerApiRoot: "https://prod.signer.cubist.dev" }, gamma: { SignerApiRoot: "https://gamma.signer.cubist.dev" } };
8
- var C = L("CUBE_SIGNER_ORG_ID");
9
- var v = getEnv("RELAY_ORIGIN");
10
- function L(e) {
11
- return getEnv(e) || "";
12
- }
13
- var f = ({ url: e, name: g, width: r, height: t }) => {
14
- let i = (window.innerHeight - (t || 400)) / 2 + window.screenY, a = (window.innerWidth - (r || 400)) / 2 + window.screenX;
15
- try {
16
- let s = window.open(e, g, `dialog=yes,top=${i}px,left=${a},width=${r !== void 0 ? r : 400}px,height=${t !== void 0 ? t : 600}px`);
17
- return s || null;
18
- } catch (s) {
19
- return console.error("Failed to open window:", s), null;
20
- }
21
- };
22
- var R = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
23
- function $(e) {
24
- if (e in w) return w[e].SignerApiRoot;
25
- if (/^https?:\/\//.test(e)) return e.replace(/\/$/, "");
26
- throw new Error(`Unsupported CubeSigner env: ${e}`);
27
- }
28
- var O = async (e, g, r) => {
29
- let t = await fetch(`${$(g)}/v0/org/${encodeURIComponent(r)}/oidc/email-otp`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: e }) });
30
- if (!t.ok) {
31
- let a = await t.text().catch(() => "");
32
- throw new Error(a ? `Email login failed (${t.status}): ${a}` : `Email login failed (${t.status})`);
33
- }
34
- let i = await t.json();
35
- if (!i.partial_token) throw new Error("Email login response missing partial_token");
36
- return i.partial_token;
37
- };
38
- var Y = ({ stage: e, xClientId: g, googleClientId: r }) => {
39
- let t = v;
40
- if (window.location.hostname === "localhost" && (t = window.location.origin), !t) throw new Error("Invalid stage");
41
- let i = `${t}/relay/x`, a = `${t}/relay/google`, s = S[e], E = C;
42
- if (!E) throw new Error("Invalid cube stage");
43
- let y = (o, l = 12e4) => new Promise((c, n) => {
44
- if (!o) {
45
- n(new Error("Failed to open popup"));
46
- return;
47
- }
48
- let m = setTimeout(() => {
49
- o.close(), n(new Error("Login timeout"));
50
- }, l), d = async (p) => {
51
- if (p.origin !== t || p.data.action !== "login") return;
52
- let { data: I } = p.data;
53
- try {
54
- let { oidcToken: u = "", error: h } = I || {};
55
- if (h) {
56
- clearTimeout(m), window.removeEventListener("message", d), o.close(), n(new Error(String(h)));
57
- return;
58
- }
59
- u && (clearTimeout(m), window.removeEventListener("message", d), o.close(), c(u));
60
- } catch (u) {
61
- clearTimeout(m), window.removeEventListener("message", d), o.close(), n(u);
62
- }
63
- };
64
- window.addEventListener("message", d);
65
- let T = setInterval(() => {
66
- o.closed && (clearTimeout(m), clearInterval(T), window.removeEventListener("message", d), n(new Error("Login cancelled by user")));
67
- }, 400);
68
- });
69
- return { loginByGoogle: async () => {
70
- let l = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: r }, c = `${a}?${new URLSearchParams(l).toString()}`, n = f({ url: c, name: "Google login" });
71
- return await y(n);
72
- }, loginByX: async () => {
73
- let l = { target: window.location.origin, stage: e, eventId: Date.now().toString(), action: "login", clientId: g }, c = `${i}?${new URLSearchParams(l).toString()}`, n = f({ url: c, name: "X login" });
74
- return await y(n);
75
- }, loginByEmail: async (o) => {
76
- if (!R(o)) throw new Error("Invalid email");
77
- return { partialOidcToken: await O(o, s, E), lifeTime: x };
78
- } };
79
- };
80
-
81
- export { w as CubeEnvs, C as CubeOrgId, S as CubeStages, x as EmailCodeLifeTime, Y as OidcAuth, _ as RelayMessageTypes, v as RelayOrigin, O as emailLogin, L as getPredicateCubeRegisterPath };