@swype-org/react-sdk 0.1.35 → 0.1.38

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/index.js CHANGED
@@ -2,6 +2,7 @@ import { createContext, useRef, useState, useCallback, useMemo, useContext, useE
2
2
  import { PrivyProvider, usePrivy, useLoginWithEmail, useLoginWithSms, useLoginWithOAuth } from '@privy-io/react-auth';
3
3
  import { createConfig, http, WagmiProvider, useConfig, useConnect, useSwitchChain } from 'wagmi';
4
4
  import { mainnet, arbitrum, base } from 'wagmi/chains';
5
+ import { injected } from 'wagmi/connectors';
5
6
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
6
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
8
  import { recoverTypedDataAddress, decodeAbiParameters, walletActions, createClient, custom } from 'viem';
@@ -74,6 +75,7 @@ function getTheme(mode) {
74
75
  var SWYPE_PRIVY_APP_ID = "cmlil87uv004n0ck0blwumwek";
75
76
  var wagmiConfig = createConfig({
76
77
  chains: [mainnet, arbitrum, base],
78
+ connectors: [injected()],
77
79
  transports: {
78
80
  [mainnet.id]: http(),
79
81
  [arbitrum.id]: http(),
@@ -1778,10 +1780,12 @@ function OtpInput({ value, onChange, length = 6, disabled }) {
1778
1780
  var containerStyle5 = {
1779
1781
  display: "flex",
1780
1782
  gap: 8,
1781
- justifyContent: "center"
1783
+ justifyContent: "center",
1784
+ width: "100%"
1782
1785
  };
1783
1786
  var inputStyle = (tokens, filled) => ({
1784
1787
  width: 44,
1788
+ maxWidth: "calc((100% - 40px) / 6)",
1785
1789
  height: 52,
1786
1790
  borderRadius: 12,
1787
1791
  border: `1.5px solid ${filled ? tokens.borderFocus : tokens.border}`,
@@ -1793,7 +1797,8 @@ var inputStyle = (tokens, filled) => ({
1793
1797
  textAlign: "center",
1794
1798
  outline: "none",
1795
1799
  caretColor: tokens.borderFocus,
1796
- transition: "border-color 0.15s ease"
1800
+ transition: "border-color 0.15s ease",
1801
+ flexShrink: 0
1797
1802
  });
1798
1803
  function LimitSlider({
1799
1804
  value,
@@ -1912,11 +1917,61 @@ var sliderThumbCss = (accent) => `
1912
1917
  cursor: pointer;
1913
1918
  }
1914
1919
  `;
1920
+
1921
+ // src/assets/logos.ts
1922
+ function svgToDataUri(svg) {
1923
+ return `data:image/svg+xml,${encodeURIComponent(svg)}`;
1924
+ }
1925
+ var BASE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 111 111" fill="none">
1926
+ <path d="M54.921 110.034C85.359 110.034 110.034 85.402 110.034 55.017C110.034 24.6319 85.359 0 54.921 0C26.0432 0 2.35281 22.1714 0 50.3923H72.8467V59.6416H0C2.35281 87.8625 26.0432 110.034 54.921 110.034Z" fill="#0052FF"/>
1927
+ </svg>`;
1928
+ var METAMASK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.6 318.6">
1929
+ <polygon fill="#E2761B" stroke="#E2761B" stroke-linecap="round" stroke-linejoin="round" points="274.1,35.5 174.6,109.4 193,65.8"/>
1930
+ <polygon fill="#E4761B" stroke="#E4761B" stroke-linecap="round" stroke-linejoin="round" points="44.4,35.5 143.1,110.1 125.6,65.8"/>
1931
+ <polygon fill="#D7C1B3" stroke="#D7C1B3" stroke-linecap="round" stroke-linejoin="round" points="238.3,206.8 211.8,247.4 268.5,263.2 285.8,207.7"/>
1932
+ <polygon fill="#D7C1B3" stroke="#D7C1B3" stroke-linecap="round" stroke-linejoin="round" points="33.9,207.7 51.1,263.2 107.8,247.4 81.3,206.8"/>
1933
+ <polygon fill="#233447" stroke="#233447" stroke-linecap="round" stroke-linejoin="round" points="103.6,138.2 87.8,162.1 143.1,164.6 141.1,104.1"/>
1934
+ <polygon fill="#233447" stroke="#233447" stroke-linecap="round" stroke-linejoin="round" points="214.9,138.2 175.9,103.4 174.6,164.6 230.8,162.1"/>
1935
+ <polygon fill="#CD6116" stroke="#CD6116" stroke-linecap="round" stroke-linejoin="round" points="107.8,247.4 140.6,230.9 111.4,208.1"/>
1936
+ <polygon fill="#CD6116" stroke="#CD6116" stroke-linecap="round" stroke-linejoin="round" points="177.9,230.9 211.8,247.4 207.1,208.1"/>
1937
+ <polygon fill="#E4761B" stroke="#E4761B" stroke-linecap="round" stroke-linejoin="round" points="211.8,247.4 177.9,230.9 180.6,253 180.3,262.3"/>
1938
+ <polygon fill="#E4761B" stroke="#E4761B" stroke-linecap="round" stroke-linejoin="round" points="107.8,247.4 138.3,262.3 138.1,253 140.6,230.9"/>
1939
+ <polygon fill="#763D16" stroke="#763D16" stroke-linecap="round" stroke-linejoin="round" points="138.8,193.5 110.6,185.2 130.5,176.1"/>
1940
+ <polygon fill="#763D16" stroke="#763D16" stroke-linecap="round" stroke-linejoin="round" points="179.7,193.5 188,176.1 208,185.2"/>
1941
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="107.8,247.4 111.6,206.8 81.3,207.7"/>
1942
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="207,206.8 211.8,247.4 238.3,207.7"/>
1943
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="230.8,162.1 174.6,164.6 179.8,193.5 188.1,176.1 208.1,185.2"/>
1944
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="110.6,185.2 130.6,176.1 138.8,193.5 143.1,164.6 87.8,162.1"/>
1945
+ <polygon fill="#E4751F" stroke="#E4751F" stroke-linecap="round" stroke-linejoin="round" points="87.8,162.1 111.4,208.1 110.6,185.2"/>
1946
+ <polygon fill="#E4751F" stroke="#E4751F" stroke-linecap="round" stroke-linejoin="round" points="208.1,185.2 207.1,208.1 230.8,162.1"/>
1947
+ <polygon fill="#E4751F" stroke="#E4751F" stroke-linecap="round" stroke-linejoin="round" points="143.1,164.6 138.8,193.5 144.1,218.9 145.3,182.8"/>
1948
+ <polygon fill="#E4751F" stroke="#E4751F" stroke-linecap="round" stroke-linejoin="round" points="174.6,164.6 173.1,182.6 174.4,218.9 179.8,193.5"/>
1949
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="179.8,193.5 174.4,218.9 177.9,230.9 207.1,208.1 208.1,185.2"/>
1950
+ <polygon fill="#F6851B" stroke="#F6851B" stroke-linecap="round" stroke-linejoin="round" points="110.6,185.2 111.4,208.1 140.6,230.9 144.1,218.9 138.8,193.5"/>
1951
+ <polygon fill="#C0AD9E" stroke="#C0AD9E" stroke-linecap="round" stroke-linejoin="round" points="180.3,262.3 180.6,253 178.1,250.8 140.4,250.8 138.1,253 138.3,262.3 107.8,247.4 117.8,255.1 140.1,271.9 178.4,271.9 200.8,255.1 211.8,247.4"/>
1952
+ <polygon fill="#161616" stroke="#161616" stroke-linecap="round" stroke-linejoin="round" points="177.9,230.9 174.4,218.9 178.1,250.8 180.6,253"/>
1953
+ <polygon fill="#161616" stroke="#161616" stroke-linecap="round" stroke-linejoin="round" points="140.6,230.9 138.1,253 140.4,250.8 144.1,218.9"/>
1954
+ <polygon fill="#763D16" stroke="#763D16" stroke-linecap="round" stroke-linejoin="round" points="278.3,114.2 286.8,73.7 274.1,35.5 174.6,109.4 214.9,138.2 267.2,153.5 278.8,140 273.8,136.4 281.8,129.1 275.4,124.1 283.4,118"/>
1955
+ <polygon fill="#763D16" stroke="#763D16" stroke-linecap="round" stroke-linejoin="round" points="31.8,73.7 40.3,114.2 35.5,118 43.5,124.1 36.8,129.1 44.8,136.4 39.8,140 51.3,153.5 103.6,138.2 143.1,110.1 44.4,35.5"/>
1956
+ </svg>`;
1957
+ var BASE_LOGO = svgToDataUri(BASE_SVG);
1958
+ var METAMASK_LOGO = svgToDataUri(METAMASK_SVG);
1959
+ var KNOWN_LOGOS = {
1960
+ metamask: METAMASK_LOGO,
1961
+ base: BASE_LOGO
1962
+ };
1915
1963
  function SourceCard({ name, address, verified, onChangeSource }) {
1916
1964
  const { tokens } = useSwypeConfig();
1917
1965
  return /* @__PURE__ */ jsxs("div", { style: containerStyle6(tokens), children: [
1918
1966
  /* @__PURE__ */ jsxs("div", { style: leftStyle, children: [
1919
- /* @__PURE__ */ jsx("div", { style: iconStyle3(tokens.textMuted), children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
1967
+ KNOWN_LOGOS[name.toLowerCase()] ? /* @__PURE__ */ jsx(
1968
+ "img",
1969
+ {
1970
+ src: KNOWN_LOGOS[name.toLowerCase()],
1971
+ alt: name,
1972
+ style: logoImgStyle
1973
+ }
1974
+ ) : /* @__PURE__ */ jsx("div", { style: iconStyle3(tokens.textMuted), children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
1920
1975
  "path",
1921
1976
  {
1922
1977
  d: "M21 7H3c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zm0 8H3V9h18v6z",
@@ -1948,6 +2003,12 @@ var leftStyle = {
1948
2003
  alignItems: "center",
1949
2004
  gap: 10
1950
2005
  };
2006
+ var logoImgStyle = {
2007
+ width: 20,
2008
+ height: 20,
2009
+ borderRadius: "50%",
2010
+ objectFit: "contain"
2011
+ };
1951
2012
  var iconStyle3 = (color) => ({
1952
2013
  color,
1953
2014
  display: "flex",
@@ -2157,7 +2218,7 @@ function LoginScreen({
2157
2218
  ] }),
2158
2219
  /* @__PURE__ */ jsxs("div", { style: walletSectionStyle, children: [
2159
2220
  /* @__PURE__ */ jsx("span", { style: walletLabelStyle(tokens.textMuted), children: "Works with" }),
2160
- /* @__PURE__ */ jsx("div", { style: walletLogosStyle, children: walletIcons.map(({ key, emoji }) => /* @__PURE__ */ jsx("span", { style: walletEmojiStyle, children: emoji }, key)) })
2221
+ /* @__PURE__ */ jsx("div", { style: walletLogosStyle, children: walletIcons.map(({ key, emoji, logo }) => logo ? /* @__PURE__ */ jsx("img", { src: logo, alt: key, style: walletLogoImgStyle }, key) : /* @__PURE__ */ jsx("span", { style: walletEmojiStyle, children: emoji }, key)) })
2161
2222
  ] }),
2162
2223
  /* @__PURE__ */ jsx(PoweredByFooter, {})
2163
2224
  ] }),
@@ -2196,11 +2257,11 @@ function LoginScreen({
2196
2257
  );
2197
2258
  }
2198
2259
  var walletIcons = [
2199
- { key: "metamask", emoji: "\u{1F98A}" },
2260
+ { key: "metamask", emoji: "\u{1F98A}", logo: KNOWN_LOGOS["metamask"] },
2200
2261
  { key: "rabby", emoji: "\u{1F430}" },
2201
2262
  { key: "phantom", emoji: "\u25C6" },
2202
2263
  { key: "rainbow", emoji: "\u{1F439}" },
2203
- { key: "coinbase", emoji: "\u{1F535}" }
2264
+ { key: "coinbase", emoji: "\u{1F535}", logo: KNOWN_LOGOS["base"] }
2204
2265
  ];
2205
2266
  function socialLabel(provider) {
2206
2267
  switch (provider) {
@@ -2324,6 +2385,11 @@ var walletEmojiStyle = {
2324
2385
  fontSize: "1.4rem",
2325
2386
  lineHeight: 1
2326
2387
  };
2388
+ var walletLogoImgStyle = {
2389
+ width: 24,
2390
+ height: 24,
2391
+ objectFit: "contain"
2392
+ };
2327
2393
  var avatarStyle = (tokens) => ({
2328
2394
  width: 28,
2329
2395
  height: 28,
@@ -2381,50 +2447,43 @@ function OtpVerifyScreen({
2381
2447
  });
2382
2448
  }, 1e3);
2383
2449
  }, [cooldown, onResend]);
2384
- return /* @__PURE__ */ jsxs(
2385
- ScreenLayout,
2386
- {
2387
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [
2388
- /* @__PURE__ */ jsx(PrimaryButton, { onClick: onVerify, disabled, loading: verifying, children: "Verify" }),
2389
- /* @__PURE__ */ jsx("p", { style: hintStyle(tokens.textMuted), children: "Didn't get the code? Check your spam folder" }),
2390
- /* @__PURE__ */ jsx(PoweredByFooter, {})
2450
+ return /* @__PURE__ */ jsxs(ScreenLayout, { footer: /* @__PURE__ */ jsx(PoweredByFooter, {}), children: [
2451
+ /* @__PURE__ */ jsx(ScreenHeader, { onBack }),
2452
+ /* @__PURE__ */ jsxs("div", { style: contentStyle2, children: [
2453
+ /* @__PURE__ */ jsx(IconCircle, { variant: "accent", size: 56, children: /* @__PURE__ */ jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
2454
+ "path",
2455
+ {
2456
+ d: "M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4z",
2457
+ fill: tokens.accent
2458
+ }
2459
+ ) }) }),
2460
+ /* @__PURE__ */ jsx("h2", { style: headingStyle2(tokens.text), children: "Check your email" }),
2461
+ /* @__PURE__ */ jsxs("p", { style: subtitleStyle2(tokens.textSecondary), children: [
2462
+ "We sent a 6-digit code to",
2463
+ "\n",
2464
+ /* @__PURE__ */ jsx("strong", { children: maskedIdentifier })
2391
2465
  ] }),
2392
- children: [
2393
- /* @__PURE__ */ jsx(ScreenHeader, { onBack }),
2394
- /* @__PURE__ */ jsxs("div", { style: contentStyle2, children: [
2395
- /* @__PURE__ */ jsx(IconCircle, { variant: "accent", size: 56, children: /* @__PURE__ */ jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
2396
- "path",
2397
- {
2398
- d: "M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4z",
2399
- fill: tokens.accent
2400
- }
2401
- ) }) }),
2402
- /* @__PURE__ */ jsx("h2", { style: headingStyle2(tokens.text), children: "Check your email" }),
2403
- /* @__PURE__ */ jsxs("p", { style: subtitleStyle2(tokens.textSecondary), children: [
2404
- "We sent a 6-digit code to",
2405
- "\n",
2406
- /* @__PURE__ */ jsx("strong", { children: maskedIdentifier })
2407
- ] }),
2408
- error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle(tokens), children: error }),
2409
- /* @__PURE__ */ jsx(OtpInput, { value: otpCode, onChange: onOtpChange, disabled: verifying }),
2410
- /* @__PURE__ */ jsx(
2411
- "button",
2412
- {
2413
- type: "button",
2414
- onClick: handleResend,
2415
- disabled: cooldown > 0,
2416
- style: resendStyle(tokens.textMuted, cooldown > 0),
2417
- children: cooldown > 0 ? `Resend code in ${cooldown}s` : "Resend code"
2418
- }
2419
- )
2420
- ] })
2421
- ]
2422
- }
2423
- );
2466
+ error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle(tokens), children: error }),
2467
+ /* @__PURE__ */ jsx(OtpInput, { value: otpCode, onChange: onOtpChange, disabled: verifying }),
2468
+ /* @__PURE__ */ jsx(
2469
+ "button",
2470
+ {
2471
+ type: "button",
2472
+ onClick: handleResend,
2473
+ disabled: cooldown > 0,
2474
+ style: resendStyle(tokens.textMuted, cooldown > 0),
2475
+ children: cooldown > 0 ? `Resend code in ${cooldown}s` : "Resend code"
2476
+ }
2477
+ ),
2478
+ /* @__PURE__ */ jsxs("div", { style: actionStyle, children: [
2479
+ /* @__PURE__ */ jsx(PrimaryButton, { onClick: onVerify, disabled, loading: verifying, children: "Verify" }),
2480
+ /* @__PURE__ */ jsx("p", { style: hintStyle(tokens.textMuted), children: "Didn't get the code? Check your spam folder" })
2481
+ ] })
2482
+ ] })
2483
+ ] });
2424
2484
  }
2425
2485
  var contentStyle2 = {
2426
2486
  textAlign: "center",
2427
- flex: 1,
2428
2487
  display: "flex",
2429
2488
  flexDirection: "column",
2430
2489
  alignItems: "center",
@@ -2467,6 +2526,10 @@ var resendStyle = (color, disabled) => ({
2467
2526
  padding: 0,
2468
2527
  opacity: disabled ? 0.6 : 1
2469
2528
  });
2529
+ var actionStyle = {
2530
+ width: "100%",
2531
+ marginTop: 32
2532
+ };
2470
2533
  var hintStyle = (color) => ({
2471
2534
  textAlign: "center",
2472
2535
  fontSize: "0.78rem",
@@ -2555,18 +2618,24 @@ var skipStyle = (color) => ({
2555
2618
  padding: "12px 0 0"
2556
2619
  });
2557
2620
  var WALLET_EMOJIS = {
2558
- metamask: "\u{1F98A}",
2559
2621
  rabby: "\u{1F430}",
2560
2622
  ora: "\u2666\uFE0F",
2561
2623
  phantom: "\u{1F47B}"
2562
2624
  };
2625
+ function truncateAddress(address) {
2626
+ if (address.length <= 10) return address;
2627
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
2628
+ }
2563
2629
  function WalletPickerScreen({
2564
2630
  providers,
2631
+ pendingConnections,
2565
2632
  onSelectProvider,
2633
+ onContinueConnection,
2566
2634
  onBack
2567
2635
  }) {
2568
2636
  const { tokens } = useSwypeConfig();
2569
2637
  const [hoveredId, setHoveredId] = useState(null);
2638
+ const hasPending = pendingConnections != null && pendingConnections.length > 0;
2570
2639
  const displayProviders = providers.length > 0 ? providers : [
2571
2640
  { id: "metamask", name: "MetaMask" },
2572
2641
  { id: "rabby", name: "Rabby" },
@@ -2582,10 +2651,54 @@ function WalletPickerScreen({
2582
2651
  ] }),
2583
2652
  children: [
2584
2653
  /* @__PURE__ */ jsx(ScreenHeader, { title: "Set up Swype", onBack }),
2585
- /* @__PURE__ */ jsx("h2", { style: headingStyle4(tokens.text), children: "Where are your stablecoins?" }),
2586
- /* @__PURE__ */ jsx("p", { style: subtitleStyle4(tokens.textSecondary), children: "Select the wallet you want to deposit from" }),
2654
+ hasPending && /* @__PURE__ */ jsxs(Fragment, { children: [
2655
+ /* @__PURE__ */ jsx("h2", { style: headingStyle4(tokens.text), children: "Continue where you left off" }),
2656
+ /* @__PURE__ */ jsx("p", { style: subtitleStyle4(tokens.textSecondary), children: "You have a wallet that still needs setup" }),
2657
+ /* @__PURE__ */ jsx("div", { style: pendingListStyle, children: pendingConnections.map((acct) => {
2658
+ const wallet = acct.wallets[0];
2659
+ const address = wallet ? truncateAddress(wallet.name) : void 0;
2660
+ const isHovered = hoveredId === `pending-${acct.id}`;
2661
+ return /* @__PURE__ */ jsxs(
2662
+ "button",
2663
+ {
2664
+ onClick: () => onContinueConnection?.(acct.id),
2665
+ onMouseEnter: () => setHoveredId(`pending-${acct.id}`),
2666
+ onMouseLeave: () => setHoveredId(null),
2667
+ style: pendingCardStyle(tokens, isHovered),
2668
+ children: [
2669
+ /* @__PURE__ */ jsxs("div", { style: pendingCardContentStyle, children: [
2670
+ /* @__PURE__ */ jsx("div", { style: pendingIconStyle, children: KNOWN_LOGOS[acct.name.toLowerCase()] ? /* @__PURE__ */ jsx(
2671
+ "img",
2672
+ {
2673
+ src: KNOWN_LOGOS[acct.name.toLowerCase()],
2674
+ alt: acct.name,
2675
+ style: logoImgStyle2
2676
+ }
2677
+ ) : /* @__PURE__ */ jsx("span", { style: emojiStyle, children: WALLET_EMOJIS[acct.name.toLowerCase()] ?? acct.name.charAt(0) }) }),
2678
+ /* @__PURE__ */ jsxs("div", { style: pendingInfoStyle, children: [
2679
+ /* @__PURE__ */ jsx("span", { style: pendingNameStyle(tokens.text), children: acct.name }),
2680
+ address && /* @__PURE__ */ jsx("span", { style: pendingAddressStyle(tokens.textMuted), children: address })
2681
+ ] }),
2682
+ /* @__PURE__ */ jsx("span", { style: pendingBadgeStyle(tokens), children: "Setup incomplete" })
2683
+ ] }),
2684
+ /* @__PURE__ */ jsxs("div", { style: continueRowStyle(tokens), children: [
2685
+ "Continue setup",
2686
+ /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z", fill: "currentColor" }) })
2687
+ ] })
2688
+ ]
2689
+ },
2690
+ acct.id
2691
+ );
2692
+ }) }),
2693
+ /* @__PURE__ */ jsx("div", { style: dividerStyle2(tokens.border), children: /* @__PURE__ */ jsx("span", { style: dividerTextStyle(tokens.textMuted), children: "Or connect a new wallet" }) })
2694
+ ] }),
2695
+ !hasPending && /* @__PURE__ */ jsxs(Fragment, { children: [
2696
+ /* @__PURE__ */ jsx("h2", { style: headingStyle4(tokens.text), children: "Where are your stablecoins?" }),
2697
+ /* @__PURE__ */ jsx("p", { style: subtitleStyle4(tokens.textSecondary), children: "Select the wallet you want to deposit from" })
2698
+ ] }),
2587
2699
  /* @__PURE__ */ jsxs("div", { style: gridStyle, children: [
2588
2700
  displayProviders.map((p) => {
2701
+ const logoSrc = "logoURI" in p && p.logoURI || KNOWN_LOGOS[p.name.toLowerCase()];
2589
2702
  const emoji = WALLET_EMOJIS[p.name.toLowerCase()] ?? p.name.charAt(0);
2590
2703
  const isHovered = hoveredId === p.id;
2591
2704
  return /* @__PURE__ */ jsxs(
@@ -2596,12 +2709,12 @@ function WalletPickerScreen({
2596
2709
  onMouseLeave: () => setHoveredId(null),
2597
2710
  style: cardStyle(tokens, isHovered),
2598
2711
  children: [
2599
- "logoURI" in p && p.logoURI ? /* @__PURE__ */ jsx(
2712
+ logoSrc ? /* @__PURE__ */ jsx(
2600
2713
  "img",
2601
2714
  {
2602
- src: p.logoURI,
2715
+ src: logoSrc,
2603
2716
  alt: p.name,
2604
- style: logoImgStyle
2717
+ style: logoImgStyle2
2605
2718
  }
2606
2719
  ) : /* @__PURE__ */ jsx("span", { style: emojiStyle, children: emoji }),
2607
2720
  /* @__PURE__ */ jsx("span", { style: nameStyle2(tokens.text), children: p.name })
@@ -2670,7 +2783,7 @@ var emojiStyle = {
2670
2783
  fontSize: "1.75rem",
2671
2784
  lineHeight: 1
2672
2785
  };
2673
- var logoImgStyle = {
2786
+ var logoImgStyle2 = {
2674
2787
  width: 32,
2675
2788
  height: 32,
2676
2789
  borderRadius: 8,
@@ -2687,6 +2800,86 @@ var hintStyle2 = (color) => ({
2687
2800
  color,
2688
2801
  margin: "0 0 4px"
2689
2802
  });
2803
+ var pendingListStyle = {
2804
+ display: "flex",
2805
+ flexDirection: "column",
2806
+ gap: 10,
2807
+ marginBottom: 20
2808
+ };
2809
+ var pendingCardStyle = (tokens, hovered) => ({
2810
+ display: "flex",
2811
+ flexDirection: "column",
2812
+ gap: 0,
2813
+ padding: 0,
2814
+ background: hovered ? tokens.bgHover : tokens.bgInput,
2815
+ border: `1.5px solid ${tokens.warning}44`,
2816
+ borderRadius: 16,
2817
+ cursor: "pointer",
2818
+ fontFamily: "inherit",
2819
+ transition: "background 0.15s ease",
2820
+ outline: "none",
2821
+ overflow: "hidden",
2822
+ textAlign: "left"
2823
+ });
2824
+ var pendingCardContentStyle = {
2825
+ display: "flex",
2826
+ alignItems: "center",
2827
+ gap: 12,
2828
+ padding: "14px 16px"
2829
+ };
2830
+ var pendingIconStyle = {
2831
+ flexShrink: 0
2832
+ };
2833
+ var pendingInfoStyle = {
2834
+ display: "flex",
2835
+ flexDirection: "column",
2836
+ gap: 2,
2837
+ flex: 1,
2838
+ minWidth: 0
2839
+ };
2840
+ var pendingNameStyle = (color) => ({
2841
+ fontSize: "0.92rem",
2842
+ fontWeight: 600,
2843
+ color
2844
+ });
2845
+ var pendingAddressStyle = (color) => ({
2846
+ fontSize: "0.78rem",
2847
+ color,
2848
+ fontFamily: "monospace"
2849
+ });
2850
+ var pendingBadgeStyle = (tokens) => ({
2851
+ fontSize: "0.72rem",
2852
+ fontWeight: 600,
2853
+ color: tokens.warningText ?? tokens.warning,
2854
+ background: tokens.warningBg ?? `${tokens.warning}1a`,
2855
+ padding: "3px 8px",
2856
+ borderRadius: 6,
2857
+ whiteSpace: "nowrap",
2858
+ flexShrink: 0
2859
+ });
2860
+ var continueRowStyle = (tokens) => ({
2861
+ display: "flex",
2862
+ alignItems: "center",
2863
+ justifyContent: "center",
2864
+ gap: 4,
2865
+ padding: "10px 16px",
2866
+ fontSize: "0.84rem",
2867
+ fontWeight: 600,
2868
+ color: tokens.accent,
2869
+ background: `${tokens.accent}0d`,
2870
+ borderTop: `1px solid ${tokens.accent}22`
2871
+ });
2872
+ var dividerStyle2 = (borderColor) => ({
2873
+ display: "flex",
2874
+ alignItems: "center",
2875
+ gap: 12,
2876
+ margin: "4px 0 16px"
2877
+ });
2878
+ var dividerTextStyle = (color) => ({
2879
+ fontSize: "0.82rem",
2880
+ color,
2881
+ whiteSpace: "nowrap"
2882
+ });
2690
2883
  var DEFAULT_MAX = 500;
2691
2884
  var ABSOLUTE_MIN = 1;
2692
2885
  function buildTicks(min, max) {
@@ -2733,7 +2926,7 @@ function SetupScreen({
2733
2926
  /* @__PURE__ */ jsx(PoweredByFooter, {})
2734
2927
  ] }),
2735
2928
  children: [
2736
- /* @__PURE__ */ jsx(ScreenHeader, { title: "Swype Setup", badge: "Simple", onBack, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
2929
+ /* @__PURE__ */ jsx(ScreenHeader, { title: "Swype Setup", onBack, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
2737
2930
  /* @__PURE__ */ jsx("h2", { style: headingStyle5(tokens.text), children: "Set up One-Tap deposits" }),
2738
2931
  /* @__PURE__ */ jsx("p", { style: subtitleStyle5(tokens.textSecondary), children: "Set your limit for instant deposits. Like a contactless card \u2014 you choose the max." }),
2739
2932
  error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle3(tokens), children: error }),
@@ -2888,7 +3081,6 @@ function SetupStatusScreen({
2888
3081
  complete,
2889
3082
  limit,
2890
3083
  tokensApproved,
2891
- currentStepLabel,
2892
3084
  merchantName,
2893
3085
  onContinue,
2894
3086
  onLogout,
@@ -2904,7 +3096,7 @@ function SetupStatusScreen({
2904
3096
  { label: "Done", status: "complete" }
2905
3097
  ] : [
2906
3098
  {
2907
- label: currentStepLabel ?? "Approving tokens",
3099
+ label: "Setting up Wallet",
2908
3100
  status: "active"
2909
3101
  },
2910
3102
  { label: "Done", status: "pending" }
@@ -2942,7 +3134,7 @@ var contentStyle4 = {
2942
3134
  alignItems: "center",
2943
3135
  justifyContent: "center",
2944
3136
  textAlign: "center",
2945
- padding: "0 24px"
3137
+ padding: "0 24px 32px"
2946
3138
  };
2947
3139
  var headingStyle6 = (color) => ({
2948
3140
  fontSize: "1.45rem",
@@ -3082,7 +3274,7 @@ function DepositScreen({
3082
3274
  /* @__PURE__ */ jsx(PoweredByFooter, {})
3083
3275
  ] }),
3084
3276
  children: [
3085
- /* @__PURE__ */ jsx(ScreenHeader, { title: headerTitle, badge: "Simple", onBack, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
3277
+ /* @__PURE__ */ jsx(ScreenHeader, { title: headerTitle, onBack, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
3086
3278
  /* @__PURE__ */ jsx(
3087
3279
  SourceCard,
3088
3280
  {
@@ -3774,6 +3966,7 @@ function SwypePayment({
3774
3966
  const [setupComplete, setSetupComplete] = useState(false);
3775
3967
  const [setupStepLabel, setSetupStepLabel] = useState(void 0);
3776
3968
  const [mobileFlow, setMobileFlow] = useState(false);
3969
+ const [mobileSetupFlow, setMobileSetupFlow] = useState(false);
3777
3970
  const pollingTransferIdRef = useRef(null);
3778
3971
  const mobileSigningTransferIdRef = useRef(null);
3779
3972
  const processingStartedAtRef = useRef(null);
@@ -3786,6 +3979,23 @@ function SwypePayment({
3786
3979
  const transferSigning = useTransferSigning();
3787
3980
  const sourceType = connectingNewAccount ? "providerId" : selectedWalletId ? "walletId" : selectedAccountId ? "accountId" : "providerId";
3788
3981
  const sourceId = connectingNewAccount ? selectedProviderId ?? "" : selectedWalletId ? selectedWalletId : selectedAccountId ? selectedAccountId : selectedProviderId ?? "";
3982
+ const reloadAccounts = useCallback(async () => {
3983
+ const token = await getAccessToken();
3984
+ if (!token || !activeCredentialId) return;
3985
+ const [accts, prov] = await Promise.all([
3986
+ fetchAccounts(apiBaseUrl, token, activeCredentialId),
3987
+ fetchProviders(apiBaseUrl, token)
3988
+ ]);
3989
+ setAccounts(accts);
3990
+ setProviders(prov);
3991
+ const parsedAmt = depositAmount != null ? depositAmount : 0;
3992
+ const defaults = computeSmartDefaults(accts, parsedAmt);
3993
+ if (defaults) {
3994
+ setSelectedAccountId(defaults.accountId);
3995
+ setSelectedWalletId(defaults.walletId);
3996
+ setConnectingNewAccount(false);
3997
+ }
3998
+ }, [getAccessToken, activeCredentialId, apiBaseUrl, depositAmount]);
3789
3999
  useEffect(() => {
3790
4000
  if (depositAmount != null) {
3791
4001
  setAmount(depositAmount.toString());
@@ -3935,7 +4145,10 @@ function SwypePayment({
3935
4145
  } else if (prov.length > 0) {
3936
4146
  setSelectedProviderId(prov[0].id);
3937
4147
  }
3938
- if (accts.length === 0 && step === "deposit") {
4148
+ const hasActiveWallet = accts.some(
4149
+ (a) => a.wallets.some((w) => w.status === "ACTIVE")
4150
+ );
4151
+ if ((accts.length === 0 || !hasActiveWallet) && step === "deposit") {
3939
4152
  setStep("wallet-picker");
3940
4153
  }
3941
4154
  } catch (err) {
@@ -3994,7 +4207,24 @@ function SwypePayment({
3994
4207
  return () => window.clearTimeout(timeoutId);
3995
4208
  }, [step, polling.transfer, transfer, polling.stopPolling, onError]);
3996
4209
  useEffect(() => {
3997
- if (!mobileFlow) return;
4210
+ if (!mobileSetupFlow) return;
4211
+ const polledTransfer = polling.transfer;
4212
+ if (!polledTransfer) return;
4213
+ if (polledTransfer.status !== "AUTHORIZED" && polledTransfer.status !== "COMPLETED") return;
4214
+ polling.stopPolling();
4215
+ setMobileFlow(false);
4216
+ setMobileSetupFlow(false);
4217
+ const finishSetup = async () => {
4218
+ try {
4219
+ await reloadAccounts();
4220
+ } catch {
4221
+ }
4222
+ setStep("deposit");
4223
+ };
4224
+ void finishSetup();
4225
+ }, [mobileSetupFlow, polling, reloadAccounts]);
4226
+ useEffect(() => {
4227
+ if (!mobileFlow || mobileSetupFlow) return;
3998
4228
  const polledTransfer = polling.transfer;
3999
4229
  if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
4000
4230
  if (transferSigning.signing) return;
@@ -4012,7 +4242,7 @@ function SwypePayment({
4012
4242
  }
4013
4243
  };
4014
4244
  void sign();
4015
- }, [mobileFlow, polling.transfer, transferSigning, onError]);
4245
+ }, [mobileFlow, mobileSetupFlow, polling.transfer, transferSigning, onError]);
4016
4246
  useEffect(() => {
4017
4247
  if (!mobileFlow) return;
4018
4248
  const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
@@ -4097,6 +4327,12 @@ function SwypePayment({
4097
4327
  },
4098
4328
  [selectSourceChoices, selectSourceRecommended]
4099
4329
  );
4330
+ const pendingConnections = useMemo(
4331
+ () => accounts.filter(
4332
+ (a) => a.wallets.length > 0 && !a.wallets.some((w) => w.status === "ACTIVE")
4333
+ ),
4334
+ [accounts]
4335
+ );
4100
4336
  const selectedAccount = accounts.find((a) => a.id === selectedAccountId);
4101
4337
  const selectedWallet = selectedAccount?.wallets.find((w) => w.id === selectedWalletId);
4102
4338
  const sourceName = selectedAccount?.name ?? selectedWallet?.chain.name ?? "Wallet";
@@ -4240,7 +4476,10 @@ function SwypePayment({
4240
4476
  await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
4241
4477
  setActiveCredentialId(credentialId);
4242
4478
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
4243
- if (accounts.length === 0) {
4479
+ const hasActiveWallet = accounts.some(
4480
+ (a) => a.wallets.some((w) => w.status === "ACTIVE")
4481
+ );
4482
+ if (accounts.length === 0 || !hasActiveWallet) {
4244
4483
  setStep("wallet-picker");
4245
4484
  } else {
4246
4485
  setStep("deposit");
@@ -4250,14 +4489,17 @@ function SwypePayment({
4250
4489
  } finally {
4251
4490
  setRegisteringPasskey(false);
4252
4491
  }
4253
- }, [getAccessToken, user, apiBaseUrl, accounts.length]);
4492
+ }, [getAccessToken, user, apiBaseUrl, accounts]);
4254
4493
  const handleSkipPasskey = useCallback(() => {
4255
- if (accounts.length === 0) {
4494
+ const hasActiveWallet = accounts.some(
4495
+ (a) => a.wallets.some((w) => w.status === "ACTIVE")
4496
+ );
4497
+ if (accounts.length === 0 || !hasActiveWallet) {
4256
4498
  setStep("wallet-picker");
4257
4499
  } else {
4258
4500
  setStep("deposit");
4259
4501
  }
4260
- }, [accounts.length]);
4502
+ }, [accounts]);
4261
4503
  const handleSetupOneTap = useCallback(async (limit) => {
4262
4504
  setOneTapLimit(limit);
4263
4505
  setStep("setup-status");
@@ -4270,6 +4512,7 @@ function SwypePayment({
4270
4512
  if (!sourceId) {
4271
4513
  throw new Error("No wallet selected for setup.");
4272
4514
  }
4515
+ await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
4273
4516
  const setupAmount = depositAmount ?? MIN_SEND_AMOUNT_USD;
4274
4517
  const t = await createTransfer(apiBaseUrl, token, {
4275
4518
  id: idempotencyKey,
@@ -4287,11 +4530,16 @@ function SwypePayment({
4287
4530
  });
4288
4531
  if (!shouldUseConnector) {
4289
4532
  setMobileFlow(true);
4533
+ setMobileSetupFlow(true);
4534
+ pollingTransferIdRef.current = t.id;
4535
+ polling.startPolling(t.id);
4290
4536
  window.location.href = t.authorizationSessions[0].uri;
4537
+ return;
4291
4538
  } else {
4292
4539
  await authExecutor.executeSession(t);
4293
4540
  }
4294
4541
  }
4542
+ await reloadAccounts();
4295
4543
  setSetupStepLabel(void 0);
4296
4544
  setSetupComplete(true);
4297
4545
  } catch (err) {
@@ -4310,8 +4558,10 @@ function SwypePayment({
4310
4558
  merchantAuthorization,
4311
4559
  useWalletConnector,
4312
4560
  authExecutor,
4561
+ polling,
4313
4562
  onError,
4314
- depositAmount
4563
+ depositAmount,
4564
+ reloadAccounts
4315
4565
  ]);
4316
4566
  const handleSelectProvider = useCallback((providerId) => {
4317
4567
  setSelectedProviderId(providerId);
@@ -4319,12 +4569,23 @@ function SwypePayment({
4319
4569
  setConnectingNewAccount(true);
4320
4570
  setStep("setup");
4321
4571
  }, []);
4572
+ const handleContinueConnection = useCallback(
4573
+ (accountId) => {
4574
+ const acct = accounts.find((a) => a.id === accountId);
4575
+ setSelectedAccountId(accountId);
4576
+ setSelectedWalletId(acct?.wallets[0]?.id ?? null);
4577
+ setConnectingNewAccount(false);
4578
+ setStep("setup");
4579
+ },
4580
+ [accounts]
4581
+ );
4322
4582
  const handleNewPayment = useCallback(() => {
4323
4583
  setStep("deposit");
4324
4584
  setTransfer(null);
4325
4585
  setError(null);
4326
4586
  setAmount(depositAmount != null ? depositAmount.toString() : "");
4327
4587
  setMobileFlow(false);
4588
+ setMobileSetupFlow(false);
4328
4589
  processingStartedAtRef.current = null;
4329
4590
  pollingTransferIdRef.current = null;
4330
4591
  mobileSigningTransferIdRef.current = null;
@@ -4357,6 +4618,7 @@ function SwypePayment({
4357
4618
  setConnectingNewAccount(false);
4358
4619
  setAmount(depositAmount != null ? depositAmount.toString() : "");
4359
4620
  setMobileFlow(false);
4621
+ setMobileSetupFlow(false);
4360
4622
  setSetupComplete(false);
4361
4623
  resetHeadlessLogin();
4362
4624
  }, [logout, polling, depositAmount, resetHeadlessLogin]);
@@ -4420,7 +4682,9 @@ function SwypePayment({
4420
4682
  WalletPickerScreen,
4421
4683
  {
4422
4684
  providers,
4685
+ pendingConnections,
4423
4686
  onSelectProvider: handleSelectProvider,
4687
+ onContinueConnection: handleContinueConnection,
4424
4688
  onBack: () => setStep("create-passkey")
4425
4689
  }
4426
4690
  );
@@ -4447,7 +4711,6 @@ function SwypePayment({
4447
4711
  complete: setupComplete,
4448
4712
  limit: oneTapLimit,
4449
4713
  tokensApproved: tokenCount,
4450
- currentStepLabel: setupStepLabel,
4451
4714
  merchantName,
4452
4715
  onContinue: () => setStep("deposit"),
4453
4716
  onLogout: handleLogout,
@@ -4559,6 +4822,6 @@ function SwypePayment({
4559
4822
  return null;
4560
4823
  }
4561
4824
 
4562
- export { SwypePayment, SwypeProvider, createPasskeyCredential, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
4825
+ export { IconCircle, OutlineButton, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, Spinner, StepList, SwypePayment, SwypeProvider, createPasskeyCredential, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
4563
4826
  //# sourceMappingURL=index.js.map
4564
4827
  //# sourceMappingURL=index.js.map