@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 CHANGED
@@ -1,4 +1,5 @@
1
1
  # @swype-org/react-sdk
2
+ Deploy
2
3
 
3
4
  Blink React SDK — drop-in payment widget and hooks for integrating Blink payments.
4
5
 
package/dist/index.cjs CHANGED
@@ -7577,6 +7577,9 @@ function screenForSession(session) {
7577
7577
  return "deposit-failed";
7578
7578
  }
7579
7579
  }
7580
+ function isSameChainSameTokenSelection(option, destination) {
7581
+ return option.chainId === destination.chainId && option.tokenAddress.toLowerCase() === destination.token.address.toLowerCase();
7582
+ }
7580
7583
  function feeCopy(_session) {
7581
7584
  return "No fees";
7582
7585
  }
@@ -7675,9 +7678,13 @@ function useManualTransferSession({
7675
7678
  if (cancelled) return;
7676
7679
  setSourceOptions(sources);
7677
7680
  setLoadingSources(false);
7681
+ const destTokenAddrLower = destination.token.address.toLowerCase();
7682
+ const destMatch = sources.find(
7683
+ (s) => s.chainId === destination.chainId && s.tokenAddress.toLowerCase() === destTokenAddrLower
7684
+ );
7678
7685
  const svmCanonical = sources.find((s) => s.canonical && s.chainFamily === "svm");
7679
7686
  const evmCanonical = sources.find((s) => s.canonical && s.chainFamily === "evm");
7680
- const defaultOption = svmCanonical ?? evmCanonical ?? sources[0];
7687
+ const defaultOption = destMatch ?? svmCanonical ?? evmCanonical ?? sources[0];
7681
7688
  if (defaultOption) {
7682
7689
  setSelectedToken(defaultOption.tokenSymbol);
7683
7690
  setSelectedChainId(String(defaultOption.chainId));
@@ -7774,10 +7781,14 @@ function useManualTransferSession({
7774
7781
  }, [sourceOptions, selectedToken]);
7775
7782
  const session = react.useMemo(() => {
7776
7783
  if (!selectedOption) return null;
7784
+ const perToken = perTokenSessions[perTokenKey(selectedOption.chainId, selectedOption.tokenAddress)] ?? null;
7785
+ if (isSameChainSameTokenSelection(selectedOption, destination)) {
7786
+ return perToken ?? sessionsByFamily[selectedOption.chainFamily] ?? null;
7787
+ }
7777
7788
  const familySession = sessionsByFamily[selectedOption.chainFamily];
7778
7789
  if (familySession) return familySession;
7779
- return perTokenSessions[perTokenKey(selectedOption.chainId, selectedOption.tokenAddress)] ?? null;
7780
- }, [selectedOption, sessionsByFamily, perTokenSessions]);
7790
+ return perToken;
7791
+ }, [selectedOption, destination, sessionsByFamily, perTokenSessions]);
7781
7792
  const depositAddress = session?.depositAddress;
7782
7793
  const qrReady = !!depositAddress;
7783
7794
  const lastFeeCopyRef = react.useRef(null);
@@ -7868,8 +7879,11 @@ function useManualTransferSession({
7868
7879
  }, [apiBaseUrl, destination, idempotencyKey, merchantAuthorization, tokens.text, tokens.bg]);
7869
7880
  react.useEffect(() => {
7870
7881
  if (!selectedOption) return;
7871
- if (sessionsByFamily[selectedOption.chainFamily]) return;
7872
- if (premintedFamiliesRef.current.has(selectedOption.chainFamily)) return;
7882
+ const sameTokenSelection = isSameChainSameTokenSelection(selectedOption, destination);
7883
+ if (!sameTokenSelection) {
7884
+ if (sessionsByFamily[selectedOption.chainFamily]) return;
7885
+ if (premintedFamiliesRef.current.has(selectedOption.chainFamily)) return;
7886
+ }
7873
7887
  const key = perTokenKey(selectedOption.chainId, selectedOption.tokenAddress);
7874
7888
  if (perTokenSessions[key]) return;
7875
7889
  if (inFlightPerTokenRef.current.has(key)) return;
@@ -7877,7 +7891,7 @@ function useManualTransferSession({
7877
7891
  void createSession(selectedOption).finally(() => {
7878
7892
  inFlightPerTokenRef.current.delete(key);
7879
7893
  });
7880
- }, [selectedOption, sessionsByFamily, perTokenSessions, createSession]);
7894
+ }, [selectedOption, destination, sessionsByFamily, perTokenSessions, createSession]);
7881
7895
  const resetSessionForNewSelection = react.useCallback(() => {
7882
7896
  setError(null);
7883
7897
  }, []);