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