@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.cjs +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2026,11 +2026,17 @@ var METAMASK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.6 3
|
|
|
2026
2026
|
<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"/>
|
|
2027
2027
|
<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"/>
|
|
2028
2028
|
</svg>`;
|
|
2029
|
+
var TRUST_WALLET_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 480" fill="none">
|
|
2030
|
+
<rect width="480" height="480" rx="96" fill="#0500FF"/>
|
|
2031
|
+
<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"/>
|
|
2032
|
+
</svg>`;
|
|
2029
2033
|
var BASE_LOGO = svgToDataUri(BASE_SVG);
|
|
2030
2034
|
var METAMASK_LOGO = svgToDataUri(METAMASK_SVG);
|
|
2035
|
+
var TRUST_WALLET_LOGO = svgToDataUri(TRUST_WALLET_SVG);
|
|
2031
2036
|
var KNOWN_LOGOS = {
|
|
2032
2037
|
metamask: METAMASK_LOGO,
|
|
2033
|
-
base: BASE_LOGO
|
|
2038
|
+
base: BASE_LOGO,
|
|
2039
|
+
"trust wallet": TRUST_WALLET_LOGO
|
|
2034
2040
|
};
|
|
2035
2041
|
function SourceCard({ name, address, verified, onChangeSource }) {
|
|
2036
2042
|
const { tokens } = useSwypeConfig();
|
|
@@ -4507,6 +4513,7 @@ function SwypePaymentInner({
|
|
|
4507
4513
|
const pollingTransferIdRef = react.useRef(null);
|
|
4508
4514
|
const mobileSigningTransferIdRef = react.useRef(null);
|
|
4509
4515
|
const mobileSetupFlowRef = react.useRef(false);
|
|
4516
|
+
const handlingMobileReturnRef = react.useRef(false);
|
|
4510
4517
|
const processingStartedAtRef = react.useRef(null);
|
|
4511
4518
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
4512
4519
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
@@ -4549,6 +4556,8 @@ function SwypePaymentInner({
|
|
|
4549
4556
|
polling.startPolling(persisted.transferId);
|
|
4550
4557
|
}, [polling]);
|
|
4551
4558
|
const handleAuthorizedMobileReturn = react.useCallback(async (authorizedTransfer, isSetup) => {
|
|
4559
|
+
if (handlingMobileReturnRef.current) return;
|
|
4560
|
+
handlingMobileReturnRef.current = true;
|
|
4552
4561
|
polling.stopPolling();
|
|
4553
4562
|
if (isSetup) {
|
|
4554
4563
|
mobileSetupFlowRef.current = false;
|
|
@@ -4562,6 +4571,7 @@ function SwypePaymentInner({
|
|
|
4562
4571
|
setMobileFlow(false);
|
|
4563
4572
|
setStep("deposit");
|
|
4564
4573
|
} catch (err) {
|
|
4574
|
+
handlingMobileReturnRef.current = false;
|
|
4565
4575
|
setError(
|
|
4566
4576
|
err instanceof Error ? err.message : "Wallet authorized, but we could not refresh your account yet."
|
|
4567
4577
|
);
|
|
@@ -4579,6 +4589,7 @@ function SwypePaymentInner({
|
|
|
4579
4589
|
}, [polling.stopPolling, reloadAccounts, resetDataLoadingState]);
|
|
4580
4590
|
const handleRetryMobileStatus = react.useCallback(() => {
|
|
4581
4591
|
setError(null);
|
|
4592
|
+
handlingMobileReturnRef.current = false;
|
|
4582
4593
|
const currentTransfer = polling.transfer ?? transfer;
|
|
4583
4594
|
if (currentTransfer?.status === "AUTHORIZED") {
|
|
4584
4595
|
void handleAuthorizedMobileReturn(currentTransfer, mobileSetupFlowRef.current);
|
|
@@ -4610,8 +4621,9 @@ function SwypePaymentInner({
|
|
|
4610
4621
|
const activeOtpStatus = verificationTarget?.kind === "email" ? emailLoginState.status : verificationTarget?.kind === "phone" ? smsLoginState.status : "initial";
|
|
4611
4622
|
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;
|
|
4612
4623
|
react.useEffect(() => {
|
|
4624
|
+
if (authenticated) return;
|
|
4613
4625
|
if (activeOtpErrorMessage) setError(activeOtpErrorMessage);
|
|
4614
|
-
}, [activeOtpErrorMessage]);
|
|
4626
|
+
}, [activeOtpErrorMessage, authenticated]);
|
|
4615
4627
|
const handleSendLoginCode = react.useCallback(async () => {
|
|
4616
4628
|
const normalizedIdentifier = normalizeAuthIdentifier(authInput);
|
|
4617
4629
|
if (!normalizedIdentifier) {
|
|
@@ -4923,18 +4935,23 @@ function SwypePaymentInner({
|
|
|
4923
4935
|
return () => window.clearTimeout(timeoutId);
|
|
4924
4936
|
}, [step, polling.transfer, transfer, polling.stopPolling, onError]);
|
|
4925
4937
|
react.useEffect(() => {
|
|
4926
|
-
if (!mobileFlow)
|
|
4938
|
+
if (!mobileFlow) {
|
|
4939
|
+
handlingMobileReturnRef.current = false;
|
|
4940
|
+
return;
|
|
4941
|
+
}
|
|
4942
|
+
if (handlingMobileReturnRef.current) return;
|
|
4927
4943
|
const polledTransfer = polling.transfer;
|
|
4928
4944
|
if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
|
|
4929
4945
|
void handleAuthorizedMobileReturn(polledTransfer, mobileSetupFlowRef.current);
|
|
4930
4946
|
}, [mobileFlow, polling.transfer, handleAuthorizedMobileReturn]);
|
|
4931
4947
|
react.useEffect(() => {
|
|
4932
4948
|
if (!mobileFlow) return;
|
|
4949
|
+
if (handlingMobileReturnRef.current) return;
|
|
4933
4950
|
const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
|
|
4934
4951
|
if (!transferIdToResume) return;
|
|
4935
4952
|
if (!polling.isPolling) polling.startPolling(transferIdToResume);
|
|
4936
4953
|
const handleVisibility = () => {
|
|
4937
|
-
if (document.visibilityState === "visible") {
|
|
4954
|
+
if (document.visibilityState === "visible" && !handlingMobileReturnRef.current) {
|
|
4938
4955
|
polling.startPolling(transferIdToResume);
|
|
4939
4956
|
}
|
|
4940
4957
|
};
|
|
@@ -5218,6 +5235,7 @@ function SwypePaymentInner({
|
|
|
5218
5235
|
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
5219
5236
|
});
|
|
5220
5237
|
if (isMobile) {
|
|
5238
|
+
handlingMobileReturnRef.current = false;
|
|
5221
5239
|
mobileSetupFlowRef.current = true;
|
|
5222
5240
|
const amount2 = depositAmount ?? 5;
|
|
5223
5241
|
handlePay(amount2, { sourceType: "providerId", sourceId: providerId });
|