@swype-org/react-sdk 0.1.115 → 0.1.121

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
@@ -1905,7 +1905,10 @@ function buildSelectSourceChoices(options) {
1905
1905
  chainChoice.tokens.push({ tokenSymbol, balance });
1906
1906
  }
1907
1907
  }
1908
- return chainChoices;
1908
+ return chainChoices.map((chain) => ({
1909
+ ...chain,
1910
+ tokens: chain.tokens.filter((t) => t.balance > 0)
1911
+ })).filter((chain) => chain.tokens.length > 0);
1909
1912
  }
1910
1913
 
1911
1914
  // src/paymentReducer.ts
@@ -2166,7 +2169,7 @@ function paymentReducer(state, action) {
2166
2169
  };
2167
2170
  // ── Navigation & error ───────────────────────────────────────
2168
2171
  case "NAVIGATE":
2169
- return { ...state, step: action.step };
2172
+ return { ...state, step: action.step, error: null };
2170
2173
  case "SET_ERROR":
2171
2174
  return { ...state, error: action.error };
2172
2175
  // ── Lifecycle ────────────────────────────────────────────────
@@ -2245,7 +2248,7 @@ var spinnerStyle = {
2245
2248
  };
2246
2249
  var FOOTER_CSS = `
2247
2250
  .swype-screen-footer {
2248
- padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
2251
+ padding-bottom: max(32px, env(safe-area-inset-bottom, 32px));
2249
2252
  }`;
2250
2253
  function ScreenLayout({ children, footer }) {
2251
2254
  const { tokens } = useSwypeConfig();
@@ -2268,12 +2271,16 @@ var containerStyle2 = (bg) => ({
2268
2271
  });
2269
2272
  var bodyStyle = {
2270
2273
  flex: 1,
2274
+ minHeight: 0,
2271
2275
  padding: "0 24px",
2272
2276
  display: "flex",
2273
- flexDirection: "column"
2277
+ flexDirection: "column",
2278
+ overflowY: "auto"
2274
2279
  };
2275
2280
  var footerStyle = {
2276
- padding: "16px 24px 0",
2281
+ paddingTop: 16,
2282
+ paddingLeft: 24,
2283
+ paddingRight: 24,
2277
2284
  marginTop: "auto"
2278
2285
  };
2279
2286
  function ScreenHeader({ title, right, onBack, badge }) {
@@ -3150,7 +3157,7 @@ function LoginScreen({
3150
3157
  ] }),
3151
3158
  /* @__PURE__ */ jsxs("div", { style: walletSectionStyle, children: [
3152
3159
  /* @__PURE__ */ jsx("span", { style: walletLabelStyle(tokens.textMuted), children: "Works with" }),
3153
- /* @__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)) })
3160
+ /* @__PURE__ */ jsx("div", { style: walletLogosStyle, children: walletIcons.map(({ key, logo }) => /* @__PURE__ */ jsx("img", { src: logo, alt: key, style: walletLogoImgStyle }, key)) })
3154
3161
  ] }),
3155
3162
  /* @__PURE__ */ jsx(PoweredByFooter, {})
3156
3163
  ] }),
@@ -3189,11 +3196,9 @@ function LoginScreen({
3189
3196
  );
3190
3197
  }
3191
3198
  var walletIcons = [
3192
- { key: "metamask", emoji: "\u{1F98A}", logo: KNOWN_LOGOS["metamask"] },
3193
- { key: "rabby", emoji: "\u{1F430}" },
3194
- { key: "phantom", emoji: "\u25C6" },
3195
- { key: "rainbow", emoji: "\u{1F439}" },
3196
- { key: "coinbase", emoji: "\u{1F535}", logo: KNOWN_LOGOS["base"] }
3199
+ { key: "metamask", logo: KNOWN_LOGOS["metamask"] },
3200
+ { key: "base", logo: KNOWN_LOGOS["base"] },
3201
+ { key: "trust wallet", logo: KNOWN_LOGOS["trust wallet"] }
3197
3202
  ];
3198
3203
  function socialLabel(provider) {
3199
3204
  switch (provider) {
@@ -3313,10 +3318,6 @@ var walletLogosStyle = {
3313
3318
  justifyContent: "center",
3314
3319
  gap: 16
3315
3320
  };
3316
- var walletEmojiStyle = {
3317
- fontSize: "1.4rem",
3318
- lineHeight: 1
3319
- };
3320
3321
  var walletLogoImgStyle = {
3321
3322
  width: 24,
3322
3323
  height: 24,
@@ -3478,7 +3479,7 @@ function CreatePasskeyScreen({
3478
3479
  }) {
3479
3480
  const { tokens } = useSwypeConfig();
3480
3481
  const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
3481
- const buttonLabel = popupFallback ? "Open passkey setup" : "Create passkey";
3482
+ const buttonLabel = popupFallback ? "Open passkey setup" : "Set up passkey";
3482
3483
  return /* @__PURE__ */ jsxs(
3483
3484
  ScreenLayout,
3484
3485
  {
@@ -3495,7 +3496,7 @@ function CreatePasskeyScreen({
3495
3496
  /* @__PURE__ */ jsx("circle", { cx: "15", cy: "10", r: "1", fill: tokens.accent }),
3496
3497
  /* @__PURE__ */ jsx("path", { d: "M9 14c0 1.5 1.34 2.5 3 2.5s3-1 3-2.5", stroke: tokens.accent, strokeWidth: "1.2", strokeLinecap: "round" })
3497
3498
  ] }) }),
3498
- /* @__PURE__ */ jsx("h2", { style: headingStyle3(tokens.text), children: "Create your passkey" }),
3499
+ /* @__PURE__ */ jsx("h2", { style: headingStyle3(tokens.text), children: "Set up your passkey" }),
3499
3500
  /* @__PURE__ */ jsx("p", { style: subtitleStyle3(tokens.textSecondary), children: popupFallback ? "Your browser requires a separate window for passkey setup. Tap the button below to continue." : "Use Face ID to sign in instantly \u2014 no passwords, no codes." }),
3500
3501
  error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle2(tokens), children: error }),
3501
3502
  /* @__PURE__ */ jsx(InfoBanner, { children: "Your passkey is stored securely on your device. Swype never sees your biometric data." })
@@ -3839,16 +3840,16 @@ function SetupScreen({
3839
3840
  error
3840
3841
  }) {
3841
3842
  const { tokens } = useSwypeConfig();
3842
- const effectiveMax = DEFAULT_MAX;
3843
+ const effectiveMax = Math.min(DEFAULT_MAX, availableBalance);
3843
3844
  const effectiveMin = Math.min(ABSOLUTE_MIN, effectiveMax);
3844
- const [limit, setLimit] = useState(() => effectiveMax);
3845
+ const [limit, setLimit] = useState(() => Math.min(availableBalance, effectiveMax));
3845
3846
  const [editing, setEditing] = useState(false);
3846
3847
  const [inputValue, setInputValue] = useState("");
3847
3848
  const inputRef = useRef(null);
3848
3849
  const startEditing = useCallback(() => {
3849
3850
  setInputValue(limit.toFixed(2));
3850
3851
  setEditing(true);
3851
- requestAnimationFrame(() => inputRef.current?.select());
3852
+ requestAnimationFrame(() => inputRef.current?.focus());
3852
3853
  }, [limit]);
3853
3854
  const commitEdit = useCallback(() => {
3854
3855
  const parsed = parseFloat(inputValue);
@@ -5138,6 +5139,7 @@ function OpenWalletScreen({
5138
5139
  loading,
5139
5140
  error,
5140
5141
  onRetryStatus,
5142
+ onBack,
5141
5143
  onLogout
5142
5144
  }) {
5143
5145
  const { tokens } = useSwypeConfig();
@@ -5168,7 +5170,7 @@ function OpenWalletScreen({
5168
5170
  /* @__PURE__ */ jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : error ? "Retry the status check after returning to the browser, or reopen your wallet if needed." : "If your wallet didn't open automatically, tap the button above" })
5169
5171
  ] }),
5170
5172
  children: [
5171
- /* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
5173
+ /* @__PURE__ */ jsx(ScreenHeader, { onBack, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
5172
5174
  /* @__PURE__ */ jsxs("div", { style: contentStyle8, children: [
5173
5175
  logoSrc ? /* @__PURE__ */ jsx("img", { src: logoSrc, alt: displayName, style: logoStyle }) : /* @__PURE__ */ jsx(Spinner, { size: 48 }),
5174
5176
  /* @__PURE__ */ jsx("h2", { style: headingStyle10(tokens.text), children: loading ? "Connecting..." : `Open ${displayName}` }),
@@ -5638,6 +5640,19 @@ function StepRenderer({
5638
5640
  }
5639
5641
  );
5640
5642
  }
5643
+ if (step === "verify-passkey") {
5644
+ return /* @__PURE__ */ jsx(
5645
+ CreatePasskeyScreen,
5646
+ {
5647
+ onCreatePasskey: handlers.onRegisterPasskey,
5648
+ onBack: handlers.onLogout,
5649
+ creating: state.verifyingPasskeyPopup,
5650
+ error: state.error,
5651
+ popupFallback: true,
5652
+ onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
5653
+ }
5654
+ );
5655
+ }
5641
5656
  if (step === "wallet-picker") {
5642
5657
  return /* @__PURE__ */ jsx(
5643
5658
  WalletPickerScreen,
@@ -5661,6 +5676,7 @@ function StepRenderer({
5661
5676
  loading: state.creatingTransfer || !state.deeplinkUri,
5662
5677
  error: state.error || pollingError,
5663
5678
  onRetryStatus: handlers.onRetryMobileStatus,
5679
+ onBack: () => handlers.onNavigate("wallet-picker"),
5664
5680
  onLogout: handlers.onLogout
5665
5681
  }
5666
5682
  );
@@ -6244,7 +6260,7 @@ function SwypePaymentInner({
6244
6260
  return;
6245
6261
  }
6246
6262
  if (!state.activeCredentialId) {
6247
- dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
6263
+ dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
6248
6264
  dispatch({ type: "NAVIGATE", step: "create-passkey" });
6249
6265
  return;
6250
6266
  }
@@ -6325,7 +6341,7 @@ function SwypePaymentInner({
6325
6341
  return;
6326
6342
  }
6327
6343
  if (!state.activeCredentialId) {
6328
- dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
6344
+ dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
6329
6345
  dispatch({ type: "NAVIGATE", step: "create-passkey" });
6330
6346
  return;
6331
6347
  }
@@ -6399,7 +6415,7 @@ function SwypePaymentInner({
6399
6415
  return;
6400
6416
  }
6401
6417
  if (!state.activeCredentialId) {
6402
- dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
6418
+ dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
6403
6419
  dispatch({ type: "NAVIGATE", step: "create-passkey" });
6404
6420
  return;
6405
6421
  }
@@ -6496,7 +6512,7 @@ function SwypePaymentInner({
6496
6512
  const handleSelectProvider = useCallback(async (providerId) => {
6497
6513
  dispatch({ type: "SELECT_PROVIDER", providerId });
6498
6514
  if (!state.activeCredentialId) {
6499
- dispatch({ type: "SET_ERROR", error: "Create a passkey on this device before continuing." });
6515
+ dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
6500
6516
  dispatch({ type: "NAVIGATE", step: "create-passkey" });
6501
6517
  return;
6502
6518
  }
@@ -6660,11 +6676,11 @@ function SwypePaymentInner({
6660
6676
  }
6661
6677
  }, [depositAmount]);
6662
6678
  useEffect(() => {
6663
- if (authenticated) return;
6679
+ if (authenticated || state.step !== "otp-verify") return;
6664
6680
  if (activeOtpErrorMessage) dispatch({ type: "SET_ERROR", error: activeOtpErrorMessage });
6665
- }, [activeOtpErrorMessage, authenticated]);
6681
+ }, [activeOtpErrorMessage, authenticated, state.step]);
6666
6682
  useEffect(() => {
6667
- if (state.step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus !== "submitting-code") {
6683
+ if (state.step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus === "awaiting-code-input") {
6668
6684
  handleVerifyLoginCode();
6669
6685
  }
6670
6686
  }, [otpCode, state.step, activeOtpStatus, handleVerifyLoginCode]);
@@ -6760,6 +6776,7 @@ function SwypePaymentInner({
6760
6776
  });
6761
6777
  pollingTransferIdRef.current = persisted.transferId ?? null;
6762
6778
  mobileSetupFlowRef.current = persisted.isSetup;
6779
+ setupAccountIdRef.current = persisted.accountId ?? null;
6763
6780
  if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
6764
6781
  return;
6765
6782
  }
@@ -6770,6 +6787,7 @@ function SwypePaymentInner({
6770
6787
  });
6771
6788
  pollingTransferIdRef.current = persisted.transferId ?? null;
6772
6789
  mobileSetupFlowRef.current = persisted.isSetup;
6790
+ setupAccountIdRef.current = persisted.accountId ?? null;
6773
6791
  if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
6774
6792
  return;
6775
6793
  }
@@ -6988,7 +7006,10 @@ function SwypePaymentInner({
6988
7006
  mobileSetupFlowRef.current = false;
6989
7007
  setupAccountIdRef.current = null;
6990
7008
  clearMobileFlowState();
6991
- await reloadAccounts();
7009
+ try {
7010
+ await reloadAccounts();
7011
+ } catch {
7012
+ }
6992
7013
  dispatch({ type: "MOBILE_SETUP_COMPLETE" });
6993
7014
  }
6994
7015
  } catch {