@swype-org/react-sdk 0.1.34 → 0.1.35

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
@@ -3783,6 +3783,7 @@ function SwypePayment({
3783
3783
  const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
3784
3784
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
3785
3785
  const initializedSelectSourceActionRef = react.useRef(null);
3786
+ const preSelectSourceStepRef = react.useRef(null);
3786
3787
  const authExecutor = useAuthorizationExecutor();
3787
3788
  const polling = useTransferPolling();
3788
3789
  const transferSigning = useTransferSigning();
@@ -3798,7 +3799,7 @@ function SwypePayment({
3798
3799
  setVerificationTarget(null);
3799
3800
  setOtpCode("");
3800
3801
  }, []);
3801
- const handleSocialLogin = react.useCallback(async (provider) => {
3802
+ react.useCallback(async (provider) => {
3802
3803
  setError(null);
3803
3804
  try {
3804
3805
  await initOAuth({ provider });
@@ -4062,12 +4063,30 @@ function SwypePayment({
4062
4063
  initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
4063
4064
  }, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
4064
4065
  react.useEffect(() => {
4065
- if (pendingSelectSourceAction && step === "processing") {
4066
+ if (pendingSelectSourceAction && (step === "processing" || step === "setup-status")) {
4067
+ preSelectSourceStepRef.current = step;
4066
4068
  setStep("select-source");
4067
4069
  } else if (!pendingSelectSourceAction && step === "select-source") {
4068
- setStep("processing");
4070
+ setStep(preSelectSourceStepRef.current ?? "processing");
4071
+ preSelectSourceStepRef.current = null;
4069
4072
  }
4070
4073
  }, [pendingSelectSourceAction, step]);
4074
+ const SETUP_ACTION_LABELS = react.useMemo(() => ({
4075
+ OPEN_PROVIDER: "Connecting wallet",
4076
+ SELECT_SOURCE: "Selecting source",
4077
+ SWITCH_CHAIN: "Switching network",
4078
+ APPROVE_PERMIT2: "Approving tokens",
4079
+ SIGN_PERMIT2: "Signing permit",
4080
+ DEPLOY_SMART_ACCOUNT: "Setting up account",
4081
+ CREATE_SMART_ACCOUNT: "Creating account"
4082
+ }), []);
4083
+ react.useEffect(() => {
4084
+ if (step !== "setup-status") return;
4085
+ const actionType = authExecutor.currentAction?.type;
4086
+ if (!actionType) return;
4087
+ const label = SETUP_ACTION_LABELS[actionType];
4088
+ if (label) setSetupStepLabel(label);
4089
+ }, [step, authExecutor.currentAction, SETUP_ACTION_LABELS]);
4071
4090
  const handleSelectSourceChainChange = react.useCallback(
4072
4091
  (chainName) => {
4073
4092
  setSelectSourceChainName(chainName);
@@ -4246,7 +4265,7 @@ function SwypePayment({
4246
4265
  setOneTapLimit(limit);
4247
4266
  setStep("setup-status");
4248
4267
  setSetupComplete(false);
4249
- setSetupStepLabel("Approving tokens");
4268
+ setSetupStepLabel("Preparing");
4250
4269
  setError(null);
4251
4270
  try {
4252
4271
  const token = await getAccessToken();
@@ -4357,8 +4376,7 @@ function SwypePayment({
4357
4376
  sending: activeOtpStatus === "sending-code",
4358
4377
  error,
4359
4378
  onBack,
4360
- merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0,
4361
- onSocialLogin: handleSocialLogin
4379
+ merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
4362
4380
  }
4363
4381
  );
4364
4382
  }