@unifold/connect-react 0.1.40 → 0.1.41

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
@@ -1182,7 +1182,7 @@ __export(index_exports, {
1182
1182
  module.exports = __toCommonJS(index_exports);
1183
1183
 
1184
1184
  // src/provider.tsx
1185
- var import_react25 = __toESM(require("react"));
1185
+ var import_react26 = __toESM(require("react"));
1186
1186
 
1187
1187
  // ../react-provider/dist/index.mjs
1188
1188
  var import_react = require("react");
@@ -6885,9 +6885,10 @@ var import_jsx_runtime52 = require("react/jsx-runtime");
6885
6885
  var import_react21 = require("react");
6886
6886
  var import_jsx_runtime53 = require("react/jsx-runtime");
6887
6887
  var import_jsx_runtime54 = require("react/jsx-runtime");
6888
+ var import_react22 = require("react");
6888
6889
  var import_jsx_runtime55 = require("react/jsx-runtime");
6889
6890
  var import_jsx_runtime56 = require("react/jsx-runtime");
6890
- var import_react22 = require("react");
6891
+ var import_react23 = require("react");
6891
6892
  var React242 = __toESM(require("react"), 1);
6892
6893
 
6893
6894
  // ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._aqltx4jspgwttwvtzmq3z5uagy/node_modules/@radix-ui/react-tooltip/dist/index.mjs
@@ -9627,7 +9628,7 @@ var Content22 = TooltipContent;
9627
9628
  // ../ui-react/dist/index.mjs
9628
9629
  var import_jsx_runtime57 = require("react/jsx-runtime");
9629
9630
  var import_jsx_runtime58 = require("react/jsx-runtime");
9630
- var import_react23 = require("react");
9631
+ var import_react24 = require("react");
9631
9632
  var React252 = __toESM(require("react"), 1);
9632
9633
 
9633
9634
  // ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_5n4syhs66qrtkkphe44qzgdimq/node_modules/@radix-ui/react-select/dist/index.mjs
@@ -10870,7 +10871,7 @@ var import_jsx_runtime61 = require("react/jsx-runtime");
10870
10871
  var import_jsx_runtime62 = require("react/jsx-runtime");
10871
10872
  var import_jsx_runtime63 = require("react/jsx-runtime");
10872
10873
  var import_jsx_runtime64 = require("react/jsx-runtime");
10873
- var import_react24 = require("react");
10874
+ var import_react25 = require("react");
10874
10875
  var import_jsx_runtime65 = require("react/jsx-runtime");
10875
10876
  var import_jsx_runtime66 = require("react/jsx-runtime");
10876
10877
  var React272 = __toESM(require("react"), 1);
@@ -18499,6 +18500,104 @@ function DepositPollingUi({
18499
18500
  }
18500
18501
  return null;
18501
18502
  }
18503
+ var getChainKey = (chainId, chainType) => {
18504
+ return `${chainType}:${chainId}`;
18505
+ };
18506
+ function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
18507
+ if (!supportedTokens.length) return null;
18508
+ let selectedTokenData;
18509
+ let selectedChainData;
18510
+ const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
18511
+ if (defaultSourceTokenAddress && hasChainDefaults) {
18512
+ for (const t7 of supportedTokens) {
18513
+ const matchingChain = t7.chains.find(
18514
+ (c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
18515
+ );
18516
+ if (matchingChain) {
18517
+ selectedTokenData = t7;
18518
+ selectedChainData = matchingChain;
18519
+ break;
18520
+ }
18521
+ }
18522
+ }
18523
+ if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
18524
+ for (const t7 of supportedTokens) {
18525
+ if (t7.symbol !== defaultSourceSymbol) continue;
18526
+ const matchedChain = t7.chains.find(
18527
+ (c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
18528
+ );
18529
+ if (matchedChain) {
18530
+ selectedTokenData = t7;
18531
+ selectedChainData = matchedChain;
18532
+ break;
18533
+ }
18534
+ }
18535
+ }
18536
+ if (!selectedTokenData) {
18537
+ for (const t7 of supportedTokens) {
18538
+ if (t7.chains.length > 0) {
18539
+ selectedTokenData = t7;
18540
+ selectedChainData = t7.chains[0];
18541
+ break;
18542
+ }
18543
+ }
18544
+ }
18545
+ if (selectedTokenData && selectedChainData) {
18546
+ return { token: selectedTokenData, chain: selectedChainData };
18547
+ }
18548
+ return null;
18549
+ }
18550
+ function useDefaultSourceToken({
18551
+ supportedTokens,
18552
+ defaultSourceChainType,
18553
+ defaultSourceChainId,
18554
+ defaultSourceTokenAddress,
18555
+ defaultSourceSymbol
18556
+ }) {
18557
+ const [token, setToken] = (0, import_react22.useState)(null);
18558
+ const [chain, setChain] = (0, import_react22.useState)(null);
18559
+ const [initialSelectionDone, setInitialSelectionDone] = (0, import_react22.useState)(false);
18560
+ const appliedDefaultsRef = (0, import_react22.useRef)("");
18561
+ (0, import_react22.useEffect)(() => {
18562
+ if (!supportedTokens.length) return;
18563
+ const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
18564
+ const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
18565
+ if (initialSelectionDone && !defaultsChanged) return;
18566
+ const result = resolveSourceToken(
18567
+ supportedTokens,
18568
+ defaultSourceChainType,
18569
+ defaultSourceChainId,
18570
+ defaultSourceTokenAddress,
18571
+ defaultSourceSymbol
18572
+ );
18573
+ if (result) {
18574
+ setToken(result.token.symbol);
18575
+ setChain(getChainKey(result.chain.chain_id, result.chain.chain_type));
18576
+ appliedDefaultsRef.current = defaultsKey;
18577
+ setInitialSelectionDone(true);
18578
+ }
18579
+ }, [
18580
+ supportedTokens,
18581
+ defaultSourceTokenAddress,
18582
+ defaultSourceSymbol,
18583
+ defaultSourceChainType,
18584
+ defaultSourceChainId,
18585
+ initialSelectionDone
18586
+ ]);
18587
+ (0, import_react22.useEffect)(() => {
18588
+ if (!supportedTokens.length || !token) return;
18589
+ const currentToken = supportedTokens.find((t7) => t7.symbol === token);
18590
+ if (!currentToken || currentToken.chains.length === 0) return;
18591
+ const isChainAvailable = chain && currentToken.chains.some((c) => {
18592
+ return getChainKey(c.chain_id, c.chain_type) === chain;
18593
+ });
18594
+ if (!isChainAvailable) {
18595
+ const firstChain = currentToken.chains[0];
18596
+ setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
18597
+ }
18598
+ }, [token, supportedTokens, chain]);
18599
+ return { token, chain, setToken, setChain, initialSelectionDone };
18600
+ }
18502
18601
  function DepositFooterLinks({
18503
18602
  onGlossaryClick
18504
18603
  }) {
@@ -18658,7 +18757,7 @@ function GlossaryModal({
18658
18757
  ) });
18659
18758
  }
18660
18759
  function useCopyAddress() {
18661
- const [copied, setCopied] = (0, import_react22.useState)(false);
18760
+ const [copied, setCopied] = (0, import_react23.useState)(false);
18662
18761
  const handleCopy = (address) => {
18663
18762
  if (!address) return;
18664
18763
  navigator.clipboard.writeText(address);
@@ -18704,7 +18803,7 @@ var TooltipContent2 = React242.forwardRef(({ className, sideOffset = 4, ...props
18704
18803
  });
18705
18804
  TooltipContent2.displayName = Content22.displayName;
18706
18805
  var t4 = i18n2.transferCrypto;
18707
- var getChainKey = (chainId, chainType) => {
18806
+ var getChainKey2 = (chainId, chainType) => {
18708
18807
  return `${chainType}:${chainId}`;
18709
18808
  };
18710
18809
  var parseChainKey = (chainKey) => {
@@ -18718,6 +18817,10 @@ function TransferCryptoSingleInput({
18718
18817
  destinationChainType,
18719
18818
  destinationChainId,
18720
18819
  destinationTokenAddress,
18820
+ defaultSourceChainType,
18821
+ defaultSourceChainId,
18822
+ defaultSourceTokenAddress,
18823
+ defaultSourceSymbol,
18721
18824
  depositConfirmationMode = "auto_ui",
18722
18825
  onExecutionsChange,
18723
18826
  onDepositSuccess,
@@ -18726,21 +18829,25 @@ function TransferCryptoSingleInput({
18726
18829
  }) {
18727
18830
  const { themeClass, colors: colors2, fonts, components } = useTheme();
18728
18831
  const isDarkMode = themeClass.includes("uf-dark");
18729
- const [token, setToken] = (0, import_react18.useState)("USDC");
18730
- const [chain, setChain] = (0, import_react18.useState)("solana:mainnet");
18731
18832
  const [copied, setCopied] = (0, import_react18.useState)(false);
18732
18833
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
18733
18834
  const [glossaryOpen, setGlossaryOpen] = (0, import_react18.useState)(false);
18734
18835
  const [detailsExpanded, setDetailsExpanded] = (0, import_react18.useState)(false);
18735
18836
  const [depositsModalOpen, setDepositsModalOpen] = (0, import_react18.useState)(false);
18736
18837
  const [tokenSelectorOpen, setTokenSelectorOpen] = (0, import_react18.useState)(false);
18737
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react18.useState)(false);
18738
18838
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
18739
18839
  destination_token_address: destinationTokenAddress,
18740
18840
  destination_chain_id: destinationChainId,
18741
18841
  destination_chain_type: destinationChainType
18742
18842
  });
18743
18843
  const supportedTokens = tokensResponse?.data ?? [];
18844
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
18845
+ supportedTokens,
18846
+ defaultSourceChainType,
18847
+ defaultSourceChainId,
18848
+ defaultSourceTokenAddress,
18849
+ defaultSourceSymbol
18850
+ });
18744
18851
  const {
18745
18852
  data: depositAddressResponse,
18746
18853
  isLoading: walletsLoading,
@@ -18770,10 +18877,10 @@ function TransferCryptoSingleInput({
18770
18877
  });
18771
18878
  return Array.from(chainsMap.values());
18772
18879
  }, [supportedTokens]);
18773
- const currentChainCombo = parseChainKey(chain);
18774
- const currentChainData = allAvailableChains.find(
18880
+ const currentChainCombo = chain ? parseChainKey(chain) : null;
18881
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
18775
18882
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
18776
- );
18883
+ ) : void 0;
18777
18884
  const currentChainType = currentChainData?.chain_type || "ethereum";
18778
18885
  const currentWallet = getWalletByChainType(wallets, currentChainType);
18779
18886
  const depositAddress = currentWallet?.address || "";
@@ -18791,78 +18898,20 @@ function TransferCryptoSingleInput({
18791
18898
  onDepositSuccess,
18792
18899
  onDepositError
18793
18900
  });
18794
- (0, import_react18.useEffect)(() => {
18795
- if (!supportedTokens.length || initialSelectionDone) return;
18796
- let selectedTokenData;
18797
- let selectedChainData;
18798
- if (destinationTokenAddress) {
18799
- for (const t7 of supportedTokens) {
18800
- const matchingChain = t7.chains.find(
18801
- (c) => c.token_address.toLowerCase() === destinationTokenAddress.toLowerCase()
18802
- );
18803
- if (matchingChain) {
18804
- selectedTokenData = t7;
18805
- selectedChainData = matchingChain;
18806
- break;
18807
- }
18808
- }
18809
- }
18810
- if (!selectedTokenData) {
18811
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDC");
18812
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
18813
- selectedChainData = selectedTokenData.chains[0];
18814
- }
18815
- }
18816
- if (!selectedTokenData) {
18817
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDT");
18818
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
18819
- selectedChainData = selectedTokenData.chains[0];
18820
- }
18821
- }
18822
- if (!selectedTokenData) {
18823
- selectedTokenData = supportedTokens[0];
18824
- if (selectedTokenData.chains.length > 0) {
18825
- selectedChainData = selectedTokenData.chains[0];
18826
- }
18827
- }
18828
- if (selectedTokenData) {
18829
- setToken(selectedTokenData.symbol);
18830
- }
18831
- if (selectedChainData) {
18832
- setChain(
18833
- getChainKey(selectedChainData.chain_id, selectedChainData.chain_type)
18834
- );
18835
- }
18836
- setInitialSelectionDone(true);
18837
- }, [supportedTokens, destinationTokenAddress, initialSelectionDone]);
18838
18901
  (0, import_react18.useEffect)(() => {
18839
18902
  if (onExecutionsChange) {
18840
18903
  onExecutionsChange(depositExecutions);
18841
18904
  }
18842
18905
  }, [depositExecutions, onExecutionsChange]);
18843
- (0, import_react18.useEffect)(() => {
18844
- if (!supportedTokens.length) return;
18845
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
18846
- if (!currentToken || currentToken.chains.length === 0) return;
18847
- const isChainAvailable = currentToken.chains.some((c) => {
18848
- const key = getChainKey(c.chain_id, c.chain_type);
18849
- return key === chain;
18850
- });
18851
- if (!isChainAvailable) {
18852
- const firstChain = currentToken.chains[0];
18853
- const newChain = getChainKey(firstChain.chain_id, firstChain.chain_type);
18854
- setChain(newChain);
18855
- }
18856
- }, [token, supportedTokens, chain]);
18857
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
18906
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
18858
18907
  const availableChainsForToken = selectedToken?.chains || [];
18859
- const currentChainFromBackend = availableChainsForToken.find((c) => {
18860
- const key = getChainKey(c.chain_id, c.chain_type);
18908
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
18909
+ const key = getChainKey2(c.chain_id, c.chain_type);
18861
18910
  return key === chain;
18862
18911
  }) || allAvailableChains.find((c) => {
18863
- const key = getChainKey(c.chain_id, c.chain_type);
18912
+ const key = getChainKey2(c.chain_id, c.chain_type);
18864
18913
  return key === chain;
18865
- });
18914
+ }) : void 0;
18866
18915
  const handleCopyAddress = () => {
18867
18916
  navigator.clipboard.writeText(depositAddress);
18868
18917
  setCopied(true);
@@ -18897,10 +18946,10 @@ function TransferCryptoSingleInput({
18897
18946
  "button",
18898
18947
  {
18899
18948
  onClick: () => setTokenSelectorOpen(true),
18900
- disabled: tokensLoading || supportedTokens.length === 0,
18949
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
18901
18950
  className: "uf-w-full hover:uf-bg-accent uf-p-3 uf-flex uf-items-center uf-gap-3 uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed",
18902
18951
  style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
18903
- children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
18952
+ children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
18904
18953
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-w-10 uf-h-10 uf-rounded-full uf-bg-muted" }),
18905
18954
  /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex-1", children: [
18906
18955
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-h-4 uf-w-16 uf-bg-muted uf-rounded uf-mb-1" }),
@@ -18974,8 +19023,8 @@ function TransferCryptoSingleInput({
18974
19023
  open: tokenSelectorOpen,
18975
19024
  onOpenChange: setTokenSelectorOpen,
18976
19025
  tokens: supportedTokens,
18977
- selectedToken: token,
18978
- selectedChainKey: chain,
19026
+ selectedToken: token ?? "",
19027
+ selectedChainKey: chain ?? "",
18979
19028
  onSelect: (newToken, newChain) => {
18980
19029
  setToken(newToken);
18981
19030
  setChain(newChain);
@@ -19313,7 +19362,7 @@ var SelectSeparator2 = React252.forwardRef(({ className, ...props }, ref) => /*
19313
19362
  ));
19314
19363
  SelectSeparator2.displayName = Separator.displayName;
19315
19364
  var t5 = i18n2.transferCrypto;
19316
- var getChainKey2 = (chainId, chainType) => {
19365
+ var getChainKey3 = (chainId, chainType) => {
19317
19366
  return `${chainType}:${chainId}`;
19318
19367
  };
19319
19368
  var parseChainKey2 = (chainKey) => {
@@ -19327,6 +19376,10 @@ function TransferCryptoDoubleInput({
19327
19376
  destinationChainType,
19328
19377
  destinationChainId,
19329
19378
  destinationTokenAddress,
19379
+ defaultSourceChainType,
19380
+ defaultSourceChainId,
19381
+ defaultSourceTokenAddress,
19382
+ defaultSourceSymbol,
19330
19383
  depositConfirmationMode = "auto_ui",
19331
19384
  onExecutionsChange,
19332
19385
  onDepositSuccess,
@@ -19335,20 +19388,24 @@ function TransferCryptoDoubleInput({
19335
19388
  }) {
19336
19389
  const { themeClass, colors: colors2, fonts, components } = useTheme();
19337
19390
  const isDarkMode = themeClass.includes("uf-dark");
19338
- const [token, setToken] = (0, import_react23.useState)("USDC");
19339
- const [chain, setChain] = (0, import_react23.useState)("solana:mainnet");
19340
- const [copied, setCopied] = (0, import_react23.useState)(false);
19391
+ const [copied, setCopied] = (0, import_react24.useState)(false);
19341
19392
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
19342
- const [glossaryOpen, setGlossaryOpen] = (0, import_react23.useState)(false);
19343
- const [detailsExpanded, setDetailsExpanded] = (0, import_react23.useState)(false);
19344
- const [depositsModalOpen, setDepositsModalOpen] = (0, import_react23.useState)(false);
19345
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react23.useState)(false);
19393
+ const [glossaryOpen, setGlossaryOpen] = (0, import_react24.useState)(false);
19394
+ const [detailsExpanded, setDetailsExpanded] = (0, import_react24.useState)(false);
19395
+ const [depositsModalOpen, setDepositsModalOpen] = (0, import_react24.useState)(false);
19346
19396
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
19347
19397
  destination_token_address: destinationTokenAddress,
19348
19398
  destination_chain_id: destinationChainId,
19349
19399
  destination_chain_type: destinationChainType
19350
19400
  });
19351
19401
  const supportedTokens = tokensResponse?.data ?? [];
19402
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
19403
+ supportedTokens,
19404
+ defaultSourceChainType,
19405
+ defaultSourceChainId,
19406
+ defaultSourceTokenAddress,
19407
+ defaultSourceSymbol
19408
+ });
19352
19409
  const {
19353
19410
  data: depositAddressResponse,
19354
19411
  isLoading: walletsLoading,
@@ -19366,7 +19423,7 @@ function TransferCryptoDoubleInput({
19366
19423
  const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
19367
19424
  const loading = externalWallets?.length ? false : walletsLoading;
19368
19425
  const error = walletsError?.message ?? null;
19369
- const allAvailableChains = (0, import_react23.useMemo)(() => {
19426
+ const allAvailableChains = (0, import_react24.useMemo)(() => {
19370
19427
  const chainsMap = /* @__PURE__ */ new Map();
19371
19428
  supportedTokens.forEach((t7) => {
19372
19429
  t7.chains.forEach((c) => {
@@ -19378,10 +19435,10 @@ function TransferCryptoDoubleInput({
19378
19435
  });
19379
19436
  return Array.from(chainsMap.values());
19380
19437
  }, [supportedTokens]);
19381
- const currentChainCombo = parseChainKey2(chain);
19382
- const currentChainData = allAvailableChains.find(
19438
+ const currentChainCombo = chain ? parseChainKey2(chain) : null;
19439
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
19383
19440
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
19384
- );
19441
+ ) : void 0;
19385
19442
  const currentChainType = currentChainData?.chain_type || "ethereum";
19386
19443
  const currentWallet = getWalletByChainType(wallets, currentChainType);
19387
19444
  const depositAddress = currentWallet?.address || "";
@@ -19399,51 +19456,20 @@ function TransferCryptoDoubleInput({
19399
19456
  onDepositSuccess,
19400
19457
  onDepositError
19401
19458
  });
19402
- (0, import_react23.useEffect)(() => {
19403
- if (!supportedTokens.length || initialSelectionDone) return;
19404
- const allChains = /* @__PURE__ */ new Set();
19405
- supportedTokens.forEach((t7) => {
19406
- t7.chains.forEach((c) => {
19407
- allChains.add(getChainKey2(c.chain_id, c.chain_type));
19408
- });
19409
- });
19410
- if (!allChains.has(chain)) {
19411
- const firstToken = supportedTokens[0];
19412
- if (firstToken.chains.length > 0) {
19413
- const firstChain = firstToken.chains[0];
19414
- setChain(getChainKey2(firstChain.chain_id, firstChain.chain_type));
19415
- }
19416
- }
19417
- setInitialSelectionDone(true);
19418
- }, [supportedTokens, chain, initialSelectionDone]);
19419
- (0, import_react23.useEffect)(() => {
19459
+ (0, import_react24.useEffect)(() => {
19420
19460
  if (onExecutionsChange) {
19421
19461
  onExecutionsChange(depositExecutions);
19422
19462
  }
19423
19463
  }, [depositExecutions, onExecutionsChange]);
19424
- (0, import_react23.useEffect)(() => {
19425
- if (!supportedTokens.length) return;
19426
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
19427
- if (!currentToken || currentToken.chains.length === 0) return;
19428
- const isChainAvailable = currentToken.chains.some((c) => {
19429
- const key = getChainKey2(c.chain_id, c.chain_type);
19430
- return key === chain;
19431
- });
19432
- if (!isChainAvailable) {
19433
- const firstChain = currentToken.chains[0];
19434
- const newChain = getChainKey2(firstChain.chain_id, firstChain.chain_type);
19435
- setChain(newChain);
19436
- }
19437
- }, [token, supportedTokens, chain]);
19438
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
19464
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
19439
19465
  const availableChainsForToken = selectedToken?.chains || [];
19440
- const currentChainFromBackend = availableChainsForToken.find((c) => {
19441
- const key = getChainKey2(c.chain_id, c.chain_type);
19466
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
19467
+ const key = getChainKey3(c.chain_id, c.chain_type);
19442
19468
  return key === chain;
19443
19469
  }) || allAvailableChains.find((c) => {
19444
- const key = getChainKey2(c.chain_id, c.chain_type);
19470
+ const key = getChainKey3(c.chain_id, c.chain_type);
19445
19471
  return key === chain;
19446
- });
19472
+ }) : void 0;
19447
19473
  const handleCopyAddress = () => {
19448
19474
  navigator.clipboard.writeText(depositAddress);
19449
19475
  setCopied(true);
@@ -19517,11 +19543,11 @@ function TransferCryptoDoubleInput({
19517
19543
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
19518
19544
  Select2,
19519
19545
  {
19520
- value: token,
19546
+ value: token ?? "",
19521
19547
  onValueChange: setToken,
19522
- disabled: tokensLoading || supportedTokens.length === 0,
19548
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
19523
19549
  children: [
19524
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
19550
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
19525
19551
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectContent2, { className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px]", style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} }, children: supportedTokens.map((tokenData) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
19526
19552
  SelectItem2,
19527
19553
  {
@@ -19548,11 +19574,11 @@ function TransferCryptoDoubleInput({
19548
19574
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
19549
19575
  Select2,
19550
19576
  {
19551
- value: chain,
19577
+ value: chain ?? "",
19552
19578
  onValueChange: setChain,
19553
- disabled: tokensLoading || availableChainsForToken.length === 0,
19579
+ disabled: tokensLoading || !chain || availableChainsForToken.length === 0,
19554
19580
  children: [
19555
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : currentChainFromBackend ? renderChainItem(currentChainFromBackend) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
19581
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading || !chain ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : currentChainFromBackend ? renderChainItem(currentChainFromBackend) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
19556
19582
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
19557
19583
  SelectContent2,
19558
19584
  {
@@ -19560,7 +19586,7 @@ function TransferCryptoDoubleInput({
19560
19586
  className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px] uf-min-w-[200px]",
19561
19587
  style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} },
19562
19588
  children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-px-2 uf-py-3 uf-text-xs uf-text-muted-foreground uf-text-center", children: t5.noChainsAvailable }) : availableChainsForToken.map((chainData) => {
19563
- const chainKey = getChainKey2(
19589
+ const chainKey = getChainKey3(
19564
19590
  chainData.chain_id,
19565
19591
  chainData.chain_type
19566
19592
  );
@@ -20555,8 +20581,8 @@ function ConfirmingView({
20555
20581
  isPolling = false
20556
20582
  }) {
20557
20583
  const { colors: colors2, fonts } = useTheme();
20558
- const [containerEl, setContainerEl] = (0, import_react24.useState)(null);
20559
- const containerCallbackRef = (0, import_react24.useCallback)((el) => {
20584
+ const [containerEl, setContainerEl] = (0, import_react25.useState)(null);
20585
+ const containerCallbackRef = (0, import_react25.useCallback)((el) => {
20560
20586
  setContainerEl(el);
20561
20587
  }, []);
20562
20588
  return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PortalContainerProvider, { value: containerEl, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
@@ -21928,6 +21954,10 @@ function DepositModal({
21928
21954
  destinationChainType,
21929
21955
  destinationChainId,
21930
21956
  destinationTokenAddress,
21957
+ defaultSourceChainType,
21958
+ defaultSourceChainId,
21959
+ defaultSourceTokenAddress,
21960
+ defaultSourceSymbol,
21931
21961
  hideDepositTracker = false,
21932
21962
  showBalanceHeader = false,
21933
21963
  transferInputVariant = "double_input",
@@ -22360,6 +22390,10 @@ function DepositModal({
22360
22390
  destinationChainType,
22361
22391
  destinationChainId,
22362
22392
  destinationTokenAddress,
22393
+ defaultSourceChainType,
22394
+ defaultSourceChainId,
22395
+ defaultSourceTokenAddress,
22396
+ defaultSourceSymbol,
22363
22397
  depositConfirmationMode,
22364
22398
  onExecutionsChange: setDepositExecutions,
22365
22399
  onDepositSuccess,
@@ -22375,6 +22409,10 @@ function DepositModal({
22375
22409
  destinationChainType,
22376
22410
  destinationChainId,
22377
22411
  destinationTokenAddress,
22412
+ defaultSourceChainType,
22413
+ defaultSourceChainId,
22414
+ defaultSourceTokenAddress,
22415
+ defaultSourceSymbol,
22378
22416
  depositConfirmationMode,
22379
22417
  onExecutionsChange: setDepositExecutions,
22380
22418
  onDepositSuccess,
@@ -22543,17 +22581,17 @@ function UnifoldProvider2({
22543
22581
  publishableKey,
22544
22582
  config
22545
22583
  }) {
22546
- const [isOpen, setIsOpen] = (0, import_react25.useState)(false);
22547
- const [depositConfig, setDepositConfig] = (0, import_react25.useState)(
22584
+ const [isOpen, setIsOpen] = (0, import_react26.useState)(false);
22585
+ const [depositConfig, setDepositConfig] = (0, import_react26.useState)(
22548
22586
  null
22549
22587
  );
22550
- const [resolvedTheme, setResolvedTheme] = import_react25.default.useState("dark");
22551
- (0, import_react25.useEffect)(() => {
22588
+ const [resolvedTheme, setResolvedTheme] = import_react26.default.useState("dark");
22589
+ (0, import_react26.useEffect)(() => {
22552
22590
  if (publishableKey) {
22553
22591
  setApiConfig({ publishableKey });
22554
22592
  }
22555
22593
  }, [publishableKey]);
22556
- import_react25.default.useEffect(() => {
22594
+ import_react26.default.useEffect(() => {
22557
22595
  const appearance = config?.appearance || "dark";
22558
22596
  if (appearance === "auto") {
22559
22597
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
@@ -22568,12 +22606,12 @@ function UnifoldProvider2({
22568
22606
  setResolvedTheme(appearance);
22569
22607
  }
22570
22608
  }, [config?.appearance]);
22571
- const depositPromiseRef = import_react25.default.useRef(null);
22572
- const depositConfigRef = import_react25.default.useRef(null);
22609
+ const depositPromiseRef = import_react26.default.useRef(null);
22610
+ const depositConfigRef = import_react26.default.useRef(null);
22573
22611
  depositConfigRef.current = depositConfig;
22574
- const closeTimeoutRef = import_react25.default.useRef(null);
22575
- const closeGuardRef = import_react25.default.useRef(false);
22576
- const beginDeposit = (0, import_react25.useCallback)((config2) => {
22612
+ const closeTimeoutRef = import_react26.default.useRef(null);
22613
+ const closeGuardRef = import_react26.default.useRef(false);
22614
+ const beginDeposit = (0, import_react26.useCallback)((config2) => {
22577
22615
  if (closeTimeoutRef.current) {
22578
22616
  clearTimeout(closeTimeoutRef.current);
22579
22617
  closeTimeoutRef.current = null;
@@ -22596,7 +22634,7 @@ function UnifoldProvider2({
22596
22634
  setIsOpen(true);
22597
22635
  return promise;
22598
22636
  }, []);
22599
- const closeDeposit = (0, import_react25.useCallback)(() => {
22637
+ const closeDeposit = (0, import_react26.useCallback)(() => {
22600
22638
  if (closeGuardRef.current) {
22601
22639
  return;
22602
22640
  }
@@ -22618,7 +22656,7 @@ function UnifoldProvider2({
22618
22656
  closeTimeoutRef.current = null;
22619
22657
  }, 200);
22620
22658
  }, []);
22621
- const handleDepositSuccess = (0, import_react25.useCallback)((data) => {
22659
+ const handleDepositSuccess = (0, import_react26.useCallback)((data) => {
22622
22660
  if (depositConfig?.onSuccess) {
22623
22661
  depositConfig.onSuccess(data);
22624
22662
  }
@@ -22627,7 +22665,7 @@ function UnifoldProvider2({
22627
22665
  depositPromiseRef.current = null;
22628
22666
  }
22629
22667
  }, [depositConfig]);
22630
- const handleDepositError = (0, import_react25.useCallback)((error) => {
22668
+ const handleDepositError = (0, import_react26.useCallback)((error) => {
22631
22669
  console.error("[UnifoldProvider] Deposit error:", error);
22632
22670
  if (depositConfig?.onError) {
22633
22671
  depositConfig.onError(error);
@@ -22637,7 +22675,7 @@ function UnifoldProvider2({
22637
22675
  depositPromiseRef.current = null;
22638
22676
  }
22639
22677
  }, [depositConfig]);
22640
- const contextValue = (0, import_react25.useMemo)(
22678
+ const contextValue = (0, import_react26.useMemo)(
22641
22679
  () => ({
22642
22680
  beginDeposit,
22643
22681
  closeDeposit,
@@ -22670,6 +22708,10 @@ function UnifoldProvider2({
22670
22708
  destinationChainType: depositConfig.destinationChainType,
22671
22709
  destinationChainId: depositConfig.destinationChainId,
22672
22710
  destinationTokenAddress: depositConfig.destinationTokenAddress,
22711
+ defaultSourceChainType: depositConfig.defaultSourceChainType,
22712
+ defaultSourceChainId: depositConfig.defaultSourceChainId,
22713
+ defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
22714
+ defaultSourceSymbol: depositConfig.defaultSourceSymbol,
22673
22715
  depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
22674
22716
  hideDepositTracker: config?.hideDepositTracker,
22675
22717
  showBalanceHeader: config?.showBalanceHeader,
@@ -22694,10 +22736,10 @@ function UnifoldProvider2({
22694
22736
  }
22695
22737
  ) }) });
22696
22738
  }
22697
- var ConnectContext = import_react25.default.createContext(null);
22739
+ var ConnectContext = import_react26.default.createContext(null);
22698
22740
  function useUnifold2() {
22699
22741
  const baseContext = useUnifold();
22700
- const connectContext = import_react25.default.useContext(ConnectContext);
22742
+ const connectContext = import_react26.default.useContext(ConnectContext);
22701
22743
  if (typeof window === "undefined") {
22702
22744
  return {
22703
22745
  publishableKey: "",