@swype-org/react-sdk 0.2.261 → 0.2.263
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/README.md +1 -0
- package/dist/index.cjs +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7553,6 +7553,9 @@ function screenForSession(session) {
|
|
|
7553
7553
|
return "deposit-failed";
|
|
7554
7554
|
}
|
|
7555
7555
|
}
|
|
7556
|
+
function isSameChainSameTokenSelection(option, destination) {
|
|
7557
|
+
return option.chainId === destination.chainId && option.tokenAddress.toLowerCase() === destination.token.address.toLowerCase();
|
|
7558
|
+
}
|
|
7556
7559
|
function feeCopy(_session) {
|
|
7557
7560
|
return "No fees";
|
|
7558
7561
|
}
|
|
@@ -7651,9 +7654,13 @@ function useManualTransferSession({
|
|
|
7651
7654
|
if (cancelled) return;
|
|
7652
7655
|
setSourceOptions(sources);
|
|
7653
7656
|
setLoadingSources(false);
|
|
7657
|
+
const destTokenAddrLower = destination.token.address.toLowerCase();
|
|
7658
|
+
const destMatch = sources.find(
|
|
7659
|
+
(s) => s.chainId === destination.chainId && s.tokenAddress.toLowerCase() === destTokenAddrLower
|
|
7660
|
+
);
|
|
7654
7661
|
const svmCanonical = sources.find((s) => s.canonical && s.chainFamily === "svm");
|
|
7655
7662
|
const evmCanonical = sources.find((s) => s.canonical && s.chainFamily === "evm");
|
|
7656
|
-
const defaultOption = svmCanonical ?? evmCanonical ?? sources[0];
|
|
7663
|
+
const defaultOption = destMatch ?? svmCanonical ?? evmCanonical ?? sources[0];
|
|
7657
7664
|
if (defaultOption) {
|
|
7658
7665
|
setSelectedToken(defaultOption.tokenSymbol);
|
|
7659
7666
|
setSelectedChainId(String(defaultOption.chainId));
|
|
@@ -7750,10 +7757,14 @@ function useManualTransferSession({
|
|
|
7750
7757
|
}, [sourceOptions, selectedToken]);
|
|
7751
7758
|
const session = useMemo(() => {
|
|
7752
7759
|
if (!selectedOption) return null;
|
|
7760
|
+
const perToken = perTokenSessions[perTokenKey(selectedOption.chainId, selectedOption.tokenAddress)] ?? null;
|
|
7761
|
+
if (isSameChainSameTokenSelection(selectedOption, destination)) {
|
|
7762
|
+
return perToken ?? sessionsByFamily[selectedOption.chainFamily] ?? null;
|
|
7763
|
+
}
|
|
7753
7764
|
const familySession = sessionsByFamily[selectedOption.chainFamily];
|
|
7754
7765
|
if (familySession) return familySession;
|
|
7755
|
-
return
|
|
7756
|
-
}, [selectedOption, sessionsByFamily, perTokenSessions]);
|
|
7766
|
+
return perToken;
|
|
7767
|
+
}, [selectedOption, destination, sessionsByFamily, perTokenSessions]);
|
|
7757
7768
|
const depositAddress = session?.depositAddress;
|
|
7758
7769
|
const qrReady = !!depositAddress;
|
|
7759
7770
|
const lastFeeCopyRef = useRef(null);
|
|
@@ -7844,8 +7855,11 @@ function useManualTransferSession({
|
|
|
7844
7855
|
}, [apiBaseUrl, destination, idempotencyKey, merchantAuthorization, tokens.text, tokens.bg]);
|
|
7845
7856
|
useEffect(() => {
|
|
7846
7857
|
if (!selectedOption) return;
|
|
7847
|
-
|
|
7848
|
-
if (
|
|
7858
|
+
const sameTokenSelection = isSameChainSameTokenSelection(selectedOption, destination);
|
|
7859
|
+
if (!sameTokenSelection) {
|
|
7860
|
+
if (sessionsByFamily[selectedOption.chainFamily]) return;
|
|
7861
|
+
if (premintedFamiliesRef.current.has(selectedOption.chainFamily)) return;
|
|
7862
|
+
}
|
|
7849
7863
|
const key = perTokenKey(selectedOption.chainId, selectedOption.tokenAddress);
|
|
7850
7864
|
if (perTokenSessions[key]) return;
|
|
7851
7865
|
if (inFlightPerTokenRef.current.has(key)) return;
|
|
@@ -7853,7 +7867,7 @@ function useManualTransferSession({
|
|
|
7853
7867
|
void createSession(selectedOption).finally(() => {
|
|
7854
7868
|
inFlightPerTokenRef.current.delete(key);
|
|
7855
7869
|
});
|
|
7856
|
-
}, [selectedOption, sessionsByFamily, perTokenSessions, createSession]);
|
|
7870
|
+
}, [selectedOption, destination, sessionsByFamily, perTokenSessions, createSession]);
|
|
7857
7871
|
const resetSessionForNewSelection = useCallback(() => {
|
|
7858
7872
|
setError(null);
|
|
7859
7873
|
}, []);
|