@unifold/ui-web 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.
Files changed (3) hide show
  1. package/dist/index.js +196 -154
  2. package/dist/index.mjs +196 -154
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -34407,7 +34407,7 @@ __export(index_exports, {
34407
34407
  module.exports = __toCommonJS(index_exports);
34408
34408
 
34409
34409
  // src/unifold.tsx
34410
- var import_react26 = __toESM(require_react());
34410
+ var import_react27 = __toESM(require_react());
34411
34411
  var import_client = __toESM(require_client());
34412
34412
 
34413
34413
  // ../connect-react/dist/index.mjs
@@ -37182,14 +37182,15 @@ var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
37182
37182
  var import_react19 = __toESM(require_react(), 1);
37183
37183
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
37184
37184
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
37185
+ var import_react20 = __toESM(require_react(), 1);
37185
37186
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
37186
37187
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
37187
- var import_react20 = __toESM(require_react(), 1);
37188
+ var import_react21 = __toESM(require_react(), 1);
37188
37189
  var React242 = __toESM(require_react(), 1);
37189
37190
  var React31 = __toESM(require_react(), 1);
37190
37191
  var React29 = __toESM(require_react(), 1);
37191
37192
  var React26 = __toESM(require_react(), 1);
37192
- var import_react21 = __toESM(require_react(), 1);
37193
+ var import_react22 = __toESM(require_react(), 1);
37193
37194
  var ReactDOM3 = __toESM(require_react_dom(), 1);
37194
37195
  var React27 = __toESM(require_react(), 1);
37195
37196
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
@@ -37200,13 +37201,13 @@ var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
37200
37201
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
37201
37202
  var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
37202
37203
  var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
37203
- var import_react22 = __toESM(require_react(), 1);
37204
+ var import_react23 = __toESM(require_react(), 1);
37204
37205
  var React252 = __toESM(require_react(), 1);
37205
37206
  var React35 = __toESM(require_react(), 1);
37206
37207
  var ReactDOM4 = __toESM(require_react_dom(), 1);
37207
- var import_react23 = __toESM(require_react(), 1);
37208
- var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
37209
37208
  var import_react24 = __toESM(require_react(), 1);
37209
+ var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
37210
+ var import_react25 = __toESM(require_react(), 1);
37210
37211
  var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
37211
37212
  var React33 = __toESM(require_react(), 1);
37212
37213
  var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
@@ -37219,7 +37220,7 @@ var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
37219
37220
  var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
37220
37221
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
37221
37222
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
37222
- var import_react25 = __toESM(require_react(), 1);
37223
+ var import_react26 = __toESM(require_react(), 1);
37223
37224
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
37224
37225
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
37225
37226
  var React272 = __toESM(require_react(), 1);
@@ -45258,7 +45259,7 @@ var computePosition2 = (reference, floating, options2) => {
45258
45259
  var isClient = typeof document !== "undefined";
45259
45260
  var noop2 = function noop22() {
45260
45261
  };
45261
- var index = isClient ? import_react21.useLayoutEffect : noop2;
45262
+ var index = isClient ? import_react22.useLayoutEffect : noop2;
45262
45263
  function deepEqual(a, b) {
45263
45264
  if (a === b) {
45264
45265
  return true;
@@ -46367,14 +46368,14 @@ function createCollection(name) {
46367
46368
  );
46368
46369
  const CollectionProvider = (props) => {
46369
46370
  const { scope, children } = props;
46370
- const ref = import_react23.default.useRef(null);
46371
- const itemMap = import_react23.default.useRef(/* @__PURE__ */ new Map()).current;
46371
+ const ref = import_react24.default.useRef(null);
46372
+ const itemMap = import_react24.default.useRef(/* @__PURE__ */ new Map()).current;
46372
46373
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
46373
46374
  };
46374
46375
  CollectionProvider.displayName = PROVIDER_NAME2;
46375
46376
  const COLLECTION_SLOT_NAME = name + "CollectionSlot";
46376
46377
  const CollectionSlotImpl = /* @__PURE__ */ createSlot(COLLECTION_SLOT_NAME);
46377
- const CollectionSlot = import_react23.default.forwardRef(
46378
+ const CollectionSlot = import_react24.default.forwardRef(
46378
46379
  (props, forwardedRef) => {
46379
46380
  const { scope, children } = props;
46380
46381
  const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
@@ -46386,13 +46387,13 @@ function createCollection(name) {
46386
46387
  const ITEM_SLOT_NAME = name + "CollectionItemSlot";
46387
46388
  const ITEM_DATA_ATTR = "data-radix-collection-item";
46388
46389
  const CollectionItemSlotImpl = /* @__PURE__ */ createSlot(ITEM_SLOT_NAME);
46389
- const CollectionItemSlot = import_react23.default.forwardRef(
46390
+ const CollectionItemSlot = import_react24.default.forwardRef(
46390
46391
  (props, forwardedRef) => {
46391
46392
  const { scope, children, ...itemData } = props;
46392
- const ref = import_react23.default.useRef(null);
46393
+ const ref = import_react24.default.useRef(null);
46393
46394
  const composedRefs = useComposedRefs(forwardedRef, ref);
46394
46395
  const context = useCollectionContext(ITEM_SLOT_NAME, scope);
46395
- import_react23.default.useEffect(() => {
46396
+ import_react24.default.useEffect(() => {
46396
46397
  context.itemMap.set(ref, { ref, ...itemData });
46397
46398
  return () => void context.itemMap.delete(ref);
46398
46399
  });
@@ -46402,7 +46403,7 @@ function createCollection(name) {
46402
46403
  CollectionItemSlot.displayName = ITEM_SLOT_NAME;
46403
46404
  function useCollection2(scope) {
46404
46405
  const context = useCollectionContext(name + "CollectionConsumer", scope);
46405
- const getItems = import_react23.default.useCallback(() => {
46406
+ const getItems = import_react24.default.useCallback(() => {
46406
46407
  const collectionNode = context.collectionRef.current;
46407
46408
  if (!collectionNode) return [];
46408
46409
  const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
@@ -55188,6 +55189,104 @@ function DepositPollingUi({
55188
55189
  }
55189
55190
  return null;
55190
55191
  }
55192
+ var getChainKey = (chainId, chainType) => {
55193
+ return `${chainType}:${chainId}`;
55194
+ };
55195
+ function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
55196
+ if (!supportedTokens.length) return null;
55197
+ let selectedTokenData;
55198
+ let selectedChainData;
55199
+ const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
55200
+ if (defaultSourceTokenAddress && hasChainDefaults) {
55201
+ for (const t7 of supportedTokens) {
55202
+ const matchingChain = t7.chains.find(
55203
+ (c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55204
+ );
55205
+ if (matchingChain) {
55206
+ selectedTokenData = t7;
55207
+ selectedChainData = matchingChain;
55208
+ break;
55209
+ }
55210
+ }
55211
+ }
55212
+ if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
55213
+ for (const t7 of supportedTokens) {
55214
+ if (t7.symbol !== defaultSourceSymbol) continue;
55215
+ const matchedChain = t7.chains.find(
55216
+ (c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55217
+ );
55218
+ if (matchedChain) {
55219
+ selectedTokenData = t7;
55220
+ selectedChainData = matchedChain;
55221
+ break;
55222
+ }
55223
+ }
55224
+ }
55225
+ if (!selectedTokenData) {
55226
+ for (const t7 of supportedTokens) {
55227
+ if (t7.chains.length > 0) {
55228
+ selectedTokenData = t7;
55229
+ selectedChainData = t7.chains[0];
55230
+ break;
55231
+ }
55232
+ }
55233
+ }
55234
+ if (selectedTokenData && selectedChainData) {
55235
+ return { token: selectedTokenData, chain: selectedChainData };
55236
+ }
55237
+ return null;
55238
+ }
55239
+ function useDefaultSourceToken({
55240
+ supportedTokens,
55241
+ defaultSourceChainType,
55242
+ defaultSourceChainId,
55243
+ defaultSourceTokenAddress,
55244
+ defaultSourceSymbol
55245
+ }) {
55246
+ const [token, setToken] = (0, import_react20.useState)(null);
55247
+ const [chain, setChain] = (0, import_react20.useState)(null);
55248
+ const [initialSelectionDone, setInitialSelectionDone] = (0, import_react20.useState)(false);
55249
+ const appliedDefaultsRef = (0, import_react20.useRef)("");
55250
+ (0, import_react20.useEffect)(() => {
55251
+ if (!supportedTokens.length) return;
55252
+ const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
55253
+ const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
55254
+ if (initialSelectionDone && !defaultsChanged) return;
55255
+ const result = resolveSourceToken(
55256
+ supportedTokens,
55257
+ defaultSourceChainType,
55258
+ defaultSourceChainId,
55259
+ defaultSourceTokenAddress,
55260
+ defaultSourceSymbol
55261
+ );
55262
+ if (result) {
55263
+ setToken(result.token.symbol);
55264
+ setChain(getChainKey(result.chain.chain_id, result.chain.chain_type));
55265
+ appliedDefaultsRef.current = defaultsKey;
55266
+ setInitialSelectionDone(true);
55267
+ }
55268
+ }, [
55269
+ supportedTokens,
55270
+ defaultSourceTokenAddress,
55271
+ defaultSourceSymbol,
55272
+ defaultSourceChainType,
55273
+ defaultSourceChainId,
55274
+ initialSelectionDone
55275
+ ]);
55276
+ (0, import_react20.useEffect)(() => {
55277
+ if (!supportedTokens.length || !token) return;
55278
+ const currentToken = supportedTokens.find((t7) => t7.symbol === token);
55279
+ if (!currentToken || currentToken.chains.length === 0) return;
55280
+ const isChainAvailable = chain && currentToken.chains.some((c) => {
55281
+ return getChainKey(c.chain_id, c.chain_type) === chain;
55282
+ });
55283
+ if (!isChainAvailable) {
55284
+ const firstChain = currentToken.chains[0];
55285
+ setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
55286
+ }
55287
+ }, [token, supportedTokens, chain]);
55288
+ return { token, chain, setToken, setChain, initialSelectionDone };
55289
+ }
55191
55290
  function DepositFooterLinks({
55192
55291
  onGlossaryClick
55193
55292
  }) {
@@ -55347,7 +55446,7 @@ function GlossaryModal({
55347
55446
  ) });
55348
55447
  }
55349
55448
  function useCopyAddress() {
55350
- const [copied, setCopied] = (0, import_react20.useState)(false);
55449
+ const [copied, setCopied] = (0, import_react21.useState)(false);
55351
55450
  const handleCopy = (address) => {
55352
55451
  if (!address) return;
55353
55452
  navigator.clipboard.writeText(address);
@@ -55393,7 +55492,7 @@ var TooltipContent2 = React242.forwardRef(({ className, sideOffset = 4, ...props
55393
55492
  });
55394
55493
  TooltipContent2.displayName = Content22.displayName;
55395
55494
  var t4 = i18n2.transferCrypto;
55396
- var getChainKey = (chainId, chainType) => {
55495
+ var getChainKey2 = (chainId, chainType) => {
55397
55496
  return `${chainType}:${chainId}`;
55398
55497
  };
55399
55498
  var parseChainKey = (chainKey) => {
@@ -55407,6 +55506,10 @@ function TransferCryptoSingleInput({
55407
55506
  destinationChainType,
55408
55507
  destinationChainId,
55409
55508
  destinationTokenAddress,
55509
+ defaultSourceChainType,
55510
+ defaultSourceChainId,
55511
+ defaultSourceTokenAddress,
55512
+ defaultSourceSymbol,
55410
55513
  depositConfirmationMode = "auto_ui",
55411
55514
  onExecutionsChange,
55412
55515
  onDepositSuccess,
@@ -55415,21 +55518,25 @@ function TransferCryptoSingleInput({
55415
55518
  }) {
55416
55519
  const { themeClass, colors: colors2, fonts, components } = useTheme();
55417
55520
  const isDarkMode = themeClass.includes("uf-dark");
55418
- const [token, setToken] = (0, import_react16.useState)("USDC");
55419
- const [chain, setChain] = (0, import_react16.useState)("solana:mainnet");
55420
55521
  const [copied, setCopied] = (0, import_react16.useState)(false);
55421
55522
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
55422
55523
  const [glossaryOpen, setGlossaryOpen] = (0, import_react16.useState)(false);
55423
55524
  const [detailsExpanded, setDetailsExpanded] = (0, import_react16.useState)(false);
55424
55525
  const [depositsModalOpen, setDepositsModalOpen] = (0, import_react16.useState)(false);
55425
55526
  const [tokenSelectorOpen, setTokenSelectorOpen] = (0, import_react16.useState)(false);
55426
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react16.useState)(false);
55427
55527
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
55428
55528
  destination_token_address: destinationTokenAddress,
55429
55529
  destination_chain_id: destinationChainId,
55430
55530
  destination_chain_type: destinationChainType
55431
55531
  });
55432
55532
  const supportedTokens = tokensResponse?.data ?? [];
55533
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
55534
+ supportedTokens,
55535
+ defaultSourceChainType,
55536
+ defaultSourceChainId,
55537
+ defaultSourceTokenAddress,
55538
+ defaultSourceSymbol
55539
+ });
55433
55540
  const {
55434
55541
  data: depositAddressResponse,
55435
55542
  isLoading: walletsLoading,
@@ -55459,10 +55566,10 @@ function TransferCryptoSingleInput({
55459
55566
  });
55460
55567
  return Array.from(chainsMap.values());
55461
55568
  }, [supportedTokens]);
55462
- const currentChainCombo = parseChainKey(chain);
55463
- const currentChainData = allAvailableChains.find(
55569
+ const currentChainCombo = chain ? parseChainKey(chain) : null;
55570
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
55464
55571
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
55465
- );
55572
+ ) : void 0;
55466
55573
  const currentChainType = currentChainData?.chain_type || "ethereum";
55467
55574
  const currentWallet = getWalletByChainType(wallets, currentChainType);
55468
55575
  const depositAddress = currentWallet?.address || "";
@@ -55480,78 +55587,20 @@ function TransferCryptoSingleInput({
55480
55587
  onDepositSuccess,
55481
55588
  onDepositError
55482
55589
  });
55483
- (0, import_react16.useEffect)(() => {
55484
- if (!supportedTokens.length || initialSelectionDone) return;
55485
- let selectedTokenData;
55486
- let selectedChainData;
55487
- if (destinationTokenAddress) {
55488
- for (const t7 of supportedTokens) {
55489
- const matchingChain = t7.chains.find(
55490
- (c) => c.token_address.toLowerCase() === destinationTokenAddress.toLowerCase()
55491
- );
55492
- if (matchingChain) {
55493
- selectedTokenData = t7;
55494
- selectedChainData = matchingChain;
55495
- break;
55496
- }
55497
- }
55498
- }
55499
- if (!selectedTokenData) {
55500
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDC");
55501
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
55502
- selectedChainData = selectedTokenData.chains[0];
55503
- }
55504
- }
55505
- if (!selectedTokenData) {
55506
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDT");
55507
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
55508
- selectedChainData = selectedTokenData.chains[0];
55509
- }
55510
- }
55511
- if (!selectedTokenData) {
55512
- selectedTokenData = supportedTokens[0];
55513
- if (selectedTokenData.chains.length > 0) {
55514
- selectedChainData = selectedTokenData.chains[0];
55515
- }
55516
- }
55517
- if (selectedTokenData) {
55518
- setToken(selectedTokenData.symbol);
55519
- }
55520
- if (selectedChainData) {
55521
- setChain(
55522
- getChainKey(selectedChainData.chain_id, selectedChainData.chain_type)
55523
- );
55524
- }
55525
- setInitialSelectionDone(true);
55526
- }, [supportedTokens, destinationTokenAddress, initialSelectionDone]);
55527
55590
  (0, import_react16.useEffect)(() => {
55528
55591
  if (onExecutionsChange) {
55529
55592
  onExecutionsChange(depositExecutions);
55530
55593
  }
55531
55594
  }, [depositExecutions, onExecutionsChange]);
55532
- (0, import_react16.useEffect)(() => {
55533
- if (!supportedTokens.length) return;
55534
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
55535
- if (!currentToken || currentToken.chains.length === 0) return;
55536
- const isChainAvailable = currentToken.chains.some((c) => {
55537
- const key = getChainKey(c.chain_id, c.chain_type);
55538
- return key === chain;
55539
- });
55540
- if (!isChainAvailable) {
55541
- const firstChain = currentToken.chains[0];
55542
- const newChain = getChainKey(firstChain.chain_id, firstChain.chain_type);
55543
- setChain(newChain);
55544
- }
55545
- }, [token, supportedTokens, chain]);
55546
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
55595
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
55547
55596
  const availableChainsForToken = selectedToken?.chains || [];
55548
- const currentChainFromBackend = availableChainsForToken.find((c) => {
55549
- const key = getChainKey(c.chain_id, c.chain_type);
55597
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
55598
+ const key = getChainKey2(c.chain_id, c.chain_type);
55550
55599
  return key === chain;
55551
55600
  }) || allAvailableChains.find((c) => {
55552
- const key = getChainKey(c.chain_id, c.chain_type);
55601
+ const key = getChainKey2(c.chain_id, c.chain_type);
55553
55602
  return key === chain;
55554
- });
55603
+ }) : void 0;
55555
55604
  const handleCopyAddress = () => {
55556
55605
  navigator.clipboard.writeText(depositAddress);
55557
55606
  setCopied(true);
@@ -55586,10 +55635,10 @@ function TransferCryptoSingleInput({
55586
55635
  "button",
55587
55636
  {
55588
55637
  onClick: () => setTokenSelectorOpen(true),
55589
- disabled: tokensLoading || supportedTokens.length === 0,
55638
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
55590
55639
  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",
55591
55640
  style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
55592
- children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
55641
+ children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
55593
55642
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-w-10 uf-h-10 uf-rounded-full uf-bg-muted" }),
55594
55643
  /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex-1", children: [
55595
55644
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-h-4 uf-w-16 uf-bg-muted uf-rounded uf-mb-1" }),
@@ -55663,8 +55712,8 @@ function TransferCryptoSingleInput({
55663
55712
  open: tokenSelectorOpen,
55664
55713
  onOpenChange: setTokenSelectorOpen,
55665
55714
  tokens: supportedTokens,
55666
- selectedToken: token,
55667
- selectedChainKey: chain,
55715
+ selectedToken: token ?? "",
55716
+ selectedChainKey: chain ?? "",
55668
55717
  onSelect: (newToken, newChain) => {
55669
55718
  setToken(newToken);
55670
55719
  setChain(newChain);
@@ -56002,7 +56051,7 @@ var SelectSeparator2 = React252.forwardRef(({ className, ...props }, ref) => /*
56002
56051
  ));
56003
56052
  SelectSeparator2.displayName = Separator.displayName;
56004
56053
  var t5 = i18n2.transferCrypto;
56005
- var getChainKey2 = (chainId, chainType) => {
56054
+ var getChainKey3 = (chainId, chainType) => {
56006
56055
  return `${chainType}:${chainId}`;
56007
56056
  };
56008
56057
  var parseChainKey2 = (chainKey) => {
@@ -56016,6 +56065,10 @@ function TransferCryptoDoubleInput({
56016
56065
  destinationChainType,
56017
56066
  destinationChainId,
56018
56067
  destinationTokenAddress,
56068
+ defaultSourceChainType,
56069
+ defaultSourceChainId,
56070
+ defaultSourceTokenAddress,
56071
+ defaultSourceSymbol,
56019
56072
  depositConfirmationMode = "auto_ui",
56020
56073
  onExecutionsChange,
56021
56074
  onDepositSuccess,
@@ -56024,20 +56077,24 @@ function TransferCryptoDoubleInput({
56024
56077
  }) {
56025
56078
  const { themeClass, colors: colors2, fonts, components } = useTheme();
56026
56079
  const isDarkMode = themeClass.includes("uf-dark");
56027
- const [token, setToken] = (0, import_react22.useState)("USDC");
56028
- const [chain, setChain] = (0, import_react22.useState)("solana:mainnet");
56029
- const [copied, setCopied] = (0, import_react22.useState)(false);
56080
+ const [copied, setCopied] = (0, import_react23.useState)(false);
56030
56081
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
56031
- const [glossaryOpen, setGlossaryOpen] = (0, import_react22.useState)(false);
56032
- const [detailsExpanded, setDetailsExpanded] = (0, import_react22.useState)(false);
56033
- const [depositsModalOpen, setDepositsModalOpen] = (0, import_react22.useState)(false);
56034
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react22.useState)(false);
56082
+ const [glossaryOpen, setGlossaryOpen] = (0, import_react23.useState)(false);
56083
+ const [detailsExpanded, setDetailsExpanded] = (0, import_react23.useState)(false);
56084
+ const [depositsModalOpen, setDepositsModalOpen] = (0, import_react23.useState)(false);
56035
56085
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
56036
56086
  destination_token_address: destinationTokenAddress,
56037
56087
  destination_chain_id: destinationChainId,
56038
56088
  destination_chain_type: destinationChainType
56039
56089
  });
56040
56090
  const supportedTokens = tokensResponse?.data ?? [];
56091
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
56092
+ supportedTokens,
56093
+ defaultSourceChainType,
56094
+ defaultSourceChainId,
56095
+ defaultSourceTokenAddress,
56096
+ defaultSourceSymbol
56097
+ });
56041
56098
  const {
56042
56099
  data: depositAddressResponse,
56043
56100
  isLoading: walletsLoading,
@@ -56055,7 +56112,7 @@ function TransferCryptoDoubleInput({
56055
56112
  const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
56056
56113
  const loading = externalWallets?.length ? false : walletsLoading;
56057
56114
  const error = walletsError?.message ?? null;
56058
- const allAvailableChains = (0, import_react22.useMemo)(() => {
56115
+ const allAvailableChains = (0, import_react23.useMemo)(() => {
56059
56116
  const chainsMap = /* @__PURE__ */ new Map();
56060
56117
  supportedTokens.forEach((t7) => {
56061
56118
  t7.chains.forEach((c) => {
@@ -56067,10 +56124,10 @@ function TransferCryptoDoubleInput({
56067
56124
  });
56068
56125
  return Array.from(chainsMap.values());
56069
56126
  }, [supportedTokens]);
56070
- const currentChainCombo = parseChainKey2(chain);
56071
- const currentChainData = allAvailableChains.find(
56127
+ const currentChainCombo = chain ? parseChainKey2(chain) : null;
56128
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
56072
56129
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
56073
- );
56130
+ ) : void 0;
56074
56131
  const currentChainType = currentChainData?.chain_type || "ethereum";
56075
56132
  const currentWallet = getWalletByChainType(wallets, currentChainType);
56076
56133
  const depositAddress = currentWallet?.address || "";
@@ -56088,51 +56145,20 @@ function TransferCryptoDoubleInput({
56088
56145
  onDepositSuccess,
56089
56146
  onDepositError
56090
56147
  });
56091
- (0, import_react22.useEffect)(() => {
56092
- if (!supportedTokens.length || initialSelectionDone) return;
56093
- const allChains = /* @__PURE__ */ new Set();
56094
- supportedTokens.forEach((t7) => {
56095
- t7.chains.forEach((c) => {
56096
- allChains.add(getChainKey2(c.chain_id, c.chain_type));
56097
- });
56098
- });
56099
- if (!allChains.has(chain)) {
56100
- const firstToken = supportedTokens[0];
56101
- if (firstToken.chains.length > 0) {
56102
- const firstChain = firstToken.chains[0];
56103
- setChain(getChainKey2(firstChain.chain_id, firstChain.chain_type));
56104
- }
56105
- }
56106
- setInitialSelectionDone(true);
56107
- }, [supportedTokens, chain, initialSelectionDone]);
56108
- (0, import_react22.useEffect)(() => {
56148
+ (0, import_react23.useEffect)(() => {
56109
56149
  if (onExecutionsChange) {
56110
56150
  onExecutionsChange(depositExecutions);
56111
56151
  }
56112
56152
  }, [depositExecutions, onExecutionsChange]);
56113
- (0, import_react22.useEffect)(() => {
56114
- if (!supportedTokens.length) return;
56115
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
56116
- if (!currentToken || currentToken.chains.length === 0) return;
56117
- const isChainAvailable = currentToken.chains.some((c) => {
56118
- const key = getChainKey2(c.chain_id, c.chain_type);
56119
- return key === chain;
56120
- });
56121
- if (!isChainAvailable) {
56122
- const firstChain = currentToken.chains[0];
56123
- const newChain = getChainKey2(firstChain.chain_id, firstChain.chain_type);
56124
- setChain(newChain);
56125
- }
56126
- }, [token, supportedTokens, chain]);
56127
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
56153
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
56128
56154
  const availableChainsForToken = selectedToken?.chains || [];
56129
- const currentChainFromBackend = availableChainsForToken.find((c) => {
56130
- const key = getChainKey2(c.chain_id, c.chain_type);
56155
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
56156
+ const key = getChainKey3(c.chain_id, c.chain_type);
56131
56157
  return key === chain;
56132
56158
  }) || allAvailableChains.find((c) => {
56133
- const key = getChainKey2(c.chain_id, c.chain_type);
56159
+ const key = getChainKey3(c.chain_id, c.chain_type);
56134
56160
  return key === chain;
56135
- });
56161
+ }) : void 0;
56136
56162
  const handleCopyAddress = () => {
56137
56163
  navigator.clipboard.writeText(depositAddress);
56138
56164
  setCopied(true);
@@ -56206,11 +56232,11 @@ function TransferCryptoDoubleInput({
56206
56232
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
56207
56233
  Select2,
56208
56234
  {
56209
- value: token,
56235
+ value: token ?? "",
56210
56236
  onValueChange: setToken,
56211
- disabled: tokensLoading || supportedTokens.length === 0,
56237
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
56212
56238
  children: [
56213
- /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
56239
+ /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
56214
56240
  /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(
56215
56241
  SelectItem2,
56216
56242
  {
@@ -56237,11 +56263,11 @@ function TransferCryptoDoubleInput({
56237
56263
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
56238
56264
  Select2,
56239
56265
  {
56240
- value: chain,
56266
+ value: chain ?? "",
56241
56267
  onValueChange: setChain,
56242
- disabled: tokensLoading || availableChainsForToken.length === 0,
56268
+ disabled: tokensLoading || !chain || availableChainsForToken.length === 0,
56243
56269
  children: [
56244
- /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
56270
+ /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading || !chain ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
56245
56271
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
56246
56272
  SelectContent2,
56247
56273
  {
@@ -56249,7 +56275,7 @@ function TransferCryptoDoubleInput({
56249
56275
  className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px] uf-min-w-[200px]",
56250
56276
  style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} },
56251
56277
  children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime62.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) => {
56252
- const chainKey = getChainKey2(
56278
+ const chainKey = getChainKey3(
56253
56279
  chainData.chain_id,
56254
56280
  chainData.chain_type
56255
56281
  );
@@ -57244,8 +57270,8 @@ function ConfirmingView({
57244
57270
  isPolling = false
57245
57271
  }) {
57246
57272
  const { colors: colors2, fonts } = useTheme();
57247
- const [containerEl, setContainerEl] = (0, import_react25.useState)(null);
57248
- const containerCallbackRef = (0, import_react25.useCallback)((el) => {
57273
+ const [containerEl, setContainerEl] = (0, import_react26.useState)(null);
57274
+ const containerCallbackRef = (0, import_react26.useCallback)((el) => {
57249
57275
  setContainerEl(el);
57250
57276
  }, []);
57251
57277
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PortalContainerProvider, { value: containerEl, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
@@ -58617,6 +58643,10 @@ function DepositModal({
58617
58643
  destinationChainType,
58618
58644
  destinationChainId,
58619
58645
  destinationTokenAddress,
58646
+ defaultSourceChainType,
58647
+ defaultSourceChainId,
58648
+ defaultSourceTokenAddress,
58649
+ defaultSourceSymbol,
58620
58650
  hideDepositTracker = false,
58621
58651
  showBalanceHeader = false,
58622
58652
  transferInputVariant = "double_input",
@@ -59049,6 +59079,10 @@ function DepositModal({
59049
59079
  destinationChainType,
59050
59080
  destinationChainId,
59051
59081
  destinationTokenAddress,
59082
+ defaultSourceChainType,
59083
+ defaultSourceChainId,
59084
+ defaultSourceTokenAddress,
59085
+ defaultSourceSymbol,
59052
59086
  depositConfirmationMode,
59053
59087
  onExecutionsChange: setDepositExecutions,
59054
59088
  onDepositSuccess,
@@ -59064,6 +59098,10 @@ function DepositModal({
59064
59098
  destinationChainType,
59065
59099
  destinationChainId,
59066
59100
  destinationTokenAddress,
59101
+ defaultSourceChainType,
59102
+ defaultSourceChainId,
59103
+ defaultSourceTokenAddress,
59104
+ defaultSourceSymbol,
59067
59105
  depositConfirmationMode,
59068
59106
  onExecutionsChange: setDepositExecutions,
59069
59107
  onDepositSuccess,
@@ -59356,6 +59394,10 @@ function UnifoldProvider2({
59356
59394
  destinationChainType: depositConfig.destinationChainType,
59357
59395
  destinationChainId: depositConfig.destinationChainId,
59358
59396
  destinationTokenAddress: depositConfig.destinationTokenAddress,
59397
+ defaultSourceChainType: depositConfig.defaultSourceChainType,
59398
+ defaultSourceChainId: depositConfig.defaultSourceChainId,
59399
+ defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
59400
+ defaultSourceSymbol: depositConfig.defaultSourceSymbol,
59359
59401
  depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
59360
59402
  hideDepositTracker: config?.hideDepositTracker,
59361
59403
  showBalanceHeader: config?.showBalanceHeader,
@@ -59403,16 +59445,16 @@ function useUnifold2() {
59403
59445
  }
59404
59446
 
59405
59447
  // src/unifold.tsx
59406
- var UnifoldBridge = (0, import_react26.forwardRef)((_, ref) => {
59448
+ var UnifoldBridge = (0, import_react27.forwardRef)((_, ref) => {
59407
59449
  const { beginDeposit, closeDeposit } = useUnifold2();
59408
- (0, import_react26.useImperativeHandle)(ref, () => ({ beginDeposit, closeDeposit }), [
59450
+ (0, import_react27.useImperativeHandle)(ref, () => ({ beginDeposit, closeDeposit }), [
59409
59451
  beginDeposit,
59410
59452
  closeDeposit
59411
59453
  ]);
59412
59454
  return null;
59413
59455
  });
59414
59456
  UnifoldBridge.displayName = "UnifoldBridge";
59415
- var RenderErrorBoundary = class extends import_react26.Component {
59457
+ var RenderErrorBoundary = class extends import_react27.Component {
59416
59458
  constructor() {
59417
59459
  super(...arguments);
59418
59460
  this.state = { hasError: false };
@@ -59477,13 +59519,13 @@ function createUnifold(publishableKey, config) {
59477
59519
  };
59478
59520
  try {
59479
59521
  root.render(
59480
- import_react26.default.createElement(
59522
+ import_react27.default.createElement(
59481
59523
  RenderErrorBoundary,
59482
59524
  { onError: handleRenderError },
59483
- import_react26.default.createElement(
59525
+ import_react27.default.createElement(
59484
59526
  UnifoldProvider2,
59485
59527
  { publishableKey, config },
59486
- import_react26.default.createElement(UnifoldBridge, { ref: refCallback })
59528
+ import_react27.default.createElement(UnifoldBridge, { ref: refCallback })
59487
59529
  )
59488
59530
  )
59489
59531
  );
package/dist/index.mjs CHANGED
@@ -34394,7 +34394,7 @@ var require_jsx_runtime = __commonJS({
34394
34394
  });
34395
34395
 
34396
34396
  // src/unifold.tsx
34397
- var import_react26 = __toESM(require_react());
34397
+ var import_react27 = __toESM(require_react());
34398
34398
  var import_client = __toESM(require_client());
34399
34399
 
34400
34400
  // ../connect-react/dist/index.mjs
@@ -37169,14 +37169,15 @@ var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
37169
37169
  var import_react19 = __toESM(require_react(), 1);
37170
37170
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
37171
37171
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
37172
+ var import_react20 = __toESM(require_react(), 1);
37172
37173
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
37173
37174
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
37174
- var import_react20 = __toESM(require_react(), 1);
37175
+ var import_react21 = __toESM(require_react(), 1);
37175
37176
  var React242 = __toESM(require_react(), 1);
37176
37177
  var React31 = __toESM(require_react(), 1);
37177
37178
  var React29 = __toESM(require_react(), 1);
37178
37179
  var React26 = __toESM(require_react(), 1);
37179
- var import_react21 = __toESM(require_react(), 1);
37180
+ var import_react22 = __toESM(require_react(), 1);
37180
37181
  var ReactDOM3 = __toESM(require_react_dom(), 1);
37181
37182
  var React27 = __toESM(require_react(), 1);
37182
37183
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
@@ -37187,13 +37188,13 @@ var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
37187
37188
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
37188
37189
  var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
37189
37190
  var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
37190
- var import_react22 = __toESM(require_react(), 1);
37191
+ var import_react23 = __toESM(require_react(), 1);
37191
37192
  var React252 = __toESM(require_react(), 1);
37192
37193
  var React35 = __toESM(require_react(), 1);
37193
37194
  var ReactDOM4 = __toESM(require_react_dom(), 1);
37194
- var import_react23 = __toESM(require_react(), 1);
37195
- var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
37196
37195
  var import_react24 = __toESM(require_react(), 1);
37196
+ var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
37197
+ var import_react25 = __toESM(require_react(), 1);
37197
37198
  var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
37198
37199
  var React33 = __toESM(require_react(), 1);
37199
37200
  var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
@@ -37206,7 +37207,7 @@ var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
37206
37207
  var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
37207
37208
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
37208
37209
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
37209
- var import_react25 = __toESM(require_react(), 1);
37210
+ var import_react26 = __toESM(require_react(), 1);
37210
37211
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
37211
37212
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
37212
37213
  var React272 = __toESM(require_react(), 1);
@@ -45245,7 +45246,7 @@ var computePosition2 = (reference, floating, options2) => {
45245
45246
  var isClient = typeof document !== "undefined";
45246
45247
  var noop2 = function noop22() {
45247
45248
  };
45248
- var index = isClient ? import_react21.useLayoutEffect : noop2;
45249
+ var index = isClient ? import_react22.useLayoutEffect : noop2;
45249
45250
  function deepEqual(a, b) {
45250
45251
  if (a === b) {
45251
45252
  return true;
@@ -46354,14 +46355,14 @@ function createCollection(name) {
46354
46355
  );
46355
46356
  const CollectionProvider = (props) => {
46356
46357
  const { scope, children } = props;
46357
- const ref = import_react23.default.useRef(null);
46358
- const itemMap = import_react23.default.useRef(/* @__PURE__ */ new Map()).current;
46358
+ const ref = import_react24.default.useRef(null);
46359
+ const itemMap = import_react24.default.useRef(/* @__PURE__ */ new Map()).current;
46359
46360
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
46360
46361
  };
46361
46362
  CollectionProvider.displayName = PROVIDER_NAME2;
46362
46363
  const COLLECTION_SLOT_NAME = name + "CollectionSlot";
46363
46364
  const CollectionSlotImpl = /* @__PURE__ */ createSlot(COLLECTION_SLOT_NAME);
46364
- const CollectionSlot = import_react23.default.forwardRef(
46365
+ const CollectionSlot = import_react24.default.forwardRef(
46365
46366
  (props, forwardedRef) => {
46366
46367
  const { scope, children } = props;
46367
46368
  const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
@@ -46373,13 +46374,13 @@ function createCollection(name) {
46373
46374
  const ITEM_SLOT_NAME = name + "CollectionItemSlot";
46374
46375
  const ITEM_DATA_ATTR = "data-radix-collection-item";
46375
46376
  const CollectionItemSlotImpl = /* @__PURE__ */ createSlot(ITEM_SLOT_NAME);
46376
- const CollectionItemSlot = import_react23.default.forwardRef(
46377
+ const CollectionItemSlot = import_react24.default.forwardRef(
46377
46378
  (props, forwardedRef) => {
46378
46379
  const { scope, children, ...itemData } = props;
46379
- const ref = import_react23.default.useRef(null);
46380
+ const ref = import_react24.default.useRef(null);
46380
46381
  const composedRefs = useComposedRefs(forwardedRef, ref);
46381
46382
  const context = useCollectionContext(ITEM_SLOT_NAME, scope);
46382
- import_react23.default.useEffect(() => {
46383
+ import_react24.default.useEffect(() => {
46383
46384
  context.itemMap.set(ref, { ref, ...itemData });
46384
46385
  return () => void context.itemMap.delete(ref);
46385
46386
  });
@@ -46389,7 +46390,7 @@ function createCollection(name) {
46389
46390
  CollectionItemSlot.displayName = ITEM_SLOT_NAME;
46390
46391
  function useCollection2(scope) {
46391
46392
  const context = useCollectionContext(name + "CollectionConsumer", scope);
46392
- const getItems = import_react23.default.useCallback(() => {
46393
+ const getItems = import_react24.default.useCallback(() => {
46393
46394
  const collectionNode = context.collectionRef.current;
46394
46395
  if (!collectionNode) return [];
46395
46396
  const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
@@ -55175,6 +55176,104 @@ function DepositPollingUi({
55175
55176
  }
55176
55177
  return null;
55177
55178
  }
55179
+ var getChainKey = (chainId, chainType) => {
55180
+ return `${chainType}:${chainId}`;
55181
+ };
55182
+ function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
55183
+ if (!supportedTokens.length) return null;
55184
+ let selectedTokenData;
55185
+ let selectedChainData;
55186
+ const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
55187
+ if (defaultSourceTokenAddress && hasChainDefaults) {
55188
+ for (const t7 of supportedTokens) {
55189
+ const matchingChain = t7.chains.find(
55190
+ (c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55191
+ );
55192
+ if (matchingChain) {
55193
+ selectedTokenData = t7;
55194
+ selectedChainData = matchingChain;
55195
+ break;
55196
+ }
55197
+ }
55198
+ }
55199
+ if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
55200
+ for (const t7 of supportedTokens) {
55201
+ if (t7.symbol !== defaultSourceSymbol) continue;
55202
+ const matchedChain = t7.chains.find(
55203
+ (c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55204
+ );
55205
+ if (matchedChain) {
55206
+ selectedTokenData = t7;
55207
+ selectedChainData = matchedChain;
55208
+ break;
55209
+ }
55210
+ }
55211
+ }
55212
+ if (!selectedTokenData) {
55213
+ for (const t7 of supportedTokens) {
55214
+ if (t7.chains.length > 0) {
55215
+ selectedTokenData = t7;
55216
+ selectedChainData = t7.chains[0];
55217
+ break;
55218
+ }
55219
+ }
55220
+ }
55221
+ if (selectedTokenData && selectedChainData) {
55222
+ return { token: selectedTokenData, chain: selectedChainData };
55223
+ }
55224
+ return null;
55225
+ }
55226
+ function useDefaultSourceToken({
55227
+ supportedTokens,
55228
+ defaultSourceChainType,
55229
+ defaultSourceChainId,
55230
+ defaultSourceTokenAddress,
55231
+ defaultSourceSymbol
55232
+ }) {
55233
+ const [token, setToken] = (0, import_react20.useState)(null);
55234
+ const [chain, setChain] = (0, import_react20.useState)(null);
55235
+ const [initialSelectionDone, setInitialSelectionDone] = (0, import_react20.useState)(false);
55236
+ const appliedDefaultsRef = (0, import_react20.useRef)("");
55237
+ (0, import_react20.useEffect)(() => {
55238
+ if (!supportedTokens.length) return;
55239
+ const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
55240
+ const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
55241
+ if (initialSelectionDone && !defaultsChanged) return;
55242
+ const result = resolveSourceToken(
55243
+ supportedTokens,
55244
+ defaultSourceChainType,
55245
+ defaultSourceChainId,
55246
+ defaultSourceTokenAddress,
55247
+ defaultSourceSymbol
55248
+ );
55249
+ if (result) {
55250
+ setToken(result.token.symbol);
55251
+ setChain(getChainKey(result.chain.chain_id, result.chain.chain_type));
55252
+ appliedDefaultsRef.current = defaultsKey;
55253
+ setInitialSelectionDone(true);
55254
+ }
55255
+ }, [
55256
+ supportedTokens,
55257
+ defaultSourceTokenAddress,
55258
+ defaultSourceSymbol,
55259
+ defaultSourceChainType,
55260
+ defaultSourceChainId,
55261
+ initialSelectionDone
55262
+ ]);
55263
+ (0, import_react20.useEffect)(() => {
55264
+ if (!supportedTokens.length || !token) return;
55265
+ const currentToken = supportedTokens.find((t7) => t7.symbol === token);
55266
+ if (!currentToken || currentToken.chains.length === 0) return;
55267
+ const isChainAvailable = chain && currentToken.chains.some((c) => {
55268
+ return getChainKey(c.chain_id, c.chain_type) === chain;
55269
+ });
55270
+ if (!isChainAvailable) {
55271
+ const firstChain = currentToken.chains[0];
55272
+ setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
55273
+ }
55274
+ }, [token, supportedTokens, chain]);
55275
+ return { token, chain, setToken, setChain, initialSelectionDone };
55276
+ }
55178
55277
  function DepositFooterLinks({
55179
55278
  onGlossaryClick
55180
55279
  }) {
@@ -55334,7 +55433,7 @@ function GlossaryModal({
55334
55433
  ) });
55335
55434
  }
55336
55435
  function useCopyAddress() {
55337
- const [copied, setCopied] = (0, import_react20.useState)(false);
55436
+ const [copied, setCopied] = (0, import_react21.useState)(false);
55338
55437
  const handleCopy = (address) => {
55339
55438
  if (!address) return;
55340
55439
  navigator.clipboard.writeText(address);
@@ -55380,7 +55479,7 @@ var TooltipContent2 = React242.forwardRef(({ className, sideOffset = 4, ...props
55380
55479
  });
55381
55480
  TooltipContent2.displayName = Content22.displayName;
55382
55481
  var t4 = i18n2.transferCrypto;
55383
- var getChainKey = (chainId, chainType) => {
55482
+ var getChainKey2 = (chainId, chainType) => {
55384
55483
  return `${chainType}:${chainId}`;
55385
55484
  };
55386
55485
  var parseChainKey = (chainKey) => {
@@ -55394,6 +55493,10 @@ function TransferCryptoSingleInput({
55394
55493
  destinationChainType,
55395
55494
  destinationChainId,
55396
55495
  destinationTokenAddress,
55496
+ defaultSourceChainType,
55497
+ defaultSourceChainId,
55498
+ defaultSourceTokenAddress,
55499
+ defaultSourceSymbol,
55397
55500
  depositConfirmationMode = "auto_ui",
55398
55501
  onExecutionsChange,
55399
55502
  onDepositSuccess,
@@ -55402,21 +55505,25 @@ function TransferCryptoSingleInput({
55402
55505
  }) {
55403
55506
  const { themeClass, colors: colors2, fonts, components } = useTheme();
55404
55507
  const isDarkMode = themeClass.includes("uf-dark");
55405
- const [token, setToken] = (0, import_react16.useState)("USDC");
55406
- const [chain, setChain] = (0, import_react16.useState)("solana:mainnet");
55407
55508
  const [copied, setCopied] = (0, import_react16.useState)(false);
55408
55509
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
55409
55510
  const [glossaryOpen, setGlossaryOpen] = (0, import_react16.useState)(false);
55410
55511
  const [detailsExpanded, setDetailsExpanded] = (0, import_react16.useState)(false);
55411
55512
  const [depositsModalOpen, setDepositsModalOpen] = (0, import_react16.useState)(false);
55412
55513
  const [tokenSelectorOpen, setTokenSelectorOpen] = (0, import_react16.useState)(false);
55413
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react16.useState)(false);
55414
55514
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
55415
55515
  destination_token_address: destinationTokenAddress,
55416
55516
  destination_chain_id: destinationChainId,
55417
55517
  destination_chain_type: destinationChainType
55418
55518
  });
55419
55519
  const supportedTokens = tokensResponse?.data ?? [];
55520
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
55521
+ supportedTokens,
55522
+ defaultSourceChainType,
55523
+ defaultSourceChainId,
55524
+ defaultSourceTokenAddress,
55525
+ defaultSourceSymbol
55526
+ });
55420
55527
  const {
55421
55528
  data: depositAddressResponse,
55422
55529
  isLoading: walletsLoading,
@@ -55446,10 +55553,10 @@ function TransferCryptoSingleInput({
55446
55553
  });
55447
55554
  return Array.from(chainsMap.values());
55448
55555
  }, [supportedTokens]);
55449
- const currentChainCombo = parseChainKey(chain);
55450
- const currentChainData = allAvailableChains.find(
55556
+ const currentChainCombo = chain ? parseChainKey(chain) : null;
55557
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
55451
55558
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
55452
- );
55559
+ ) : void 0;
55453
55560
  const currentChainType = currentChainData?.chain_type || "ethereum";
55454
55561
  const currentWallet = getWalletByChainType(wallets, currentChainType);
55455
55562
  const depositAddress = currentWallet?.address || "";
@@ -55467,78 +55574,20 @@ function TransferCryptoSingleInput({
55467
55574
  onDepositSuccess,
55468
55575
  onDepositError
55469
55576
  });
55470
- (0, import_react16.useEffect)(() => {
55471
- if (!supportedTokens.length || initialSelectionDone) return;
55472
- let selectedTokenData;
55473
- let selectedChainData;
55474
- if (destinationTokenAddress) {
55475
- for (const t7 of supportedTokens) {
55476
- const matchingChain = t7.chains.find(
55477
- (c) => c.token_address.toLowerCase() === destinationTokenAddress.toLowerCase()
55478
- );
55479
- if (matchingChain) {
55480
- selectedTokenData = t7;
55481
- selectedChainData = matchingChain;
55482
- break;
55483
- }
55484
- }
55485
- }
55486
- if (!selectedTokenData) {
55487
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDC");
55488
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
55489
- selectedChainData = selectedTokenData.chains[0];
55490
- }
55491
- }
55492
- if (!selectedTokenData) {
55493
- selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDT");
55494
- if (selectedTokenData && selectedTokenData.chains.length > 0) {
55495
- selectedChainData = selectedTokenData.chains[0];
55496
- }
55497
- }
55498
- if (!selectedTokenData) {
55499
- selectedTokenData = supportedTokens[0];
55500
- if (selectedTokenData.chains.length > 0) {
55501
- selectedChainData = selectedTokenData.chains[0];
55502
- }
55503
- }
55504
- if (selectedTokenData) {
55505
- setToken(selectedTokenData.symbol);
55506
- }
55507
- if (selectedChainData) {
55508
- setChain(
55509
- getChainKey(selectedChainData.chain_id, selectedChainData.chain_type)
55510
- );
55511
- }
55512
- setInitialSelectionDone(true);
55513
- }, [supportedTokens, destinationTokenAddress, initialSelectionDone]);
55514
55577
  (0, import_react16.useEffect)(() => {
55515
55578
  if (onExecutionsChange) {
55516
55579
  onExecutionsChange(depositExecutions);
55517
55580
  }
55518
55581
  }, [depositExecutions, onExecutionsChange]);
55519
- (0, import_react16.useEffect)(() => {
55520
- if (!supportedTokens.length) return;
55521
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
55522
- if (!currentToken || currentToken.chains.length === 0) return;
55523
- const isChainAvailable = currentToken.chains.some((c) => {
55524
- const key = getChainKey(c.chain_id, c.chain_type);
55525
- return key === chain;
55526
- });
55527
- if (!isChainAvailable) {
55528
- const firstChain = currentToken.chains[0];
55529
- const newChain = getChainKey(firstChain.chain_id, firstChain.chain_type);
55530
- setChain(newChain);
55531
- }
55532
- }, [token, supportedTokens, chain]);
55533
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
55582
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
55534
55583
  const availableChainsForToken = selectedToken?.chains || [];
55535
- const currentChainFromBackend = availableChainsForToken.find((c) => {
55536
- const key = getChainKey(c.chain_id, c.chain_type);
55584
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
55585
+ const key = getChainKey2(c.chain_id, c.chain_type);
55537
55586
  return key === chain;
55538
55587
  }) || allAvailableChains.find((c) => {
55539
- const key = getChainKey(c.chain_id, c.chain_type);
55588
+ const key = getChainKey2(c.chain_id, c.chain_type);
55540
55589
  return key === chain;
55541
- });
55590
+ }) : void 0;
55542
55591
  const handleCopyAddress = () => {
55543
55592
  navigator.clipboard.writeText(depositAddress);
55544
55593
  setCopied(true);
@@ -55573,10 +55622,10 @@ function TransferCryptoSingleInput({
55573
55622
  "button",
55574
55623
  {
55575
55624
  onClick: () => setTokenSelectorOpen(true),
55576
- disabled: tokensLoading || supportedTokens.length === 0,
55625
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
55577
55626
  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",
55578
55627
  style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
55579
- children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
55628
+ children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
55580
55629
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-w-10 uf-h-10 uf-rounded-full uf-bg-muted" }),
55581
55630
  /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex-1", children: [
55582
55631
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-h-4 uf-w-16 uf-bg-muted uf-rounded uf-mb-1" }),
@@ -55650,8 +55699,8 @@ function TransferCryptoSingleInput({
55650
55699
  open: tokenSelectorOpen,
55651
55700
  onOpenChange: setTokenSelectorOpen,
55652
55701
  tokens: supportedTokens,
55653
- selectedToken: token,
55654
- selectedChainKey: chain,
55702
+ selectedToken: token ?? "",
55703
+ selectedChainKey: chain ?? "",
55655
55704
  onSelect: (newToken, newChain) => {
55656
55705
  setToken(newToken);
55657
55706
  setChain(newChain);
@@ -55989,7 +56038,7 @@ var SelectSeparator2 = React252.forwardRef(({ className, ...props }, ref) => /*
55989
56038
  ));
55990
56039
  SelectSeparator2.displayName = Separator.displayName;
55991
56040
  var t5 = i18n2.transferCrypto;
55992
- var getChainKey2 = (chainId, chainType) => {
56041
+ var getChainKey3 = (chainId, chainType) => {
55993
56042
  return `${chainType}:${chainId}`;
55994
56043
  };
55995
56044
  var parseChainKey2 = (chainKey) => {
@@ -56003,6 +56052,10 @@ function TransferCryptoDoubleInput({
56003
56052
  destinationChainType,
56004
56053
  destinationChainId,
56005
56054
  destinationTokenAddress,
56055
+ defaultSourceChainType,
56056
+ defaultSourceChainId,
56057
+ defaultSourceTokenAddress,
56058
+ defaultSourceSymbol,
56006
56059
  depositConfirmationMode = "auto_ui",
56007
56060
  onExecutionsChange,
56008
56061
  onDepositSuccess,
@@ -56011,20 +56064,24 @@ function TransferCryptoDoubleInput({
56011
56064
  }) {
56012
56065
  const { themeClass, colors: colors2, fonts, components } = useTheme();
56013
56066
  const isDarkMode = themeClass.includes("uf-dark");
56014
- const [token, setToken] = (0, import_react22.useState)("USDC");
56015
- const [chain, setChain] = (0, import_react22.useState)("solana:mainnet");
56016
- const [copied, setCopied] = (0, import_react22.useState)(false);
56067
+ const [copied, setCopied] = (0, import_react23.useState)(false);
56017
56068
  const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
56018
- const [glossaryOpen, setGlossaryOpen] = (0, import_react22.useState)(false);
56019
- const [detailsExpanded, setDetailsExpanded] = (0, import_react22.useState)(false);
56020
- const [depositsModalOpen, setDepositsModalOpen] = (0, import_react22.useState)(false);
56021
- const [initialSelectionDone, setInitialSelectionDone] = (0, import_react22.useState)(false);
56069
+ const [glossaryOpen, setGlossaryOpen] = (0, import_react23.useState)(false);
56070
+ const [detailsExpanded, setDetailsExpanded] = (0, import_react23.useState)(false);
56071
+ const [depositsModalOpen, setDepositsModalOpen] = (0, import_react23.useState)(false);
56022
56072
  const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
56023
56073
  destination_token_address: destinationTokenAddress,
56024
56074
  destination_chain_id: destinationChainId,
56025
56075
  destination_chain_type: destinationChainType
56026
56076
  });
56027
56077
  const supportedTokens = tokensResponse?.data ?? [];
56078
+ const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
56079
+ supportedTokens,
56080
+ defaultSourceChainType,
56081
+ defaultSourceChainId,
56082
+ defaultSourceTokenAddress,
56083
+ defaultSourceSymbol
56084
+ });
56028
56085
  const {
56029
56086
  data: depositAddressResponse,
56030
56087
  isLoading: walletsLoading,
@@ -56042,7 +56099,7 @@ function TransferCryptoDoubleInput({
56042
56099
  const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
56043
56100
  const loading = externalWallets?.length ? false : walletsLoading;
56044
56101
  const error = walletsError?.message ?? null;
56045
- const allAvailableChains = (0, import_react22.useMemo)(() => {
56102
+ const allAvailableChains = (0, import_react23.useMemo)(() => {
56046
56103
  const chainsMap = /* @__PURE__ */ new Map();
56047
56104
  supportedTokens.forEach((t7) => {
56048
56105
  t7.chains.forEach((c) => {
@@ -56054,10 +56111,10 @@ function TransferCryptoDoubleInput({
56054
56111
  });
56055
56112
  return Array.from(chainsMap.values());
56056
56113
  }, [supportedTokens]);
56057
- const currentChainCombo = parseChainKey2(chain);
56058
- const currentChainData = allAvailableChains.find(
56114
+ const currentChainCombo = chain ? parseChainKey2(chain) : null;
56115
+ const currentChainData = currentChainCombo ? allAvailableChains.find(
56059
56116
  (c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
56060
- );
56117
+ ) : void 0;
56061
56118
  const currentChainType = currentChainData?.chain_type || "ethereum";
56062
56119
  const currentWallet = getWalletByChainType(wallets, currentChainType);
56063
56120
  const depositAddress = currentWallet?.address || "";
@@ -56075,51 +56132,20 @@ function TransferCryptoDoubleInput({
56075
56132
  onDepositSuccess,
56076
56133
  onDepositError
56077
56134
  });
56078
- (0, import_react22.useEffect)(() => {
56079
- if (!supportedTokens.length || initialSelectionDone) return;
56080
- const allChains = /* @__PURE__ */ new Set();
56081
- supportedTokens.forEach((t7) => {
56082
- t7.chains.forEach((c) => {
56083
- allChains.add(getChainKey2(c.chain_id, c.chain_type));
56084
- });
56085
- });
56086
- if (!allChains.has(chain)) {
56087
- const firstToken = supportedTokens[0];
56088
- if (firstToken.chains.length > 0) {
56089
- const firstChain = firstToken.chains[0];
56090
- setChain(getChainKey2(firstChain.chain_id, firstChain.chain_type));
56091
- }
56092
- }
56093
- setInitialSelectionDone(true);
56094
- }, [supportedTokens, chain, initialSelectionDone]);
56095
- (0, import_react22.useEffect)(() => {
56135
+ (0, import_react23.useEffect)(() => {
56096
56136
  if (onExecutionsChange) {
56097
56137
  onExecutionsChange(depositExecutions);
56098
56138
  }
56099
56139
  }, [depositExecutions, onExecutionsChange]);
56100
- (0, import_react22.useEffect)(() => {
56101
- if (!supportedTokens.length) return;
56102
- const currentToken = supportedTokens.find((t7) => t7.symbol === token);
56103
- if (!currentToken || currentToken.chains.length === 0) return;
56104
- const isChainAvailable = currentToken.chains.some((c) => {
56105
- const key = getChainKey2(c.chain_id, c.chain_type);
56106
- return key === chain;
56107
- });
56108
- if (!isChainAvailable) {
56109
- const firstChain = currentToken.chains[0];
56110
- const newChain = getChainKey2(firstChain.chain_id, firstChain.chain_type);
56111
- setChain(newChain);
56112
- }
56113
- }, [token, supportedTokens, chain]);
56114
- const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
56140
+ const selectedToken = token ? supportedTokens.find((t7) => t7.symbol === token) : void 0;
56115
56141
  const availableChainsForToken = selectedToken?.chains || [];
56116
- const currentChainFromBackend = availableChainsForToken.find((c) => {
56117
- const key = getChainKey2(c.chain_id, c.chain_type);
56142
+ const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
56143
+ const key = getChainKey3(c.chain_id, c.chain_type);
56118
56144
  return key === chain;
56119
56145
  }) || allAvailableChains.find((c) => {
56120
- const key = getChainKey2(c.chain_id, c.chain_type);
56146
+ const key = getChainKey3(c.chain_id, c.chain_type);
56121
56147
  return key === chain;
56122
- });
56148
+ }) : void 0;
56123
56149
  const handleCopyAddress = () => {
56124
56150
  navigator.clipboard.writeText(depositAddress);
56125
56151
  setCopied(true);
@@ -56193,11 +56219,11 @@ function TransferCryptoDoubleInput({
56193
56219
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
56194
56220
  Select2,
56195
56221
  {
56196
- value: token,
56222
+ value: token ?? "",
56197
56223
  onValueChange: setToken,
56198
- disabled: tokensLoading || supportedTokens.length === 0,
56224
+ disabled: tokensLoading || !token || supportedTokens.length === 0,
56199
56225
  children: [
56200
- /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
56226
+ /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
56201
56227
  /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(
56202
56228
  SelectItem2,
56203
56229
  {
@@ -56224,11 +56250,11 @@ function TransferCryptoDoubleInput({
56224
56250
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
56225
56251
  Select2,
56226
56252
  {
56227
- value: chain,
56253
+ value: chain ?? "",
56228
56254
  onValueChange: setChain,
56229
- disabled: tokensLoading || availableChainsForToken.length === 0,
56255
+ disabled: tokensLoading || !chain || availableChainsForToken.length === 0,
56230
56256
  children: [
56231
- /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
56257
+ /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)(SelectValue2, { children: tokensLoading || !chain ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
56232
56258
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
56233
56259
  SelectContent2,
56234
56260
  {
@@ -56236,7 +56262,7 @@ function TransferCryptoDoubleInput({
56236
56262
  className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px] uf-min-w-[200px]",
56237
56263
  style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} },
56238
56264
  children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime62.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) => {
56239
- const chainKey = getChainKey2(
56265
+ const chainKey = getChainKey3(
56240
56266
  chainData.chain_id,
56241
56267
  chainData.chain_type
56242
56268
  );
@@ -57231,8 +57257,8 @@ function ConfirmingView({
57231
57257
  isPolling = false
57232
57258
  }) {
57233
57259
  const { colors: colors2, fonts } = useTheme();
57234
- const [containerEl, setContainerEl] = (0, import_react25.useState)(null);
57235
- const containerCallbackRef = (0, import_react25.useCallback)((el) => {
57260
+ const [containerEl, setContainerEl] = (0, import_react26.useState)(null);
57261
+ const containerCallbackRef = (0, import_react26.useCallback)((el) => {
57236
57262
  setContainerEl(el);
57237
57263
  }, []);
57238
57264
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PortalContainerProvider, { value: containerEl, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
@@ -58604,6 +58630,10 @@ function DepositModal({
58604
58630
  destinationChainType,
58605
58631
  destinationChainId,
58606
58632
  destinationTokenAddress,
58633
+ defaultSourceChainType,
58634
+ defaultSourceChainId,
58635
+ defaultSourceTokenAddress,
58636
+ defaultSourceSymbol,
58607
58637
  hideDepositTracker = false,
58608
58638
  showBalanceHeader = false,
58609
58639
  transferInputVariant = "double_input",
@@ -59036,6 +59066,10 @@ function DepositModal({
59036
59066
  destinationChainType,
59037
59067
  destinationChainId,
59038
59068
  destinationTokenAddress,
59069
+ defaultSourceChainType,
59070
+ defaultSourceChainId,
59071
+ defaultSourceTokenAddress,
59072
+ defaultSourceSymbol,
59039
59073
  depositConfirmationMode,
59040
59074
  onExecutionsChange: setDepositExecutions,
59041
59075
  onDepositSuccess,
@@ -59051,6 +59085,10 @@ function DepositModal({
59051
59085
  destinationChainType,
59052
59086
  destinationChainId,
59053
59087
  destinationTokenAddress,
59088
+ defaultSourceChainType,
59089
+ defaultSourceChainId,
59090
+ defaultSourceTokenAddress,
59091
+ defaultSourceSymbol,
59054
59092
  depositConfirmationMode,
59055
59093
  onExecutionsChange: setDepositExecutions,
59056
59094
  onDepositSuccess,
@@ -59343,6 +59381,10 @@ function UnifoldProvider2({
59343
59381
  destinationChainType: depositConfig.destinationChainType,
59344
59382
  destinationChainId: depositConfig.destinationChainId,
59345
59383
  destinationTokenAddress: depositConfig.destinationTokenAddress,
59384
+ defaultSourceChainType: depositConfig.defaultSourceChainType,
59385
+ defaultSourceChainId: depositConfig.defaultSourceChainId,
59386
+ defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
59387
+ defaultSourceSymbol: depositConfig.defaultSourceSymbol,
59346
59388
  depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
59347
59389
  hideDepositTracker: config?.hideDepositTracker,
59348
59390
  showBalanceHeader: config?.showBalanceHeader,
@@ -59390,16 +59432,16 @@ function useUnifold2() {
59390
59432
  }
59391
59433
 
59392
59434
  // src/unifold.tsx
59393
- var UnifoldBridge = (0, import_react26.forwardRef)((_, ref) => {
59435
+ var UnifoldBridge = (0, import_react27.forwardRef)((_, ref) => {
59394
59436
  const { beginDeposit, closeDeposit } = useUnifold2();
59395
- (0, import_react26.useImperativeHandle)(ref, () => ({ beginDeposit, closeDeposit }), [
59437
+ (0, import_react27.useImperativeHandle)(ref, () => ({ beginDeposit, closeDeposit }), [
59396
59438
  beginDeposit,
59397
59439
  closeDeposit
59398
59440
  ]);
59399
59441
  return null;
59400
59442
  });
59401
59443
  UnifoldBridge.displayName = "UnifoldBridge";
59402
- var RenderErrorBoundary = class extends import_react26.Component {
59444
+ var RenderErrorBoundary = class extends import_react27.Component {
59403
59445
  constructor() {
59404
59446
  super(...arguments);
59405
59447
  this.state = { hasError: false };
@@ -59464,13 +59506,13 @@ function createUnifold(publishableKey, config) {
59464
59506
  };
59465
59507
  try {
59466
59508
  root.render(
59467
- import_react26.default.createElement(
59509
+ import_react27.default.createElement(
59468
59510
  RenderErrorBoundary,
59469
59511
  { onError: handleRenderError },
59470
- import_react26.default.createElement(
59512
+ import_react27.default.createElement(
59471
59513
  UnifoldProvider2,
59472
59514
  { publishableKey, config },
59473
- import_react26.default.createElement(UnifoldBridge, { ref: refCallback })
59515
+ import_react27.default.createElement(UnifoldBridge, { ref: refCallback })
59474
59516
  )
59475
59517
  )
59476
59518
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-web",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Unifold UI Web - Framework-agnostic deposit widget",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -27,10 +27,10 @@
27
27
  "@types/react-dom": "^19.0.0",
28
28
  "tsup": "^8.0.0",
29
29
  "typescript": "^5.0.0",
30
- "@unifold/connect-react": "0.1.40",
31
- "@unifold/core": "0.1.40",
32
- "@unifold/react-provider": "0.1.40",
33
- "@unifold/ui-react": "0.1.40"
30
+ "@unifold/connect-react": "0.1.41",
31
+ "@unifold/core": "0.1.41",
32
+ "@unifold/react-provider": "0.1.41",
33
+ "@unifold/ui-react": "0.1.41"
34
34
  },
35
35
  "keywords": [
36
36
  "unifold",