@swype-org/react-sdk 0.1.71 → 0.1.75

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
@@ -2023,11 +2023,17 @@ var METAMASK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.6 3
2023
2023
  <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"/>
2024
2024
  <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"/>
2025
2025
  </svg>`;
2026
+ var TRUST_WALLET_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 480" fill="none">
2027
+ <rect width="480" height="480" rx="96" fill="#0500FF"/>
2028
+ <path d="M240 97C291.833 133.09 330.903 139.252 378 139.252C378 269.452 346.233 348.948 240 403C133.767 348.948 102 269.452 102 139.252C149.097 139.252 188.167 133.09 240 97Z" stroke="white" stroke-width="30" stroke-linecap="round" stroke-linejoin="round"/>
2029
+ </svg>`;
2026
2030
  var BASE_LOGO = svgToDataUri(BASE_SVG);
2027
2031
  var METAMASK_LOGO = svgToDataUri(METAMASK_SVG);
2032
+ var TRUST_WALLET_LOGO = svgToDataUri(TRUST_WALLET_SVG);
2028
2033
  var KNOWN_LOGOS = {
2029
2034
  metamask: METAMASK_LOGO,
2030
- base: BASE_LOGO
2035
+ base: BASE_LOGO,
2036
+ "trust wallet": TRUST_WALLET_LOGO
2031
2037
  };
2032
2038
  function SourceCard({ name, address, verified, onChangeSource }) {
2033
2039
  const { tokens } = useSwypeConfig();
@@ -4504,6 +4510,7 @@ function SwypePaymentInner({
4504
4510
  const pollingTransferIdRef = useRef(null);
4505
4511
  const mobileSigningTransferIdRef = useRef(null);
4506
4512
  const mobileSetupFlowRef = useRef(false);
4513
+ const handlingMobileReturnRef = useRef(false);
4507
4514
  const processingStartedAtRef = useRef(null);
4508
4515
  const [selectSourceChainName, setSelectSourceChainName] = useState("");
4509
4516
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = useState("");
@@ -4546,6 +4553,8 @@ function SwypePaymentInner({
4546
4553
  polling.startPolling(persisted.transferId);
4547
4554
  }, [polling]);
4548
4555
  const handleAuthorizedMobileReturn = useCallback(async (authorizedTransfer, isSetup) => {
4556
+ if (handlingMobileReturnRef.current) return;
4557
+ handlingMobileReturnRef.current = true;
4549
4558
  polling.stopPolling();
4550
4559
  if (isSetup) {
4551
4560
  mobileSetupFlowRef.current = false;
@@ -4559,6 +4568,7 @@ function SwypePaymentInner({
4559
4568
  setMobileFlow(false);
4560
4569
  setStep("deposit");
4561
4570
  } catch (err) {
4571
+ handlingMobileReturnRef.current = false;
4562
4572
  setError(
4563
4573
  err instanceof Error ? err.message : "Wallet authorized, but we could not refresh your account yet."
4564
4574
  );
@@ -4576,6 +4586,7 @@ function SwypePaymentInner({
4576
4586
  }, [polling.stopPolling, reloadAccounts, resetDataLoadingState]);
4577
4587
  const handleRetryMobileStatus = useCallback(() => {
4578
4588
  setError(null);
4589
+ handlingMobileReturnRef.current = false;
4579
4590
  const currentTransfer = polling.transfer ?? transfer;
4580
4591
  if (currentTransfer?.status === "AUTHORIZED") {
4581
4592
  void handleAuthorizedMobileReturn(currentTransfer, mobileSetupFlowRef.current);
@@ -4607,8 +4618,9 @@ function SwypePaymentInner({
4607
4618
  const activeOtpStatus = verificationTarget?.kind === "email" ? emailLoginState.status : verificationTarget?.kind === "phone" ? smsLoginState.status : "initial";
4608
4619
  const activeOtpErrorMessage = verificationTarget?.kind === "email" && emailLoginState.status === "error" ? emailLoginState.error?.message ?? "Failed to continue with email." : verificationTarget?.kind === "phone" && smsLoginState.status === "error" ? smsLoginState.error?.message ?? "Failed to continue with phone number." : null;
4609
4620
  useEffect(() => {
4621
+ if (authenticated) return;
4610
4622
  if (activeOtpErrorMessage) setError(activeOtpErrorMessage);
4611
- }, [activeOtpErrorMessage]);
4623
+ }, [activeOtpErrorMessage, authenticated]);
4612
4624
  const handleSendLoginCode = useCallback(async () => {
4613
4625
  const normalizedIdentifier = normalizeAuthIdentifier(authInput);
4614
4626
  if (!normalizedIdentifier) {
@@ -4920,18 +4932,23 @@ function SwypePaymentInner({
4920
4932
  return () => window.clearTimeout(timeoutId);
4921
4933
  }, [step, polling.transfer, transfer, polling.stopPolling, onError]);
4922
4934
  useEffect(() => {
4923
- if (!mobileFlow) return;
4935
+ if (!mobileFlow) {
4936
+ handlingMobileReturnRef.current = false;
4937
+ return;
4938
+ }
4939
+ if (handlingMobileReturnRef.current) return;
4924
4940
  const polledTransfer = polling.transfer;
4925
4941
  if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
4926
4942
  void handleAuthorizedMobileReturn(polledTransfer, mobileSetupFlowRef.current);
4927
4943
  }, [mobileFlow, polling.transfer, handleAuthorizedMobileReturn]);
4928
4944
  useEffect(() => {
4929
4945
  if (!mobileFlow) return;
4946
+ if (handlingMobileReturnRef.current) return;
4930
4947
  const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
4931
4948
  if (!transferIdToResume) return;
4932
4949
  if (!polling.isPolling) polling.startPolling(transferIdToResume);
4933
4950
  const handleVisibility = () => {
4934
- if (document.visibilityState === "visible") {
4951
+ if (document.visibilityState === "visible" && !handlingMobileReturnRef.current) {
4935
4952
  polling.startPolling(transferIdToResume);
4936
4953
  }
4937
4954
  };
@@ -5215,6 +5232,7 @@ function SwypePaymentInner({
5215
5232
  userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5216
5233
  });
5217
5234
  if (isMobile) {
5235
+ handlingMobileReturnRef.current = false;
5218
5236
  mobileSetupFlowRef.current = true;
5219
5237
  const amount2 = depositAmount ?? 5;
5220
5238
  handlePay(amount2, { sourceType: "providerId", sourceId: providerId });