@swype-org/react-sdk 0.1.129 → 0.1.131

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
@@ -6004,6 +6004,7 @@ function SwypePaymentInner({
6004
6004
  const initializedSelectSourceActionRef = useRef(null);
6005
6005
  const preSelectSourceStepRef = useRef(null);
6006
6006
  const pendingTokenAuthRef = useRef(null);
6007
+ const pendingTokenSelectionRef = useRef(null);
6007
6008
  const reauthSessionIdRef = useRef(null);
6008
6009
  const reauthTokenRef = useRef(null);
6009
6010
  const checkingPasskeyRef = useRef(false);
@@ -6505,7 +6506,8 @@ function SwypePaymentInner({
6505
6506
  dispatch({ type: "NAVIGATE", step: "setup-status" });
6506
6507
  await authExecutor.executeSessionById(session.id);
6507
6508
  await reloadAccounts();
6508
- dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
6509
+ pendingTokenSelectionRef.current = { walletId: _walletId, tokenSymbol };
6510
+ dispatch({ type: "NAVIGATE", step: "setup" });
6509
6511
  }
6510
6512
  } catch (err) {
6511
6513
  captureException(err);
@@ -6655,6 +6657,10 @@ function SwypePaymentInner({
6655
6657
  await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
6656
6658
  if (authExecutor.pendingOneTapSetup) {
6657
6659
  authExecutor.resolveOneTapSetup();
6660
+ } else if (pendingTokenSelectionRef.current) {
6661
+ const sel = pendingTokenSelectionRef.current;
6662
+ pendingTokenSelectionRef.current = null;
6663
+ dispatch({ type: "SELECT_TOKEN", walletId: sel.walletId, tokenSymbol: sel.tokenSymbol });
6658
6664
  } else {
6659
6665
  dispatch({ type: "NAVIGATE", step: "deposit" });
6660
6666
  }
@@ -6673,6 +6679,7 @@ function SwypePaymentInner({
6673
6679
  processingStartedAtRef.current = null;
6674
6680
  pollingTransferIdRef.current = null;
6675
6681
  preSelectSourceStepRef.current = null;
6682
+ pendingTokenSelectionRef.current = null;
6676
6683
  dispatch({
6677
6684
  type: "NEW_PAYMENT",
6678
6685
  depositAmount,
@@ -6690,6 +6697,7 @@ function SwypePaymentInner({
6690
6697
  }
6691
6698
  polling.stopPolling();
6692
6699
  preSelectSourceStepRef.current = null;
6700
+ pendingTokenSelectionRef.current = null;
6693
6701
  checkingPasskeyRef.current = false;
6694
6702
  setAuthInput("");
6695
6703
  setOtpCode("");
@@ -7189,13 +7197,38 @@ function SwypePaymentInner({
7189
7197
  }, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
7190
7198
  useEffect(() => {
7191
7199
  if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet" || state.step === "setup-status")) {
7200
+ const isDesktop = shouldUseWalletConnector({
7201
+ useWalletConnector: useWalletConnectorProp,
7202
+ userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
7203
+ });
7204
+ if (isDesktop && state.step === "setup-status") {
7205
+ const recommended = pendingSelectSourceAction.metadata?.recommended;
7206
+ const options = pendingSelectSourceAction.metadata?.options ?? [];
7207
+ let chainName;
7208
+ let tokenSymbol;
7209
+ if (pendingTokenAuthRef.current) {
7210
+ const { tokenAddress, chainId } = pendingTokenAuthRef.current;
7211
+ const chainIdHex = `0x${chainId.toString(16)}`;
7212
+ const match = options.find(
7213
+ (opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
7214
+ );
7215
+ chainName = match?.chainName ?? recommended?.chainName ?? "Base";
7216
+ tokenSymbol = match?.tokenSymbol ?? recommended?.tokenSymbol ?? "USDC";
7217
+ } else {
7218
+ const choices = buildSelectSourceChoices(options);
7219
+ chainName = recommended?.chainName ?? choices[0]?.chainName ?? "Base";
7220
+ tokenSymbol = recommended?.tokenSymbol ?? choices[0]?.tokens[0]?.tokenSymbol ?? "USDC";
7221
+ }
7222
+ authExecutor.resolveSelectSource({ chainName, tokenSymbol });
7223
+ return;
7224
+ }
7192
7225
  preSelectSourceStepRef.current = state.step;
7193
7226
  dispatch({ type: "NAVIGATE", step: "select-source" });
7194
7227
  } else if (!pendingSelectSourceAction && state.step === "select-source") {
7195
7228
  dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
7196
7229
  preSelectSourceStepRef.current = null;
7197
7230
  }
7198
- }, [pendingSelectSourceAction, state.step, authExecutor]);
7231
+ }, [pendingSelectSourceAction, state.step, authExecutor, useWalletConnectorProp]);
7199
7232
  const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
7200
7233
  const preOneTapSetupStepRef = useRef(null);
7201
7234
  useEffect(() => {