@unifold/ui-web 0.1.47 → 0.1.49

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 +113 -137
  2. package/dist/index.mjs +113 -137
  3. package/package.json +8 -5
package/dist/index.js CHANGED
@@ -50428,16 +50428,6 @@ function BuyWithCard({
50428
50428
  window.open(sessionStartUrl, "_blank");
50429
50429
  handleViewChange("onramp");
50430
50430
  };
50431
- const getProviderBadges = (quote, allQuotes) => {
50432
- const badges = [];
50433
- const maxDestination = Math.max(
50434
- ...allQuotes.map((q) => q.destination_amount)
50435
- );
50436
- if (quote.destination_amount === maxDestination) {
50437
- badges.push("Best price");
50438
- }
50439
- return badges;
50440
- };
50441
50431
  const sortedQuotes = [...quotes].sort(
50442
50432
  (a, b) => b.destination_amount - a.destination_amount
50443
50433
  );
@@ -50642,31 +50632,7 @@ function BuyWithCard({
50642
50632
  children: selectedProvider.service_provider_display_name
50643
50633
  }
50644
50634
  ),
50645
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: [
50646
- isAutoSelected && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50647
- "span",
50648
- {
50649
- className: "uf-text-[10px] uf-font-normal",
50650
- style: {
50651
- color: colors2.success,
50652
- fontFamily: fonts.regular
50653
- },
50654
- children: "Best price"
50655
- }
50656
- ),
50657
- isAutoSelected && selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50658
- "span",
50659
- {
50660
- className: "uf-text-[10px]",
50661
- style: {
50662
- color: components.card.labelColor,
50663
- fontFamily: fonts.regular
50664
- },
50665
- children: "\u2022"
50666
- }
50667
- ),
50668
- selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uf-text-[10px] uf-text-muted-foreground uf-font-normal", children: "No document upload" })
50669
- ] })
50635
+ selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uf-text-[10px] uf-text-muted-foreground uf-font-normal", children: "No document upload" }) })
50670
50636
  ] }),
50671
50637
  quotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50672
50638
  ChevronRight,
@@ -50730,7 +50696,6 @@ function BuyWithCard({
50730
50696
  {
50731
50697
  className: `uf-transition-all uf-duration-300 uf-min-h-[420px] uf-flex uf-flex-col ${showQuotesView && !showOnrampView ? "uf-opacity-100" : "uf-opacity-0 uf-pointer-events-none uf-absolute uf-inset-0"}`,
50732
50698
  children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-space-y-2 uf-pt-2 uf-pb-8 uf-overflow-y-auto uf-flex-1 uf-min-h-0", children: sortedQuotes.map((quote, index2) => {
50733
- const badges = getProviderBadges(quote, sortedQuotes);
50734
50699
  const displayName = quote.service_provider_display_name;
50735
50700
  const isSelected = selectedProvider?.service_provider === quote.service_provider;
50736
50701
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
@@ -50773,39 +50738,17 @@ function BuyWithCard({
50773
50738
  children: displayName
50774
50739
  }
50775
50740
  ),
50776
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: [
50777
- badges.map((badge, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
50778
- "span",
50779
- {
50780
- className: "uf-text-[10px] uf-font-normal",
50781
- style: { color: colors2.success },
50782
- children: [
50783
- badge,
50784
- i < badges.length - 1 && ","
50785
- ]
50741
+ quote.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50742
+ "span",
50743
+ {
50744
+ className: "uf-text-[10px] uf-font-normal",
50745
+ style: {
50746
+ color: components.card.subtextRightColor,
50747
+ fontFamily: fonts.regular
50786
50748
  },
50787
- i
50788
- )),
50789
- quote.low_kyc === false && badges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50790
- "span",
50791
- {
50792
- className: "uf-text-[10px]",
50793
- style: { color: components.card.subtextRightColor },
50794
- children: "\u2022"
50795
- }
50796
- ),
50797
- quote.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50798
- "span",
50799
- {
50800
- className: "uf-text-[10px] uf-font-normal",
50801
- style: {
50802
- color: components.card.subtextRightColor,
50803
- fontFamily: fonts.regular
50804
- },
50805
- children: "No document upload"
50806
- }
50807
- )
50808
- ] })
50749
+ children: "No document upload"
50750
+ }
50751
+ ) })
50809
50752
  ] })
50810
50753
  ] }),
50811
50754
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-text-right", children: [
@@ -55421,72 +55364,72 @@ function DepositPollingUi({
55421
55364
  var getChainKey = (chainId, chainType) => {
55422
55365
  return `${chainType}:${chainId}`;
55423
55366
  };
55424
- function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
55425
- if (!supportedTokens.length) return null;
55426
- let selectedTokenData;
55427
- let selectedChainData;
55428
- const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
55429
- if (defaultSourceTokenAddress && hasChainDefaults) {
55430
- for (const t11 of supportedTokens) {
55367
+ function resolveToken(tokens, defaultChainType, defaultChainId, defaultTokenAddress, defaultSymbol) {
55368
+ if (!tokens.length) return null;
55369
+ let selectedToken;
55370
+ let selectedChain;
55371
+ const hasChainDefaults = defaultChainType && defaultChainId;
55372
+ if (defaultTokenAddress && hasChainDefaults) {
55373
+ for (const t11 of tokens) {
55431
55374
  const matchingChain = t11.chains.find(
55432
- (c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55375
+ (c) => c.token_address.toLowerCase() === defaultTokenAddress.toLowerCase() && c.chain_type === defaultChainType && c.chain_id === defaultChainId
55433
55376
  );
55434
55377
  if (matchingChain) {
55435
- selectedTokenData = t11;
55436
- selectedChainData = matchingChain;
55378
+ selectedToken = t11;
55379
+ selectedChain = matchingChain;
55437
55380
  break;
55438
55381
  }
55439
55382
  }
55440
55383
  }
55441
- if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
55442
- for (const t11 of supportedTokens) {
55443
- if (t11.symbol !== defaultSourceSymbol) continue;
55384
+ if (!selectedToken && defaultSymbol && hasChainDefaults) {
55385
+ for (const t11 of tokens) {
55386
+ if (t11.symbol !== defaultSymbol) continue;
55444
55387
  const matchedChain = t11.chains.find(
55445
- (c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55388
+ (c) => c.chain_type === defaultChainType && c.chain_id === defaultChainId
55446
55389
  );
55447
55390
  if (matchedChain) {
55448
- selectedTokenData = t11;
55449
- selectedChainData = matchedChain;
55391
+ selectedToken = t11;
55392
+ selectedChain = matchedChain;
55450
55393
  break;
55451
55394
  }
55452
55395
  }
55453
55396
  }
55454
- if (!selectedTokenData) {
55455
- for (const t11 of supportedTokens) {
55397
+ if (!selectedToken) {
55398
+ for (const t11 of tokens) {
55456
55399
  if (t11.chains.length > 0) {
55457
- selectedTokenData = t11;
55458
- selectedChainData = t11.chains[0];
55400
+ selectedToken = t11;
55401
+ selectedChain = t11.chains[0];
55459
55402
  break;
55460
55403
  }
55461
55404
  }
55462
55405
  }
55463
- if (selectedTokenData && selectedChainData) {
55464
- return { token: selectedTokenData, chain: selectedChainData };
55406
+ if (selectedToken && selectedChain) {
55407
+ return { token: selectedToken, chain: selectedChain };
55465
55408
  }
55466
55409
  return null;
55467
55410
  }
55468
- function useDefaultSourceToken({
55469
- supportedTokens,
55470
- defaultSourceChainType,
55471
- defaultSourceChainId,
55472
- defaultSourceTokenAddress,
55473
- defaultSourceSymbol
55411
+ function useDefaultToken({
55412
+ tokens,
55413
+ defaultChainType,
55414
+ defaultChainId,
55415
+ defaultTokenAddress,
55416
+ defaultSymbol
55474
55417
  }) {
55475
55418
  const [token, setToken] = (0, import_react20.useState)(null);
55476
55419
  const [chain, setChain] = (0, import_react20.useState)(null);
55477
55420
  const [initialSelectionDone, setInitialSelectionDone] = (0, import_react20.useState)(false);
55478
55421
  const appliedDefaultsRef = (0, import_react20.useRef)("");
55479
55422
  (0, import_react20.useEffect)(() => {
55480
- if (!supportedTokens.length) return;
55481
- const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
55423
+ if (!tokens.length) return;
55424
+ const defaultsKey = `${defaultTokenAddress ?? ""}|${defaultSymbol ?? ""}|${defaultChainType ?? ""}|${defaultChainId ?? ""}`;
55482
55425
  const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
55483
55426
  if (initialSelectionDone && !defaultsChanged) return;
55484
- const result = resolveSourceToken(
55485
- supportedTokens,
55486
- defaultSourceChainType,
55487
- defaultSourceChainId,
55488
- defaultSourceTokenAddress,
55489
- defaultSourceSymbol
55427
+ const result = resolveToken(
55428
+ tokens,
55429
+ defaultChainType,
55430
+ defaultChainId,
55431
+ defaultTokenAddress,
55432
+ defaultSymbol
55490
55433
  );
55491
55434
  if (result) {
55492
55435
  setToken(result.token.symbol);
@@ -55495,16 +55438,16 @@ function useDefaultSourceToken({
55495
55438
  setInitialSelectionDone(true);
55496
55439
  }
55497
55440
  }, [
55498
- supportedTokens,
55499
- defaultSourceTokenAddress,
55500
- defaultSourceSymbol,
55501
- defaultSourceChainType,
55502
- defaultSourceChainId,
55441
+ tokens,
55442
+ defaultTokenAddress,
55443
+ defaultSymbol,
55444
+ defaultChainType,
55445
+ defaultChainId,
55503
55446
  initialSelectionDone
55504
55447
  ]);
55505
55448
  (0, import_react20.useEffect)(() => {
55506
- if (!supportedTokens.length || !token) return;
55507
- const currentToken = supportedTokens.find((t11) => t11.symbol === token);
55449
+ if (!tokens.length || !token) return;
55450
+ const currentToken = tokens.find((t11) => t11.symbol === token);
55508
55451
  if (!currentToken || currentToken.chains.length === 0) return;
55509
55452
  const isChainAvailable = chain && currentToken.chains.some((c) => {
55510
55453
  return getChainKey(c.chain_id, c.chain_type) === chain;
@@ -55513,9 +55456,24 @@ function useDefaultSourceToken({
55513
55456
  const firstChain = currentToken.chains[0];
55514
55457
  setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
55515
55458
  }
55516
- }, [token, supportedTokens, chain]);
55459
+ }, [token, tokens, chain]);
55517
55460
  return { token, chain, setToken, setChain, initialSelectionDone };
55518
55461
  }
55462
+ function useDefaultSourceToken({
55463
+ supportedTokens,
55464
+ defaultSourceChainType,
55465
+ defaultSourceChainId,
55466
+ defaultSourceTokenAddress,
55467
+ defaultSourceSymbol
55468
+ }) {
55469
+ return useDefaultToken({
55470
+ tokens: supportedTokens,
55471
+ defaultChainType: defaultSourceChainType,
55472
+ defaultChainId: defaultSourceChainId,
55473
+ defaultTokenAddress: defaultSourceTokenAddress,
55474
+ defaultSymbol: defaultSourceSymbol
55475
+ });
55476
+ }
55519
55477
  function DepositFooterLinks({
55520
55478
  onGlossaryClick
55521
55479
  }) {
@@ -60469,6 +60427,21 @@ function useSupportedDestinationTokens(publishableKey, enabled = true) {
60469
60427
  enabled
60470
60428
  });
60471
60429
  }
60430
+ function useDefaultDestinationToken({
60431
+ destinationTokens,
60432
+ defaultDestinationChainType,
60433
+ defaultDestinationChainId,
60434
+ defaultDestinationTokenAddress,
60435
+ defaultDestinationSymbol
60436
+ }) {
60437
+ return useDefaultToken({
60438
+ tokens: destinationTokens,
60439
+ defaultChainType: defaultDestinationChainType,
60440
+ defaultChainId: defaultDestinationChainId,
60441
+ defaultTokenAddress: defaultDestinationTokenAddress,
60442
+ defaultSymbol: defaultDestinationSymbol
60443
+ });
60444
+ }
60472
60445
  function useSourceTokenValidation(params) {
60473
60446
  const {
60474
60447
  sourceChainType,
@@ -61715,6 +61688,10 @@ function WithdrawModal({
61715
61688
  sourceTokenSymbol,
61716
61689
  recipientAddress: recipientAddressProp,
61717
61690
  senderAddress,
61691
+ defaultDestinationChainType,
61692
+ defaultDestinationChainId,
61693
+ defaultDestinationTokenAddress,
61694
+ defaultDestinationSymbol,
61718
61695
  onWithdraw,
61719
61696
  onWithdrawSuccess,
61720
61697
  onWithdrawError,
@@ -61758,8 +61735,21 @@ function WithdrawModal({
61758
61735
  publishableKey,
61759
61736
  enabled: open
61760
61737
  });
61761
- const [selectedToken, setSelectedToken] = (0, import_react28.useState)(null);
61762
- const [selectedChain, setSelectedChain] = (0, import_react28.useState)(null);
61738
+ const {
61739
+ token: selectedTokenSymbol,
61740
+ chain: selectedChainKey,
61741
+ setToken: setSelectedTokenSymbol,
61742
+ setChain: setSelectedChainKey,
61743
+ initialSelectionDone
61744
+ } = useDefaultDestinationToken({
61745
+ destinationTokens,
61746
+ defaultDestinationChainType,
61747
+ defaultDestinationChainId,
61748
+ defaultDestinationTokenAddress,
61749
+ defaultDestinationSymbol
61750
+ });
61751
+ const selectedToken = selectedTokenSymbol ? destinationTokens.find((t11) => t11.symbol === selectedTokenSymbol) ?? null : null;
61752
+ const selectedChain = selectedToken && selectedChainKey ? selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === selectedChainKey) ?? null : null;
61763
61753
  const [view, setView] = (0, import_react28.useState)("form");
61764
61754
  const [withdrawDepositWalletId, setWithdrawDepositWalletId] = (0, import_react28.useState)();
61765
61755
  const [selectedExecution, setSelectedExecution] = (0, import_react28.useState)(null);
@@ -61801,21 +61791,11 @@ function WithdrawModal({
61801
61791
  setSubmittedTxInfo(txInfo);
61802
61792
  setView("confirming");
61803
61793
  }, []);
61804
- (0, import_react28.useEffect)(() => {
61805
- if (!destinationTokens.length || selectedToken) return;
61806
- const first = destinationTokens[0];
61807
- if (first?.chains.length > 0) {
61808
- setSelectedToken(first);
61809
- setSelectedChain(first.chains[0]);
61810
- }
61811
- }, [destinationTokens, selectedToken]);
61812
61794
  const resetViewTimeoutRef = (0, import_react28.useRef)(null);
61813
61795
  const handleClose = (0, import_react28.useCallback)(() => {
61814
61796
  onOpenChange(false);
61815
61797
  if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
61816
61798
  resetViewTimeoutRef.current = setTimeout(() => {
61817
- setSelectedToken(null);
61818
- setSelectedChain(null);
61819
61799
  setView("form");
61820
61800
  setSelectedExecution(null);
61821
61801
  setSubmittedTxInfo(null);
@@ -61829,8 +61809,6 @@ function WithdrawModal({
61829
61809
  clearTimeout(resetViewTimeoutRef.current);
61830
61810
  resetViewTimeoutRef.current = null;
61831
61811
  }
61832
- setSelectedToken(null);
61833
- setSelectedChain(null);
61834
61812
  setView("form");
61835
61813
  setSelectedExecution(null);
61836
61814
  setSubmittedTxInfo(null);
@@ -61840,19 +61818,13 @@ function WithdrawModal({
61840
61818
  if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
61841
61819
  }, []);
61842
61820
  const handleTokenSymbolChange = (0, import_react28.useCallback)((symbol) => {
61843
- const tok = destinationTokens.find((t11) => t11.symbol === symbol);
61844
- if (tok) {
61845
- setSelectedToken(tok);
61846
- if (tok.chains.length > 0) setSelectedChain(tok.chains[0]);
61847
- }
61848
- }, [destinationTokens]);
61821
+ setSelectedTokenSymbol(symbol);
61822
+ }, [setSelectedTokenSymbol]);
61849
61823
  const handleChainKeyChange = (0, import_react28.useCallback)((chainKey) => {
61850
- if (!selectedToken) return;
61851
- const chain = selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === chainKey);
61852
- if (chain) setSelectedChain(chain);
61853
- }, [selectedToken]);
61824
+ setSelectedChainKey(chainKey);
61825
+ }, [setSelectedChainKey]);
61854
61826
  const isSourceSupported = sourceValidation?.isSupported ?? null;
61855
- const isAnyLoading = tokensLoading || isCheckingSourceToken;
61827
+ const isAnyLoading = tokensLoading || isCheckingSourceToken || destinationTokens.length > 0 && !initialSelectionDone;
61856
61828
  const withdrawPoweredByFooter = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PoweredByUnifold, { color: colors2.foregroundMuted, className: "uf-flex uf-justify-center uf-shrink-0" }) });
61857
61829
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PortalContainerProvider, { value: hideOverlay ? containerEl : null, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Dialog2, { open: hideOverlay || open, onOpenChange: hideOverlay ? void 0 : handleClose, modal: !hideOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
61858
61830
  DialogContent2,
@@ -62262,6 +62234,10 @@ function UnifoldProvider2({
62262
62234
  sourceTokenAddress: withdrawConfig.sourceTokenAddress,
62263
62235
  sourceTokenSymbol: withdrawConfig.sourceTokenSymbol,
62264
62236
  recipientAddress: withdrawConfig.recipientAddress,
62237
+ defaultDestinationChainType: withdrawConfig.defaultDestinationChainType,
62238
+ defaultDestinationChainId: withdrawConfig.defaultDestinationChainId,
62239
+ defaultDestinationTokenAddress: withdrawConfig.defaultDestinationTokenAddress,
62240
+ defaultDestinationSymbol: withdrawConfig.defaultDestinationSymbol,
62265
62241
  senderAddress: withdrawConfig.senderAddress,
62266
62242
  onWithdraw: withdrawConfig.withdraw,
62267
62243
  onWithdrawSuccess: handleWithdrawSuccess,
package/dist/index.mjs CHANGED
@@ -50415,16 +50415,6 @@ function BuyWithCard({
50415
50415
  window.open(sessionStartUrl, "_blank");
50416
50416
  handleViewChange("onramp");
50417
50417
  };
50418
- const getProviderBadges = (quote, allQuotes) => {
50419
- const badges = [];
50420
- const maxDestination = Math.max(
50421
- ...allQuotes.map((q) => q.destination_amount)
50422
- );
50423
- if (quote.destination_amount === maxDestination) {
50424
- badges.push("Best price");
50425
- }
50426
- return badges;
50427
- };
50428
50418
  const sortedQuotes = [...quotes].sort(
50429
50419
  (a, b) => b.destination_amount - a.destination_amount
50430
50420
  );
@@ -50629,31 +50619,7 @@ function BuyWithCard({
50629
50619
  children: selectedProvider.service_provider_display_name
50630
50620
  }
50631
50621
  ),
50632
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: [
50633
- isAutoSelected && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50634
- "span",
50635
- {
50636
- className: "uf-text-[10px] uf-font-normal",
50637
- style: {
50638
- color: colors2.success,
50639
- fontFamily: fonts.regular
50640
- },
50641
- children: "Best price"
50642
- }
50643
- ),
50644
- isAutoSelected && selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50645
- "span",
50646
- {
50647
- className: "uf-text-[10px]",
50648
- style: {
50649
- color: components.card.labelColor,
50650
- fontFamily: fonts.regular
50651
- },
50652
- children: "\u2022"
50653
- }
50654
- ),
50655
- selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uf-text-[10px] uf-text-muted-foreground uf-font-normal", children: "No document upload" })
50656
- ] })
50622
+ selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uf-text-[10px] uf-text-muted-foreground uf-font-normal", children: "No document upload" }) })
50657
50623
  ] }),
50658
50624
  quotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50659
50625
  ChevronRight,
@@ -50717,7 +50683,6 @@ function BuyWithCard({
50717
50683
  {
50718
50684
  className: `uf-transition-all uf-duration-300 uf-min-h-[420px] uf-flex uf-flex-col ${showQuotesView && !showOnrampView ? "uf-opacity-100" : "uf-opacity-0 uf-pointer-events-none uf-absolute uf-inset-0"}`,
50719
50685
  children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-space-y-2 uf-pt-2 uf-pb-8 uf-overflow-y-auto uf-flex-1 uf-min-h-0", children: sortedQuotes.map((quote, index2) => {
50720
- const badges = getProviderBadges(quote, sortedQuotes);
50721
50686
  const displayName = quote.service_provider_display_name;
50722
50687
  const isSelected = selectedProvider?.service_provider === quote.service_provider;
50723
50688
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
@@ -50760,39 +50725,17 @@ function BuyWithCard({
50760
50725
  children: displayName
50761
50726
  }
50762
50727
  ),
50763
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: [
50764
- badges.map((badge, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
50765
- "span",
50766
- {
50767
- className: "uf-text-[10px] uf-font-normal",
50768
- style: { color: colors2.success },
50769
- children: [
50770
- badge,
50771
- i < badges.length - 1 && ","
50772
- ]
50728
+ quote.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50729
+ "span",
50730
+ {
50731
+ className: "uf-text-[10px] uf-font-normal",
50732
+ style: {
50733
+ color: components.card.subtextRightColor,
50734
+ fontFamily: fonts.regular
50773
50735
  },
50774
- i
50775
- )),
50776
- quote.low_kyc === false && badges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50777
- "span",
50778
- {
50779
- className: "uf-text-[10px]",
50780
- style: { color: components.card.subtextRightColor },
50781
- children: "\u2022"
50782
- }
50783
- ),
50784
- quote.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
50785
- "span",
50786
- {
50787
- className: "uf-text-[10px] uf-font-normal",
50788
- style: {
50789
- color: components.card.subtextRightColor,
50790
- fontFamily: fonts.regular
50791
- },
50792
- children: "No document upload"
50793
- }
50794
- )
50795
- ] })
50736
+ children: "No document upload"
50737
+ }
50738
+ ) })
50796
50739
  ] })
50797
50740
  ] }),
50798
50741
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-text-right", children: [
@@ -55408,72 +55351,72 @@ function DepositPollingUi({
55408
55351
  var getChainKey = (chainId, chainType) => {
55409
55352
  return `${chainType}:${chainId}`;
55410
55353
  };
55411
- function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
55412
- if (!supportedTokens.length) return null;
55413
- let selectedTokenData;
55414
- let selectedChainData;
55415
- const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
55416
- if (defaultSourceTokenAddress && hasChainDefaults) {
55417
- for (const t11 of supportedTokens) {
55354
+ function resolveToken(tokens, defaultChainType, defaultChainId, defaultTokenAddress, defaultSymbol) {
55355
+ if (!tokens.length) return null;
55356
+ let selectedToken;
55357
+ let selectedChain;
55358
+ const hasChainDefaults = defaultChainType && defaultChainId;
55359
+ if (defaultTokenAddress && hasChainDefaults) {
55360
+ for (const t11 of tokens) {
55418
55361
  const matchingChain = t11.chains.find(
55419
- (c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55362
+ (c) => c.token_address.toLowerCase() === defaultTokenAddress.toLowerCase() && c.chain_type === defaultChainType && c.chain_id === defaultChainId
55420
55363
  );
55421
55364
  if (matchingChain) {
55422
- selectedTokenData = t11;
55423
- selectedChainData = matchingChain;
55365
+ selectedToken = t11;
55366
+ selectedChain = matchingChain;
55424
55367
  break;
55425
55368
  }
55426
55369
  }
55427
55370
  }
55428
- if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
55429
- for (const t11 of supportedTokens) {
55430
- if (t11.symbol !== defaultSourceSymbol) continue;
55371
+ if (!selectedToken && defaultSymbol && hasChainDefaults) {
55372
+ for (const t11 of tokens) {
55373
+ if (t11.symbol !== defaultSymbol) continue;
55431
55374
  const matchedChain = t11.chains.find(
55432
- (c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
55375
+ (c) => c.chain_type === defaultChainType && c.chain_id === defaultChainId
55433
55376
  );
55434
55377
  if (matchedChain) {
55435
- selectedTokenData = t11;
55436
- selectedChainData = matchedChain;
55378
+ selectedToken = t11;
55379
+ selectedChain = matchedChain;
55437
55380
  break;
55438
55381
  }
55439
55382
  }
55440
55383
  }
55441
- if (!selectedTokenData) {
55442
- for (const t11 of supportedTokens) {
55384
+ if (!selectedToken) {
55385
+ for (const t11 of tokens) {
55443
55386
  if (t11.chains.length > 0) {
55444
- selectedTokenData = t11;
55445
- selectedChainData = t11.chains[0];
55387
+ selectedToken = t11;
55388
+ selectedChain = t11.chains[0];
55446
55389
  break;
55447
55390
  }
55448
55391
  }
55449
55392
  }
55450
- if (selectedTokenData && selectedChainData) {
55451
- return { token: selectedTokenData, chain: selectedChainData };
55393
+ if (selectedToken && selectedChain) {
55394
+ return { token: selectedToken, chain: selectedChain };
55452
55395
  }
55453
55396
  return null;
55454
55397
  }
55455
- function useDefaultSourceToken({
55456
- supportedTokens,
55457
- defaultSourceChainType,
55458
- defaultSourceChainId,
55459
- defaultSourceTokenAddress,
55460
- defaultSourceSymbol
55398
+ function useDefaultToken({
55399
+ tokens,
55400
+ defaultChainType,
55401
+ defaultChainId,
55402
+ defaultTokenAddress,
55403
+ defaultSymbol
55461
55404
  }) {
55462
55405
  const [token, setToken] = (0, import_react20.useState)(null);
55463
55406
  const [chain, setChain] = (0, import_react20.useState)(null);
55464
55407
  const [initialSelectionDone, setInitialSelectionDone] = (0, import_react20.useState)(false);
55465
55408
  const appliedDefaultsRef = (0, import_react20.useRef)("");
55466
55409
  (0, import_react20.useEffect)(() => {
55467
- if (!supportedTokens.length) return;
55468
- const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
55410
+ if (!tokens.length) return;
55411
+ const defaultsKey = `${defaultTokenAddress ?? ""}|${defaultSymbol ?? ""}|${defaultChainType ?? ""}|${defaultChainId ?? ""}`;
55469
55412
  const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
55470
55413
  if (initialSelectionDone && !defaultsChanged) return;
55471
- const result = resolveSourceToken(
55472
- supportedTokens,
55473
- defaultSourceChainType,
55474
- defaultSourceChainId,
55475
- defaultSourceTokenAddress,
55476
- defaultSourceSymbol
55414
+ const result = resolveToken(
55415
+ tokens,
55416
+ defaultChainType,
55417
+ defaultChainId,
55418
+ defaultTokenAddress,
55419
+ defaultSymbol
55477
55420
  );
55478
55421
  if (result) {
55479
55422
  setToken(result.token.symbol);
@@ -55482,16 +55425,16 @@ function useDefaultSourceToken({
55482
55425
  setInitialSelectionDone(true);
55483
55426
  }
55484
55427
  }, [
55485
- supportedTokens,
55486
- defaultSourceTokenAddress,
55487
- defaultSourceSymbol,
55488
- defaultSourceChainType,
55489
- defaultSourceChainId,
55428
+ tokens,
55429
+ defaultTokenAddress,
55430
+ defaultSymbol,
55431
+ defaultChainType,
55432
+ defaultChainId,
55490
55433
  initialSelectionDone
55491
55434
  ]);
55492
55435
  (0, import_react20.useEffect)(() => {
55493
- if (!supportedTokens.length || !token) return;
55494
- const currentToken = supportedTokens.find((t11) => t11.symbol === token);
55436
+ if (!tokens.length || !token) return;
55437
+ const currentToken = tokens.find((t11) => t11.symbol === token);
55495
55438
  if (!currentToken || currentToken.chains.length === 0) return;
55496
55439
  const isChainAvailable = chain && currentToken.chains.some((c) => {
55497
55440
  return getChainKey(c.chain_id, c.chain_type) === chain;
@@ -55500,9 +55443,24 @@ function useDefaultSourceToken({
55500
55443
  const firstChain = currentToken.chains[0];
55501
55444
  setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
55502
55445
  }
55503
- }, [token, supportedTokens, chain]);
55446
+ }, [token, tokens, chain]);
55504
55447
  return { token, chain, setToken, setChain, initialSelectionDone };
55505
55448
  }
55449
+ function useDefaultSourceToken({
55450
+ supportedTokens,
55451
+ defaultSourceChainType,
55452
+ defaultSourceChainId,
55453
+ defaultSourceTokenAddress,
55454
+ defaultSourceSymbol
55455
+ }) {
55456
+ return useDefaultToken({
55457
+ tokens: supportedTokens,
55458
+ defaultChainType: defaultSourceChainType,
55459
+ defaultChainId: defaultSourceChainId,
55460
+ defaultTokenAddress: defaultSourceTokenAddress,
55461
+ defaultSymbol: defaultSourceSymbol
55462
+ });
55463
+ }
55506
55464
  function DepositFooterLinks({
55507
55465
  onGlossaryClick
55508
55466
  }) {
@@ -60456,6 +60414,21 @@ function useSupportedDestinationTokens(publishableKey, enabled = true) {
60456
60414
  enabled
60457
60415
  });
60458
60416
  }
60417
+ function useDefaultDestinationToken({
60418
+ destinationTokens,
60419
+ defaultDestinationChainType,
60420
+ defaultDestinationChainId,
60421
+ defaultDestinationTokenAddress,
60422
+ defaultDestinationSymbol
60423
+ }) {
60424
+ return useDefaultToken({
60425
+ tokens: destinationTokens,
60426
+ defaultChainType: defaultDestinationChainType,
60427
+ defaultChainId: defaultDestinationChainId,
60428
+ defaultTokenAddress: defaultDestinationTokenAddress,
60429
+ defaultSymbol: defaultDestinationSymbol
60430
+ });
60431
+ }
60459
60432
  function useSourceTokenValidation(params) {
60460
60433
  const {
60461
60434
  sourceChainType,
@@ -61702,6 +61675,10 @@ function WithdrawModal({
61702
61675
  sourceTokenSymbol,
61703
61676
  recipientAddress: recipientAddressProp,
61704
61677
  senderAddress,
61678
+ defaultDestinationChainType,
61679
+ defaultDestinationChainId,
61680
+ defaultDestinationTokenAddress,
61681
+ defaultDestinationSymbol,
61705
61682
  onWithdraw,
61706
61683
  onWithdrawSuccess,
61707
61684
  onWithdrawError,
@@ -61745,8 +61722,21 @@ function WithdrawModal({
61745
61722
  publishableKey,
61746
61723
  enabled: open
61747
61724
  });
61748
- const [selectedToken, setSelectedToken] = (0, import_react28.useState)(null);
61749
- const [selectedChain, setSelectedChain] = (0, import_react28.useState)(null);
61725
+ const {
61726
+ token: selectedTokenSymbol,
61727
+ chain: selectedChainKey,
61728
+ setToken: setSelectedTokenSymbol,
61729
+ setChain: setSelectedChainKey,
61730
+ initialSelectionDone
61731
+ } = useDefaultDestinationToken({
61732
+ destinationTokens,
61733
+ defaultDestinationChainType,
61734
+ defaultDestinationChainId,
61735
+ defaultDestinationTokenAddress,
61736
+ defaultDestinationSymbol
61737
+ });
61738
+ const selectedToken = selectedTokenSymbol ? destinationTokens.find((t11) => t11.symbol === selectedTokenSymbol) ?? null : null;
61739
+ const selectedChain = selectedToken && selectedChainKey ? selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === selectedChainKey) ?? null : null;
61750
61740
  const [view, setView] = (0, import_react28.useState)("form");
61751
61741
  const [withdrawDepositWalletId, setWithdrawDepositWalletId] = (0, import_react28.useState)();
61752
61742
  const [selectedExecution, setSelectedExecution] = (0, import_react28.useState)(null);
@@ -61788,21 +61778,11 @@ function WithdrawModal({
61788
61778
  setSubmittedTxInfo(txInfo);
61789
61779
  setView("confirming");
61790
61780
  }, []);
61791
- (0, import_react28.useEffect)(() => {
61792
- if (!destinationTokens.length || selectedToken) return;
61793
- const first = destinationTokens[0];
61794
- if (first?.chains.length > 0) {
61795
- setSelectedToken(first);
61796
- setSelectedChain(first.chains[0]);
61797
- }
61798
- }, [destinationTokens, selectedToken]);
61799
61781
  const resetViewTimeoutRef = (0, import_react28.useRef)(null);
61800
61782
  const handleClose = (0, import_react28.useCallback)(() => {
61801
61783
  onOpenChange(false);
61802
61784
  if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
61803
61785
  resetViewTimeoutRef.current = setTimeout(() => {
61804
- setSelectedToken(null);
61805
- setSelectedChain(null);
61806
61786
  setView("form");
61807
61787
  setSelectedExecution(null);
61808
61788
  setSubmittedTxInfo(null);
@@ -61816,8 +61796,6 @@ function WithdrawModal({
61816
61796
  clearTimeout(resetViewTimeoutRef.current);
61817
61797
  resetViewTimeoutRef.current = null;
61818
61798
  }
61819
- setSelectedToken(null);
61820
- setSelectedChain(null);
61821
61799
  setView("form");
61822
61800
  setSelectedExecution(null);
61823
61801
  setSubmittedTxInfo(null);
@@ -61827,19 +61805,13 @@ function WithdrawModal({
61827
61805
  if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
61828
61806
  }, []);
61829
61807
  const handleTokenSymbolChange = (0, import_react28.useCallback)((symbol) => {
61830
- const tok = destinationTokens.find((t11) => t11.symbol === symbol);
61831
- if (tok) {
61832
- setSelectedToken(tok);
61833
- if (tok.chains.length > 0) setSelectedChain(tok.chains[0]);
61834
- }
61835
- }, [destinationTokens]);
61808
+ setSelectedTokenSymbol(symbol);
61809
+ }, [setSelectedTokenSymbol]);
61836
61810
  const handleChainKeyChange = (0, import_react28.useCallback)((chainKey) => {
61837
- if (!selectedToken) return;
61838
- const chain = selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === chainKey);
61839
- if (chain) setSelectedChain(chain);
61840
- }, [selectedToken]);
61811
+ setSelectedChainKey(chainKey);
61812
+ }, [setSelectedChainKey]);
61841
61813
  const isSourceSupported = sourceValidation?.isSupported ?? null;
61842
- const isAnyLoading = tokensLoading || isCheckingSourceToken;
61814
+ const isAnyLoading = tokensLoading || isCheckingSourceToken || destinationTokens.length > 0 && !initialSelectionDone;
61843
61815
  const withdrawPoweredByFooter = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PoweredByUnifold, { color: colors2.foregroundMuted, className: "uf-flex uf-justify-center uf-shrink-0" }) });
61844
61816
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PortalContainerProvider, { value: hideOverlay ? containerEl : null, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Dialog2, { open: hideOverlay || open, onOpenChange: hideOverlay ? void 0 : handleClose, modal: !hideOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
61845
61817
  DialogContent2,
@@ -62249,6 +62221,10 @@ function UnifoldProvider2({
62249
62221
  sourceTokenAddress: withdrawConfig.sourceTokenAddress,
62250
62222
  sourceTokenSymbol: withdrawConfig.sourceTokenSymbol,
62251
62223
  recipientAddress: withdrawConfig.recipientAddress,
62224
+ defaultDestinationChainType: withdrawConfig.defaultDestinationChainType,
62225
+ defaultDestinationChainId: withdrawConfig.defaultDestinationChainId,
62226
+ defaultDestinationTokenAddress: withdrawConfig.defaultDestinationTokenAddress,
62227
+ defaultDestinationSymbol: withdrawConfig.defaultDestinationSymbol,
62252
62228
  senderAddress: withdrawConfig.senderAddress,
62253
62229
  onWithdraw: withdrawConfig.withdraw,
62254
62230
  onWithdrawSuccess: handleWithdrawSuccess,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-web",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "Unifold UI Web - Framework-agnostic deposit widget",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -19,6 +19,9 @@
19
19
  "dist",
20
20
  "README.md"
21
21
  ],
22
+ "peerDependencies": {
23
+ "@solana/web3.js": "^1.87.0"
24
+ },
22
25
  "devDependencies": {
23
26
  "@tanstack/react-query": "^5.90.11",
24
27
  "react": "^18.2.0 || ^19.0.0",
@@ -27,10 +30,10 @@
27
30
  "@types/react-dom": "^19.0.0",
28
31
  "tsup": "^8.0.0",
29
32
  "typescript": "^5.0.0",
30
- "@unifold/connect-react": "0.1.47",
31
- "@unifold/core": "0.1.47",
32
- "@unifold/ui-react": "0.1.47",
33
- "@unifold/react-provider": "0.1.47"
33
+ "@unifold/connect-react": "0.1.49",
34
+ "@unifold/core": "0.1.49",
35
+ "@unifold/react-provider": "0.1.49",
36
+ "@unifold/ui-react": "0.1.49"
34
37
  },
35
38
  "keywords": [
36
39
  "unifold",