@imtbl/sdk 1.63.0 → 1.64.0-alpha.2

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 (59) hide show
  1. package/dist/{blockchain_data-Dpv5muPl.js → blockchain_data-Nd9tDahm.js} +2 -2
  2. package/dist/blockchain_data.js +3 -3
  3. package/dist/browser/checkout/{AddTokensWidget-BfDY0LwB.js → AddTokensWidget-BQw-P60S.js} +56 -28
  4. package/dist/browser/checkout/{BridgeWidget-DreWq2OO.js → BridgeWidget-Cyu5i2LL.js} +9 -8
  5. package/dist/browser/checkout/{CommerceWidget-BFEo_z63.js → CommerceWidget-C5vGYGbd.js} +90 -74
  6. package/dist/browser/checkout/CryptoFiatProvider-3fUUkERi.js +224 -0
  7. package/dist/browser/checkout/{EllipsizedText-_yDoxF8V.js → EllipsizedText-CpY-fwmV.js} +1 -1
  8. package/dist/browser/checkout/{FeesBreakdown-CQVi4M-W.js → FeesBreakdown-C6qrQVEs.js} +1 -1
  9. package/dist/browser/checkout/{HandoverContent-D0HXf455.js → HandoverContent-BENLzW4n.js} +1 -1
  10. package/dist/browser/checkout/{OnRampWidget-BpRLbHli.js → OnRampWidget-JkxC8nMN.js} +3 -3
  11. package/dist/browser/checkout/{SaleWidget-C-ATgwRu.js → SaleWidget-aIL3dbMH.js} +15 -26
  12. package/dist/browser/checkout/{SpendingCapHero-DLdYNa0u.js → SpendingCapHero-C_loMgYA.js} +1 -1
  13. package/dist/browser/checkout/{SwapWidget-Dm2cQUYh.js → SwapWidget-DSQPb69U.js} +9 -8
  14. package/dist/browser/checkout/{TopUpView-Nbu5J6zy.js → TopUpView-3d5yxKuq.js} +6 -239
  15. package/dist/browser/checkout/{WalletApproveHero-Cc6p3CkR.js → WalletApproveHero-B5TXSbim.js} +3 -3
  16. package/dist/browser/checkout/{WalletWidget-C25SCVnz.js → WalletWidget-C-_77Eb9.js} +7 -22
  17. package/dist/browser/checkout/{auto-track-1Zr4QLt3.js → auto-track-D3w38cYJ.js} +1 -1
  18. package/dist/browser/checkout/{index-c7pVchOF.js → index-B0XncTM8.js} +1 -1
  19. package/dist/browser/checkout/{index-DthkZUK5.js → index-CAXT0vz6.js} +1 -1
  20. package/dist/browser/checkout/{index-Vadzr0yp.js → index-CQQwF7M-.js} +1 -1
  21. package/dist/browser/checkout/{index-BYrBQsd2.js → index-CfEMgTvB.js} +2 -2
  22. package/dist/browser/checkout/{index-Co93fBqn.js → index-CluzFQyb.js} +31 -28
  23. package/dist/browser/checkout/{index-DzrC5Kuy.js → index-D8cKqUD1.js} +1 -1
  24. package/dist/browser/checkout/{index-3DC3zK0u.js → index-DUmgcmvB.js} +1 -1
  25. package/dist/browser/checkout/{index-B7urOO_H.js → index-R-wtc9-g.js} +1 -1
  26. package/dist/browser/checkout/{index-t2b5ztUB.js → index-Vok4qNAE.js} +1 -1
  27. package/dist/browser/checkout/{index.umd-CwLr5uH5.js → index.umd-BztHAlRB.js} +1 -1
  28. package/dist/browser/checkout/{retry-DqIpQ6wO.js → retry-DekCi5fl.js} +1 -1
  29. package/dist/browser/checkout/sdk.js +4 -4
  30. package/dist/browser/checkout/{useInterval-D42dwhRA.js → useInterval-BstnDnYa.js} +1 -1
  31. package/dist/browser/checkout/widgets-esm.js +1 -1
  32. package/dist/browser/checkout/widgets.js +936 -984
  33. package/dist/{checkout-Dr99AQC1.js → checkout-Dqmj1x40.js} +5 -5
  34. package/dist/checkout.d.ts +2 -0
  35. package/dist/checkout.js +5 -5
  36. package/dist/{config-DkJOEY8_.js → config-p7sPROak.js} +1 -1
  37. package/dist/config.js +1 -1
  38. package/dist/{index-B7ZGqefm.js → index-B7Ry_G0i.js} +1 -1
  39. package/dist/{index-ONuhnAdl.js → index-BBulTBlw.js} +1 -1
  40. package/dist/{index-DWXUkxHc.js → index-BWfwTwx-.js} +1 -1
  41. package/dist/{index-Dvd-bDuR.js → index-BuZNUhP9.js} +4 -4
  42. package/dist/{index-CK8NRXyO.js → index-DB4LpDqf.js} +1 -1
  43. package/dist/{index-BI-lDUrN.js → index-ulndU_eA.js} +3 -3
  44. package/dist/index.browser.js +5 -5
  45. package/dist/index.browser.js.map +1 -1
  46. package/dist/index.cjs +77 -7
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.js +14 -14
  49. package/dist/{minting_backend-CpZGmZ-L.js → minting_backend-CsKrfvF3.js} +3 -3
  50. package/dist/minting_backend.js +5 -5
  51. package/dist/{orderbook-BGc1pQHt.js → orderbook-BW9zFoLz.js} +1 -1
  52. package/dist/orderbook.js +2 -2
  53. package/dist/{passport-CsmpMk_U.js → passport-CIedTeNc.js} +73 -3
  54. package/dist/passport.js +4 -4
  55. package/dist/{webhook-8q1P3n_h.js → webhook-C20pzRK2.js} +1 -1
  56. package/dist/webhook.js +2 -2
  57. package/dist/{x-BNK0EB3B.js → x-D4XBahT5.js} +3 -3
  58. package/dist/x.js +4 -4
  59. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { A as APIError, B as BlockchainData } from './index-BI-lDUrN.js';
2
- import { i as index } from './index-B7ZGqefm.js';
1
+ import { A as APIError, B as BlockchainData } from './index-ulndU_eA.js';
2
+ import { i as index } from './index-B7Ry_G0i.js';
3
3
 
4
4
  var blockchain_data = /*#__PURE__*/Object.freeze({
5
5
  __proto__: null,
@@ -1,6 +1,6 @@
1
- export { A as APIError, B as BlockchainData } from './index-BI-lDUrN.js';
2
- export { i as Types } from './index-B7ZGqefm.js';
3
- import './index-CK8NRXyO.js';
1
+ export { A as APIError, B as BlockchainData } from './index-ulndU_eA.js';
2
+ export { i as Types } from './index-B7Ry_G0i.js';
3
+ import './index-DB4LpDqf.js';
4
4
  import 'axios';
5
5
  import 'lru-memorise';
6
6
  import 'global-const';
@@ -1,9 +1,9 @@
1
- import { _ as _objectWithoutProperties, x as useTheme, y as useForwardLocalDomRef, z as useGetSubcomponentChild, A as useSplitApartChildrenAndSubComponents, r as reactExports, D as merge$2, F as useResizeObserver, q as jsxs, j as jsx, G as SmartClone, H as Box, J as isChildSubcomponent, K as flattenChildren, M as Body, N as useTheme$1, Q as Icon, R as ButtCon, T as Button, U as _defineProperty, X as isDualVariantIcon, Y as _slicedToArray, Z as isNumberWithinTotal, $ as getStartingSize, a0 as BaseClickable, a1 as ClassNames, a2 as _toConsumableArray, a3 as isError, a4 as Badge, a5 as FramedIcon, a6 as FramedImage, a7 as FramedLogo, a8 as Stack, a9 as hFlex, aa as usePrevious, ab as useBrowserEffect, ac as getHeadingTextStyles, ad as vFlex, ae as centerFlexChildren, af as FormControlLabel, ag as FormControlValidation, ah as FormControlCaption, I as IMTBLWidgetEvents, ai as AddTokensEventType, aj as getDefaultExportFromCjs, ak as commonjsGlobal, l as useTranslation, al as MenuItem, am as tokenValueFormat, an as DEFAULT_TOKEN_FORMATTING_DECIMALS, ao as BigNumber, ap as getRemoteVideo, aq as FramedVideo, ar as motion, as as listItemVariants, at as Divider, au as Fragment, av as listVariants, aw as useProvidersContext, ax as Drawer, ay as useAnalytics, az as UserJourney, aA as Heading, aB as WalletDrawer, aC as UnableToConnectDrawer, aD as ChangedYourMindDrawer, aE as WalletProviderRdns, aF as getProviderSlugFromRdns, aG as Web3Provider, aH as connectEIP6963Provider, aI as identifyUser, aJ as ConnectEIP6963ProviderError, aK as ProvidersContextActions, aL as ViewContext, V as ViewActions, o as SharedViews, k as ChainId, aM as commonjsRequire, aN as getRemoteImage, aO as useHandover, aP as HandoverTarget, aQ as EventTargetContext, aR as getRemoteRive, aS as Trans, aT as Link, aU as useInjectedProviders, aV as getDefaultTokenImage, aW as OverflowDrawerMenu, aX as SimpleLayout, aY as TokenFilterTypes, h as getL2ChainId, aZ as isNativeToken, a_ as getTokenImageByAddress, a$ as orchestrationEvents, b0 as requireSecp256k1$1, b1 as requireLib_commonjs, b2 as require$$0$2, b3 as bech32$2, b4 as bnExports$1, b5 as require$$0$3, b6 as getAugmentedNamespace, b7 as require$$0$4, b8 as minimalisticAssert, b9 as require$$2, ba as hash$6, bb as MaxUint256, bc as merge$3, bd as SvgIcon, be as WalletWarningHero, bf as Environment, bg as t, bh as PriceDisplay, L as LoadingView, bi as viewReducer, bj as initialViewState, bk as isValidAddress, bl as amountInputValidation, bm as CloudImage, E as ErrorView, bn as ServiceUnavailableErrorView, bo as ServiceType } from './index-Co93fBqn.js';
2
- import { f as formatUnits, p as parseUnits } from './index-DzrC5Kuy.js';
3
- import { E as EllipsizedText, C as Contract } from './EllipsizedText-_yDoxF8V.js';
4
- import { r as retry, T as TokenImage } from './retry-DqIpQ6wO.js';
5
- import { H as HandoverContent } from './HandoverContent-D0HXf455.js';
6
- import { F as FeesBreakdown } from './FeesBreakdown-CQVi4M-W.js';
1
+ import { _ as _objectWithoutProperties, w as useTheme, x as useForwardLocalDomRef, y as useGetSubcomponentChild, z as useSplitApartChildrenAndSubComponents, r as reactExports, A as merge$2, D as useResizeObserver, p as jsxs, o as jsx, F as SmartClone, G as Box, H as isChildSubcomponent, J as flattenChildren, K as Body, M as useTheme$1, N as Icon, Q as ButtCon, R as Button, T as _defineProperty, U as isDualVariantIcon, X as _slicedToArray, Y as isNumberWithinTotal, Z as getStartingSize, $ as BaseClickable, a0 as ClassNames, a1 as _toConsumableArray, a2 as isError, a3 as Badge, a4 as FramedIcon, a5 as FramedImage, a6 as FramedLogo, a7 as Stack, a8 as hFlex, a9 as usePrevious, aa as useBrowserEffect, ab as getHeadingTextStyles, ac as vFlex, ad as centerFlexChildren, ae as FormControlLabel, af as FormControlValidation, ag as FormControlCaption, I as IMTBLWidgetEvents, ah as AddTokensEventType, ai as getDefaultExportFromCjs, aj as commonjsGlobal, u as useTranslation, ak as MenuItem, al as tokenValueFormat, am as DEFAULT_TOKEN_FORMATTING_DECIMALS, an as BigNumber, ao as getRemoteVideo, ap as FramedVideo, aq as motion, ar as listItemVariants, as as Divider, at as Fragment, au as listVariants, av as useProvidersContext, aw as Drawer, ax as useAnalytics, ay as UserJourney, az as isPassportProvider, aA as Heading, aB as WalletDrawer, aC as UnableToConnectDrawer, aD as ChangedYourMindDrawer, aE as WalletProviderRdns, aF as getProviderSlugFromRdns, aG as Web3Provider, aH as connectEIP6963Provider, aI as identifyUser, aJ as ConnectEIP6963ProviderError, aK as ProvidersContextActions, aL as ViewContext, V as ViewActions, m as SharedViews, j as ChainId, aM as commonjsRequire, aN as getRemoteImage, aO as useHandover, aP as HandoverTarget, aQ as EventTargetContext, aR as getRemoteRive, aS as Trans, aT as Link, aU as useInjectedProviders, aV as getDefaultTokenImage, aW as OverflowDrawerMenu, aX as SimpleLayout, aY as TokenFilterTypes, h as getL2ChainId, aZ as isNativeToken, a_ as getTokenImageByAddress, a$ as orchestrationEvents, b0 as requireSecp256k1$1, b1 as requireLib_commonjs, b2 as require$$0$2, b3 as bech32$2, b4 as bnExports$1, b5 as require$$0$3, b6 as getAugmentedNamespace, b7 as require$$0$4, b8 as minimalisticAssert, b9 as require$$2, ba as hash$6, bb as MaxUint256, bc as merge$3, bd as SvgIcon, be as WalletWarningHero, bf as Environment, bg as t, bh as PriceDisplay, L as LoadingView, bi as viewReducer, bj as initialViewState, bk as isValidAddress, bl as amountInputValidation, bm as CloudImage, E as ErrorView, bn as ServiceUnavailableErrorView, bo as ServiceType } from './index-CluzFQyb.js';
2
+ import { f as formatUnits, p as parseUnits } from './index-D8cKqUD1.js';
3
+ import { E as EllipsizedText, C as Contract } from './EllipsizedText-CpY-fwmV.js';
4
+ import { r as retry, T as TokenImage } from './retry-DekCi5fl.js';
5
+ import { H as HandoverContent } from './HandoverContent-BENLzW4n.js';
6
+ import { F as FeesBreakdown } from './FeesBreakdown-C6qrQVEs.js';
7
7
 
8
8
  var bannerSx = {
9
9
  d: "flex",
@@ -1695,6 +1695,7 @@ function getRouteAndTokenBalances(routeData) {
1695
1695
  }
1696
1696
 
1697
1697
  function RouteOption({ routeData, onClick, chains, disabled = false, isFastest = false, size = 'small', rc = jsx("span", {}), selected = false, }) {
1698
+ const { t } = useTranslation();
1698
1699
  const { fromToken } = routeData.amountData;
1699
1700
  const { estimate } = routeData.route.route;
1700
1701
  const chain = chains?.find((c) => c.id === fromToken.chainId);
@@ -1712,7 +1713,7 @@ function RouteOption({ routeData, onClick, chains, disabled = false, isFastest =
1712
1713
  size,
1713
1714
  onClick: disabled ? undefined : handleClick,
1714
1715
  };
1715
- return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.Label, { children: fromToken.name }), chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall" }), jsx(MenuItem.FramedImage, { circularFrame: true, use: jsx("img", { src: fromToken.iconUrl, alt: fromToken.name }) })] })), jsx(MenuItem.Caption, { children: `Balance: USD ${routeBalanceUsd}` }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `USD $${fromAmountUsd}` }) }), jsxs(MenuItem.BottomSlot, { children: [jsx(MenuItem.BottomSlot.Divider, {}), jsxs(Stack, { rc: jsx("span", {}), direction: "row", justifyContent: "space-between", sx: {
1716
+ return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.Label, { children: fromToken.name }), chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall" }), jsx(MenuItem.FramedImage, { circularFrame: true, use: jsx("img", { src: fromToken.iconUrl, alt: fromToken.name }) })] })), jsx(MenuItem.Caption, { children: `Balance ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${routeBalanceUsd}` }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${fromAmountUsd}` }) }), jsxs(MenuItem.BottomSlot, { children: [jsx(MenuItem.BottomSlot.Divider, {}), jsxs(Stack, { rc: jsx("span", {}), direction: "row", justifyContent: "space-between", sx: {
1716
1717
  w: '100%',
1717
1718
  }, children: [jsxs(Body, { sx: {
1718
1719
  ...hFlex,
@@ -1722,7 +1723,7 @@ function RouteOption({ routeData, onClick, chains, disabled = false, isFastest =
1722
1723
  }, size: "xSmall", children: [jsx(Icon, { icon: "Countdown", sx: {
1723
1724
  w: 'base.icon.size.200',
1724
1725
  fill: 'base.color.text.body.secondary',
1725
- }, variant: "bold" }), estimatedDurationFormatted] }), jsxs(Body, { size: "xSmall", sx: { ...hFlex, ...centerFlexChildren }, children: [isFastest && (jsx(Badge, { badgeContent: "Fastest", variant: "emphasis", sx: { mr: 'base.spacing.x2' } })), `Fee ~ USD $${getFormattedAmounts(totalFeesUsd)}`] })] })] })] }));
1726
+ }, variant: "bold" }), estimatedDurationFormatted] }), jsxs(Body, { size: "xSmall", sx: { ...hFlex, ...centerFlexChildren }, children: [isFastest && (jsx(Badge, { badgeContent: "Fastest", variant: "emphasis", sx: { mr: 'base.spacing.x2' } })), `Fee ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${getFormattedAmounts(totalFeesUsd)}`] })] })] })] }));
1726
1727
  }
1727
1728
 
1728
1729
  const defaultFiatOptions = [
@@ -2425,6 +2426,7 @@ const BASE_SLIPPAGE = 0.02;
2425
2426
  const useRoutes = () => {
2426
2427
  const latestRequestIdRef = reactExports.useRef(0);
2427
2428
  const { addTokensDispatch } = reactExports.useContext(AddTokensContext);
2429
+ const { providersState: { toProvider, }, } = useProvidersContext();
2428
2430
  const { track } = useAnalytics();
2429
2431
  const setRoutes = (routes) => {
2430
2432
  addTokensDispatch({
@@ -2495,6 +2497,7 @@ const useRoutes = () => {
2495
2497
  toAddress,
2496
2498
  quoteOnly,
2497
2499
  enableBoost: true,
2500
+ receiveGasOnDestination: !isPassportProvider(toProvider),
2498
2501
  }), {
2499
2502
  retryIntervalMs: 1000,
2500
2503
  retries: 5,
@@ -2618,6 +2621,7 @@ function SelectedRouteOptionContainer({ children, onClick, selected, }) {
2618
2621
  }, rc: jsx("span", { ...(onClick ? { onClick } : {}) }), children: children }));
2619
2622
  }
2620
2623
  function SelectedRouteOption({ checkout, routeData, chains, loading = false, withSelectedWallet = false, withSelectedToken = false, withSelectedAmount = false, insufficientBalance = false, showOnrampOption = false, onClick, }) {
2624
+ const { t } = useTranslation();
2621
2625
  const { fromToken } = routeData?.amountData ?? {};
2622
2626
  const chain = chains?.find((c) => c.id === fromToken?.chainId);
2623
2627
  const { routeBalanceUsd, fromAmount, fromAmountUsd } = reactExports.useMemo(() => getRouteAndTokenBalances(routeData), [routeData]);
@@ -2654,7 +2658,7 @@ function SelectedRouteOption({ checkout, routeData, chains, loading = false, wit
2654
2658
  }
2655
2659
  return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [jsx(MenuItem.FramedIcon, { icon: icon, variant: "bold", circularFrame: true, emphasized: false }), jsx(MenuItem.Caption, { children: copy })] }));
2656
2660
  }
2657
- return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall", sx: { bottom: 'base.spacing.x2', right: 'base.spacing.x2' } }), jsx(MenuItem.FramedImage, { circularFrame: true, padded: true, use: jsx("img", { src: fromToken?.iconUrl, alt: fromToken?.name }) })] })), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { w: '100%' }, children: [jsxs(Stack, { gap: "0px", children: [jsx(MenuItem.Label, { children: fromToken?.name }), jsx(MenuItem.Caption, { children: `Balance USD $${routeBalanceUsd}` })] }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `USD $${fromAmountUsd}` }) })] })] }));
2661
+ return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall", sx: { bottom: 'base.spacing.x2', right: 'base.spacing.x2' } }), jsx(MenuItem.FramedImage, { circularFrame: true, padded: true, use: jsx("img", { src: fromToken?.iconUrl, alt: fromToken?.name }) })] })), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { w: '100%' }, children: [jsxs(Stack, { gap: "0px", children: [jsx(MenuItem.Label, { children: fromToken?.name }), jsx(MenuItem.Caption, { children: `Balance ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${routeBalanceUsd}` })] }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${fromAmountUsd}` }) })] })] }));
2658
2662
  }
2659
2663
 
2660
2664
  const disabledStyles = {
@@ -2871,7 +2875,7 @@ function PayWithWalletDrawer({ visible, onClose, onConnect, onPayWithCard, walle
2871
2875
  onPayWithCard?.();
2872
2876
  }, children: [jsx(MenuItem.FramedIcon, { icon: "BankCard", variant: "bold", emphasized: false }), jsx(MenuItem.Label, { children: "Pay with Card" })] }));
2873
2877
  }, [onClose, onPayWithCard]);
2874
- return (jsx(ConnectWalletDrawer, { heading: insufficientBalance ? 'Choose another option' : 'Pay With', visible: visible, onClose: onClose, providerType: "from", walletOptions: walletOptions, disabledOptions: disabledOptions, bottomSlot: payWithCardItem, onConnect: handleOnConnect, onError: handleOnError }));
2878
+ return (jsx(ConnectWalletDrawer, { heading: insufficientBalance ? 'Choose another option' : 'Send from', visible: visible, onClose: onClose, providerType: "from", walletOptions: walletOptions, disabledOptions: disabledOptions, bottomSlot: payWithCardItem, onConnect: handleOnConnect, onError: handleOnError }));
2875
2879
  }
2876
2880
 
2877
2881
  function convertToUsd(tokens, amount, token) {
@@ -5926,7 +5930,9 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
5926
5930
  const { addTokensState: { squid, chains, balances, tokens, selectedAmount, routes, selectedRouteData, selectedToken, isSwapAvailable, }, addTokensDispatch, } = reactExports.useContext(AddTokensContext);
5927
5931
  const { viewDispatch } = reactExports.useContext(ViewContext);
5928
5932
  const { track, page } = useAnalytics();
5933
+ const { t } = useTranslation();
5929
5934
  const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
5935
+ const [payWithCardClicked, setPayWithCardClicked] = reactExports.useState(false);
5930
5936
  const [showOptionsDrawer, setShowOptionsDrawer] = reactExports.useState(false);
5931
5937
  const [showPayWithDrawer, setShowPayWithDrawer] = reactExports.useState(false);
5932
5938
  const [showDeliverToDrawer, setShowDeliverToDrawer] = reactExports.useState(false);
@@ -6002,7 +6008,7 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6002
6008
  setInputValue(value);
6003
6009
  setSelectedAmount(value);
6004
6010
  };
6005
- const { providersState: { fromProviderInfo, toProviderInfo, fromAddress, toAddress, lockedToProvider, }, } = useProvidersContext();
6011
+ const { providersState: { fromProviderInfo, toProviderInfo, toProvider, fromAddress, toAddress, lockedToProvider, }, } = useProvidersContext();
6006
6012
  const { providers } = useInjectedProviders({ checkout });
6007
6013
  const walletOptions = reactExports.useMemo(() => providers
6008
6014
  // TODO: Check if must filter passport on L1
@@ -6086,9 +6092,9 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6086
6092
  });
6087
6093
  setAllowedTokens(updatedTokens);
6088
6094
  if (toTokenAddress) {
6089
- const token = tokenResponse.tokens.find((t) => t.address?.toLowerCase() === toTokenAddress.toLowerCase());
6090
- if (token) {
6091
- setSelectedToken(token);
6095
+ const preselectedToken = updatedTokens.find((token) => token.address?.toLowerCase() === toTokenAddress.toLowerCase());
6096
+ if (preselectedToken) {
6097
+ setSelectedToken(preselectedToken);
6092
6098
  }
6093
6099
  }
6094
6100
  addTokensDispatch({
@@ -6128,7 +6134,7 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6128
6134
  const handleTokenChange = reactExports.useCallback((token) => {
6129
6135
  setSelectedToken(token);
6130
6136
  }, []);
6131
- const handleCardClick = () => {
6137
+ const sendRequestOnRampEvent = () => {
6132
6138
  track({
6133
6139
  userJourney: UserJourney.ADD_TOKENS,
6134
6140
  screen: 'InputScreen',
@@ -6143,15 +6149,35 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6143
6149
  tokenAddress: selectedToken?.address ?? '',
6144
6150
  amount: selectedAmount ?? '',
6145
6151
  showBackButton: true,
6152
+ provider: toProvider,
6146
6153
  };
6147
6154
  orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, data);
6148
6155
  };
6156
+ const handleCardClick = () => {
6157
+ setPayWithCardClicked(true);
6158
+ if (!toProvider) {
6159
+ setShowDeliverToDrawer(true);
6160
+ return;
6161
+ }
6162
+ sendRequestOnRampEvent();
6163
+ };
6164
+ reactExports.useEffect(() => {
6165
+ if (toProvider && payWithCardClicked) {
6166
+ sendRequestOnRampEvent();
6167
+ }
6168
+ }, [toProvider]);
6149
6169
  const handleRouteClick = (route) => {
6150
6170
  setShowOptionsDrawer(false);
6151
6171
  setShowPayWithDrawer(false);
6152
6172
  setShowDeliverToDrawer(false);
6153
6173
  setSelectedRouteData(route);
6154
6174
  };
6175
+ const handleDeliverToClose = (connectedToAddress) => {
6176
+ if (!connectedToAddress) {
6177
+ setPayWithCardClicked(false);
6178
+ }
6179
+ setShowDeliverToDrawer(false);
6180
+ };
6155
6181
  const handleReviewClick = () => {
6156
6182
  if (!selectedRouteData || !selectedToken?.address)
6157
6183
  return;
@@ -6187,8 +6213,8 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6187
6213
  };
6188
6214
  const shouldShowOnRampOption = reactExports.useMemo(() => {
6189
6215
  if (showOnrampOption && selectedToken) {
6190
- const token = onRampAllowedTokens.find((t) => t.address?.toLowerCase() === selectedToken.address?.toLowerCase());
6191
- return !!token;
6216
+ const isAllowedToken = onRampAllowedTokens.find((token) => token.address?.toLowerCase() === selectedToken.address?.toLowerCase());
6217
+ return !!isAllowedToken;
6192
6218
  }
6193
6219
  return false;
6194
6220
  }, [selectedToken, onRampAllowedTokens, showOnrampOption]);
@@ -6240,14 +6266,15 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6240
6266
  boxShadow: ({ base }) => `0 0 0 ${base.border.size[200]} ${base.color.text.body.primary}`,
6241
6267
  },
6242
6268
  } })),
6243
- }), children: tokenChoiceOptions }), showInitialEmptyState ? (jsx(Body, { children: "Add Token" })) : (jsxs(HeroFormControl, { validationStatus: inputValue === '0' ? 'error' : 'success', children: [jsxs(HeroFormControl.Label, { children: ["Add", ' ', selectedToken.symbol] }), jsx(HeroTextInput, { testId: "add-tokens-amount-input", type: "number", value: inputValue, onChange: (value) => handleOnAmountInputChange(value), placeholder: "0", maxTextSize: "xLarge" }), jsxs(HeroFormControl.Caption, { children: ["USD $", getFormattedNumberWithDecimalPlaces(selectedAmountUsd)] })] }))] }), jsxs(Stack, { testId: "bottomSection", sx: {
6269
+ }), children: tokenChoiceOptions }), showInitialEmptyState ? (jsx(Body, { children: "Add Token" })) : (jsxs(HeroFormControl, { validationStatus: inputValue === '0' ? 'error' : 'success', children: [jsxs(HeroFormControl.Label, { children: ["Add", ' ', selectedToken.symbol] }), jsx(HeroTextInput, { testId: "add-tokens-amount-input", type: "number", value: inputValue, onChange: (value) => handleOnAmountInputChange(value), placeholder: "0", maxTextSize: "xLarge" }), jsx(HeroFormControl.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}
6270
+ $${getFormattedNumberWithDecimalPlaces(selectedAmountUsd)}` })] }))] }), jsxs(Stack, { testId: "bottomSection", sx: {
6244
6271
  alignSelf: 'stretch',
6245
6272
  p: 'base.spacing.x3',
6246
6273
  pb: 'base.spacing.x5',
6247
6274
  bg: 'base.color.neutral.800',
6248
6275
  bradtl: 'base.borderRadius.x8',
6249
6276
  bradtr: 'base.borderRadius.x8',
6250
- }, gap: "base.spacing.x4", children: [jsxs(Stack, { gap: "0px", children: [jsxs(SelectedWallet, { label: "Pay with", providerInfo: {
6277
+ }, gap: "base.spacing.x4", children: [jsxs(Stack, { gap: "0px", children: [jsxs(SelectedWallet, { label: "Send from", providerInfo: {
6251
6278
  ...fromProviderInfo,
6252
6279
  address: fromAddress,
6253
6280
  }, onClick: (event) => {
@@ -6261,7 +6288,7 @@ function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOptio
6261
6288
  } }) }), jsx(SelectedWallet, { label: "Deliver to", providerInfo: {
6262
6289
  ...toProviderInfo,
6263
6290
  address: toAddress,
6264
- }, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx(Button, { testId: "add-tokens-button", size: "large", variant: readyToReview ? 'primary' : 'secondary', disabled: !readyToReview, onClick: handleReviewClick, sx: { opacity: readyToReview ? 1 : 0.5 }, children: "Review" }), jsx(SquidFooter, {}), jsx(PayWithWalletDrawer, { visible: showPayWithDrawer, walletOptions: walletOptions, onClose: () => setShowPayWithDrawer(false), onPayWithCard: handleCardClick, onConnect: handleWalletConnected, insufficientBalance: insufficientBalance, showOnRampOption: shouldShowOnRampOption }), jsx(OptionsDrawer, { checkout: checkout, routes: routes, showOnrampOption: shouldShowOnRampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, visible: showOptionsDrawer, onClose: () => setShowOptionsDrawer(false), onCardClick: handleCardClick, onRouteClick: handleRouteClick, insufficientBalance: insufficientBalance }), jsx(DeliverToWalletDrawer, { visible: showDeliverToDrawer, walletOptions: walletOptions, onClose: () => setShowDeliverToDrawer(false) }), jsx(OnboardingDrawer, { environment: checkout?.config.environment })] })] }) }));
6291
+ }, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx(Button, { testId: "add-tokens-button", size: "large", variant: readyToReview ? 'primary' : 'secondary', disabled: !readyToReview, onClick: handleReviewClick, sx: { opacity: readyToReview ? 1 : 0.5 }, children: "Review" }), jsx(SquidFooter, {}), jsx(PayWithWalletDrawer, { visible: showPayWithDrawer, walletOptions: walletOptions, onClose: () => setShowPayWithDrawer(false), onPayWithCard: handleCardClick, onConnect: handleWalletConnected, insufficientBalance: insufficientBalance, showOnRampOption: shouldShowOnRampOption }), jsx(OptionsDrawer, { checkout: checkout, routes: routes, showOnrampOption: shouldShowOnRampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, visible: showOptionsDrawer, onClose: () => setShowOptionsDrawer(false), onCardClick: handleCardClick, onRouteClick: handleRouteClick, insufficientBalance: insufficientBalance }), jsx(DeliverToWalletDrawer, { visible: showDeliverToDrawer, walletOptions: walletOptions, onClose: handleDeliverToClose }), jsx(OnboardingDrawer, { environment: checkout?.config.environment })] })] }) }));
6265
6292
  }
6266
6293
 
6267
6294
  var dist$2 = {};
@@ -173493,10 +173520,11 @@ function SquidIcon({ sx = {}, className, }) {
173493
173520
  }
173494
173521
 
173495
173522
  function RouteFees({ visible, onClose, routeData, totalAmount, totalFiatAmount, }) {
173523
+ const { t } = useTranslation();
173496
173524
  const feeCosts = reactExports.useMemo(() => routeData?.route.estimate.feeCosts.map((fee) => ({
173497
173525
  label: fee.name,
173498
173526
  amount: getFormattedNumber(fee.amount, fee.token.decimals),
173499
- fiatAmount: `USD ≈ ${getFormattedAmounts(fee.amountUsd)}`,
173527
+ fiatAmount: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}${getFormattedAmounts(fee.amountUsd)}`,
173500
173528
  token: {
173501
173529
  name: fee.token.name,
173502
173530
  symbol: fee.token.symbol,
@@ -173509,7 +173537,7 @@ function RouteFees({ visible, onClose, routeData, totalAmount, totalFiatAmount,
173509
173537
  const gasCosts = reactExports.useMemo(() => routeData?.route.estimate.gasCosts.map((fee) => ({
173510
173538
  label: 'Gas (transaction)',
173511
173539
  amount: getFormattedNumber(fee.amount, fee.token.decimals),
173512
- fiatAmount: `USD ≈ ${getFormattedAmounts(fee.amountUsd)}`,
173540
+ fiatAmount: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}${getFormattedAmounts(fee.amountUsd)}`,
173513
173541
  token: {
173514
173542
  name: fee.token.name,
173515
173543
  symbol: fee.token.symbol,
@@ -173628,7 +173656,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173628
173656
  alignItems: 'center',
173629
173657
  c: 'base.color.text.body.secondary',
173630
173658
  cursor: 'pointer',
173631
- }, children: ["Included fees", ` USD $${getFormattedAmounts(totalFeesUsd)}`, jsx(Icon, { icon: "ChevronExpand", sx: { ml: 'base.spacing.x2', w: 'base.icon.size.200' } })] }));
173659
+ }, children: ["Included fees", ` ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${getFormattedAmounts(totalFeesUsd)}`, jsx(Icon, { icon: "ChevronExpand", sx: { ml: 'base.spacing.x2', w: 'base.icon.size.200' } })] }));
173632
173660
  }
173633
173661
  return (jsx(Body, { size: "small", sx: {
173634
173662
  ...hFlex,
@@ -173708,7 +173736,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173708
173736
  const formattedDuration = route
173709
173737
  ? getDurationFormatted(route.route.estimate.estimatedRouteDuration)
173710
173738
  : '';
173711
- return (jsxs(SimpleLayout, { header: (jsxs(Stack, { rc: jsx("header", {}), direction: "row", sx: {
173739
+ return (jsxs(SimpleLayout, { containerSx: { bg: 'transparent' }, header: (jsxs(Stack, { rc: jsx("header", {}), direction: "row", sx: {
173712
173740
  pt: 'base.spacing.x4',
173713
173741
  px: 'base.spacing.x5',
173714
173742
  h: 'base.spacing.x18',
@@ -173725,7 +173753,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173725
173753
  fontSize: 'inherit',
173726
173754
  lineHeight: 'inherit',
173727
173755
  c: 'inherit',
173728
- } })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route.route.estimate.fromAmount, route.route.estimate.fromToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `USD $${route?.route.estimate.fromAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
173756
+ } })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route.route.estimate.fromAmount, route.route.estimate.fromToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${route?.route.estimate.fromAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
173729
173757
  pos: 'relative',
173730
173758
  w: 'base.spacing.x16',
173731
173759
  ml: 'base.spacing.x7',
@@ -173745,7 +173773,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173745
173773
  top: '-26px',
173746
173774
  h: 'base.spacing.x10',
173747
173775
  },
173748
- } }), jsxs(Stack, { direction: "row", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, gap: "base.spacing.x6", alignItems: "center", children: [jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(FramedImage, { use: (jsx("img", { src: toChain?.nativeCurrency.iconUrl, alt: toChain?.nativeCurrency.name })), circularFrame: true, size: "large" }), jsx(Sticker.FramedImage, { use: jsx("img", { src: toChain?.iconUrl, alt: toChain?.name }), emphasized: true, sx: {
173776
+ } }), jsxs(Stack, { direction: "row", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, gap: "base.spacing.x6", alignItems: "center", children: [jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(FramedImage, { use: (jsx("img", { src: route.route.estimate.toToken.logoURI, alt: route.route.estimate.toToken.name })), circularFrame: true, size: "large" }), jsx(Sticker.FramedImage, { use: jsx("img", { src: toChain?.iconUrl, alt: toChain?.name }), emphasized: true, sx: {
173749
173777
  bottom: 'base.spacing.x2',
173750
173778
  right: 'base.spacing.x2',
173751
173779
  } })] }), jsxs(Stack, { sx: { flex: 1 }, gap: "0px", children: [jsxs(Body, { weight: "bold", children: ["Receive", ' ', route?.route.estimate.toToken.name] }), jsxs(Body, { size: "small", sx: { c: 'base.color.text.body.secondary' }, children: [toChain?.name, jsx(EllipsizedText, { text: toAddress ?? '', sx: {
@@ -173753,7 +173781,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173753
173781
  fontSize: 'inherit',
173754
173782
  lineHeight: 'inherit',
173755
173783
  c: 'inherit',
173756
- } })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route?.route.estimate.toAmount, route?.route.estimate.toToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `USD $${route?.route.estimate.toAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
173784
+ } })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route?.route.estimate.toAmount, route?.route.estimate.toToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${route?.route.estimate.toAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
173757
173785
  pos: 'relative',
173758
173786
  w: 'base.spacing.x16',
173759
173787
  ml: 'base.spacing.x7',
@@ -173763,7 +173791,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
173763
173791
  top: '-8px',
173764
173792
  h: 'base.spacing.x5',
173765
173793
  },
173766
- } }), jsxs(Stack, { direction: "row", gap: "base.spacing.x6", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, alignItems: "center", children: [jsx(Stack, { direction: "row", sx: { w: 'base.spacing.x12' }, justifyContent: "center", children: jsx(FramedIcon, { icon: "Countdown", variant: "bold", size: "medium", circularFrame: true }) }), jsx(Body, { size: "small", sx: { flex: 1, c: 'base.color.text.body.secondary' }, children: formattedDuration }), routeFees] })] }), jsx(Button, { size: "large", onClick: handleTransaction, disabled: proceedDisabled, sx: { mx: 'base.spacing.x3' }, children: proceedDisabled ? 'Processing' : 'Proceed' }), jsx(SquidFooter, {})] })), !route && !showAddressMissmatchDrawer && jsx(LoadingView, { loadingText: "Securing quote" })] }), jsx(RouteFees, { routeData: route, visible: showFeeBreakdown, onClose: () => setShowFeeBreakdown(false), totalAmount: totalFees, totalFiatAmount: totalFeesUsd }), jsx(AddressMissmatchDrawer, { visible: showAddressMissmatchDrawer, onClick: () => {
173794
+ } }), jsxs(Stack, { direction: "row", gap: "base.spacing.x6", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, alignItems: "center", children: [jsx(Stack, { direction: "row", sx: { w: 'base.spacing.x12' }, justifyContent: "center", children: jsx(FramedIcon, { icon: "Countdown", variant: "bold", size: "medium", circularFrame: true }) }), jsx(Body, { size: "small", sx: { flex: 1, c: 'base.color.text.body.secondary' }, children: formattedDuration }), routeFees] })] }), jsx(Button, { size: "large", onClick: handleTransaction, disabled: proceedDisabled, sx: { mx: 'base.spacing.x3' }, children: proceedDisabled ? 'Processing' : 'Proceed' }), jsx(SquidFooter, {})] })), !route && !showAddressMissmatchDrawer && (jsx(LoadingView, { loadingText: "Securing quote", containerSx: { bg: 'transparent' } }))] }), jsx(RouteFees, { routeData: route, visible: showFeeBreakdown, onClose: () => setShowFeeBreakdown(false), totalAmount: totalFees, totalFiatAmount: totalFeesUsd }), jsx(AddressMissmatchDrawer, { visible: showAddressMissmatchDrawer, onClick: () => {
173767
173795
  setShowAddressMissmatchDrawer(false);
173768
173796
  viewDispatch({
173769
173797
  payload: {
@@ -1,11 +1,12 @@
1
- import { c1 as axios, c2 as CheckoutErrorType, c3 as IMMUTABLE_API_BASE_URL, r as reactExports, I as IMTBLWidgetEvents, B as BridgeEventType, q as jsxs, j as jsx, c4 as ShimmerBox, al as MenuItem, a8 as Stack, l as useTranslation, M as Body, T as Button, H as Box, c5 as PASSPORT_URL, aT as Link, c6 as getChainIdBySlug, c7 as getChainImage, c8 as networkName, a6 as FramedImage, Q as Icon, ay as useAnalytics, az as UserJourney, at as Divider, aL as ViewContext, au as Fragment, V as ViewActions, c9 as useWalletConnect, ca as isWalletConnectProvider, cb as Logo, cc as RawImage, cd as AXELAR_SCAN_URL, aZ as isNativeToken, a_ as getTokenImageByAddress, ce as getNativeSymbolByChainSlug, by as calculateCryptoToFiat, aQ as EventTargetContext, bI as isPassportProvider, i as getL1ChainId, aY as TokenFilterTypes, h as getL2ChainId, aE as WalletProviderRdns, aG as Web3Provider, aU as useInjectedProviders, bF as HeaderNavigation, bJ as FooterLogo, aB as WalletDrawer, aX as SimpleLayout, cf as getChainSlugById, cg as JsonRpcProvider, ch as DEFAULT_TRANSACTIONS_RETRY_POLICY, L as LoadingView, k as ChainId, ci as getChainNameById, x as useTheme, aA as Heading, cj as getWalletProviderNameByProvider, ck as isAddressSanctioned, o as SharedViews, cl as isMetaMaskProvider, cm as WalletProviderName, ax as Drawer, R as ButtCon, cn as ButtonNavigationStyles, a$ as orchestrationEvents, am as tokenValueFormat, co as formatZeroAmount, cp as NATIVE, bl as amountInputValidation, aN as getRemoteImage, bm as CloudImage, cq as ETH_TOKEN_SYMBOL, ao as BigNumber, bf as Environment, cr as GasEstimateType, cs as DEFAULT_TOKEN_DECIMALS, ct as DEFAULT_QUOTE_REFRESH_INTERVAL, cu as addChainChangedListener, cv as removeChainChangedListener, cw as IMX_TOKEN_SYMBOL, cx as dist, cy as CHECKOUT_CDN_BASE_URL, cz as heroBackGroundStyles, cA as heroImageStyles, a4 as Badge, cB as SimpleTextBody, cC as FooterButton, cD as getEthTokenImage, cE as WITHDRAWAL_CLAIM_GAS_LIMIT, aV as getDefaultTokenImage, bi as viewReducer, bj as initialViewState, cF as BridgeConfiguration, cG as ImmutableConfiguration, cH as TokenBridge, cI as StatusView, bK as StatusType, E as ErrorView, bn as ServiceUnavailableErrorView, bo as ServiceType, cJ as ETH_SEPOLIA_TO_ZKEVM_TESTNET, cK as ETH_SEPOLIA_TO_ZKEVM_DEVNET, cL as ETH_MAINNET_TO_ZKEVM_MAINNET } from './index-Co93fBqn.js';
2
- import { B as BridgeWidgetViews, C as CryptoFiatContext, a as CryptoFiatActions, T as TopUpView, c as CryptoFiatProvider } from './TopUpView-Nbu5J6zy.js';
3
- import { T as TokenImage, r as retry } from './retry-DqIpQ6wO.js';
4
- import { E as EllipsizedText, C as Contract } from './EllipsizedText-_yDoxF8V.js';
5
- import { A as Accordion, S as SelectForm, T as TextInputForm, a as TransactionRejected, g as getAllowedBalances, F as Fees, N as NetworkSwitchDrawer, W as WalletApproveHero } from './WalletApproveHero-Cc6p3CkR.js';
6
- import { f as formatUnits, p as parseUnits } from './index-DzrC5Kuy.js';
7
- import { u as useInterval } from './useInterval-D42dwhRA.js';
8
- import './FeesBreakdown-CQVi4M-W.js';
1
+ import { c0 as axios, c1 as CheckoutErrorType, c2 as IMMUTABLE_API_BASE_URL, r as reactExports, I as IMTBLWidgetEvents, B as BridgeEventType, p as jsxs, o as jsx, c3 as ShimmerBox, ak as MenuItem, a7 as Stack, u as useTranslation, K as Body, R as Button, G as Box, c4 as PASSPORT_URL, aT as Link, c5 as getChainIdBySlug, c6 as getChainImage, c7 as networkName, a5 as FramedImage, N as Icon, ax as useAnalytics, ay as UserJourney, as as Divider, aL as ViewContext, at as Fragment, V as ViewActions, c8 as useWalletConnect, c9 as isWalletConnectProvider, ca as Logo, cb as RawImage, cc as AXELAR_SCAN_URL, aZ as isNativeToken, a_ as getTokenImageByAddress, cd as getNativeSymbolByChainSlug, by as calculateCryptoToFiat, aQ as EventTargetContext, az as isPassportProvider, i as getL1ChainId, aY as TokenFilterTypes, h as getL2ChainId, aE as WalletProviderRdns, aG as Web3Provider, aU as useInjectedProviders, bF as HeaderNavigation, bI as FooterLogo, aB as WalletDrawer, aX as SimpleLayout, ce as getChainSlugById, cf as JsonRpcProvider, cg as DEFAULT_TRANSACTIONS_RETRY_POLICY, L as LoadingView, j as ChainId, ch as getChainNameById, w as useTheme, aA as Heading, ci as getWalletProviderNameByProvider, cj as isAddressSanctioned, m as SharedViews, ck as isMetaMaskProvider, cl as WalletProviderName, aw as Drawer, Q as ButtCon, cm as ButtonNavigationStyles, a$ as orchestrationEvents, al as tokenValueFormat, cn as formatZeroAmount, co as NATIVE, bl as amountInputValidation, aN as getRemoteImage, bm as CloudImage, cp as ETH_TOKEN_SYMBOL, an as BigNumber, bf as Environment, cq as GasEstimateType, cr as DEFAULT_TOKEN_DECIMALS, cs as DEFAULT_QUOTE_REFRESH_INTERVAL, ct as addChainChangedListener, cu as removeChainChangedListener, cv as IMX_TOKEN_SYMBOL, cw as dist, cx as CHECKOUT_CDN_BASE_URL, cy as heroBackGroundStyles, cz as heroImageStyles, a3 as Badge, cA as SimpleTextBody, cB as FooterButton, cC as getEthTokenImage, cD as WITHDRAWAL_CLAIM_GAS_LIMIT, aV as getDefaultTokenImage, bi as viewReducer, bj as initialViewState, cE as BridgeConfiguration, cF as ImmutableConfiguration, cG as TokenBridge, cH as StatusView, bJ as StatusType, E as ErrorView, bn as ServiceUnavailableErrorView, bo as ServiceType, cI as ETH_SEPOLIA_TO_ZKEVM_TESTNET, cJ as ETH_SEPOLIA_TO_ZKEVM_DEVNET, cK as ETH_MAINNET_TO_ZKEVM_MAINNET } from './index-CluzFQyb.js';
2
+ import { C as CryptoFiatContext, a as CryptoFiatActions, b as CryptoFiatProvider } from './CryptoFiatProvider-3fUUkERi.js';
3
+ import { T as TokenImage, r as retry } from './retry-DekCi5fl.js';
4
+ import { E as EllipsizedText, C as Contract } from './EllipsizedText-CpY-fwmV.js';
5
+ import { A as Accordion, S as SelectForm, T as TextInputForm, a as TransactionRejected, g as getAllowedBalances, F as Fees, N as NetworkSwitchDrawer, W as WalletApproveHero } from './WalletApproveHero-B5TXSbim.js';
6
+ import { B as BridgeWidgetViews, T as TopUpView } from './TopUpView-3d5yxKuq.js';
7
+ import { f as formatUnits, p as parseUnits } from './index-D8cKqUD1.js';
8
+ import { u as useInterval } from './useInterval-BstnDnYa.js';
9
+ import './FeesBreakdown-C6qrQVEs.js';
9
10
 
10
11
  // This module is intended to unwrap Axios default export as named.
11
12
  // Keep top-level export same with static properties
@@ -1,72 +1,20 @@
1
- import { r as reactExports, u as useConnectLoaderState, j as jsx, I as IMTBLWidgetEvents, C as CommerceFlowType, P as ProviderEventType, a as CommerceEventType, b as ConnectEventType, c as CommerceFailureEventType, d as CommerceSuccessEventType, W as WalletEventType, e as CommerceUserActionEventType, S as SwapEventType, B as BridgeEventType, O as OnRampEventType, f as SaleEventType, g as OrchestrationEventType, V as ViewActions, h as getL2ChainId, i as getL1ChainId, k as ChainId, l as useTranslation, m as useViewState, n as useEventTargetState, o as SharedViews, p as commerceFlows, q as jsxs, L as LoadingView, E as ErrorView, s as ConnectWidget, t as ProvidersContextProvider, v as ConnectLoader, w as ViewContextProvider } from './index-Co93fBqn.js';
2
- import SwapWidget from './SwapWidget-Dm2cQUYh.js';
3
- import BridgeWidget from './BridgeWidget-DreWq2OO.js';
4
- import { O as OnRampWidget } from './OnRampWidget-BpRLbHli.js';
5
- import WalletWidget from './WalletWidget-C25SCVnz.js';
6
- import SaleWidget from './SaleWidget-C-ATgwRu.js';
7
- import AddTokensWidget from './AddTokensWidget-BfDY0LwB.js';
8
- import './WalletApproveHero-Cc6p3CkR.js';
9
- import './retry-DqIpQ6wO.js';
10
- import './FeesBreakdown-CQVi4M-W.js';
11
- import './TopUpView-Nbu5J6zy.js';
12
- import './index-DzrC5Kuy.js';
13
- import './useInterval-D42dwhRA.js';
14
- import './SpendingCapHero-DLdYNa0u.js';
15
- import './EllipsizedText-_yDoxF8V.js';
16
- import './HandoverContent-D0HXf455.js';
17
-
18
- const initialCommerceState = {
19
- checkout: undefined,
20
- provider: undefined,
21
- passport: undefined,
22
- };
23
- var CommerceActions;
24
- (function (CommerceActions) {
25
- CommerceActions["SET_CHECKOUT"] = "SET_CHECKOUT";
26
- CommerceActions["SET_PROVIDER"] = "SET_PROVIDER";
27
- CommerceActions["SET_PASSPORT"] = "SET_PASSPORT";
28
- })(CommerceActions || (CommerceActions = {}));
29
- // eslint-disable-next-line @typescript-eslint/naming-convention
30
- const CommerceContext = reactExports.createContext({
31
- commerceState: initialCommerceState,
32
- commerceDispatch: () => { },
33
- });
34
- CommerceContext.displayName = 'CommerceContext'; // help with debugging Context in browser
35
- const commerceReducer = (state, action) => {
36
- switch (action.payload.type) {
37
- case CommerceActions.SET_CHECKOUT:
38
- return {
39
- ...state,
40
- checkout: action.payload.checkout,
41
- };
42
- case CommerceActions.SET_PROVIDER:
43
- return {
44
- ...state,
45
- provider: action.payload.provider,
46
- };
47
- case CommerceActions.SET_PASSPORT:
48
- return {
49
- ...state,
50
- passport: action.payload.passport,
51
- };
52
- default:
53
- return state;
54
- }
55
- };
56
-
57
- const useCommerceWidgetState = () => {
58
- const [viewState, viewDispatch] = reactExports.useReducer(commerceReducer, initialCommerceState);
59
- return [viewState, viewDispatch];
60
- };
61
- function CommerceWidgetContextProvicer({ children, }) {
62
- const [{ checkout, provider }] = useConnectLoaderState();
63
- const [commerceState, commerceDispatch] = useCommerceWidgetState();
64
- const values = reactExports.useMemo(() => ({
65
- commerceState: { ...commerceState, checkout, provider },
66
- commerceDispatch,
67
- }), [commerceState, commerceDispatch, checkout, provider]);
68
- return (jsx(CommerceContext.Provider, { value: values, children: children }));
69
- }
1
+ import { I as IMTBLWidgetEvents, C as CommerceFlowType, P as ProviderEventType, a as CommerceEventType, b as ConnectEventType, c as CommerceFailureEventType, d as CommerceSuccessEventType, W as WalletEventType, e as CommerceUserActionEventType, S as SwapEventType, B as BridgeEventType, O as OnRampEventType, f as SaleEventType, g as OrchestrationEventType, r as reactExports, V as ViewActions, h as getL2ChainId, i as getL1ChainId, j as ChainId, u as useTranslation, k as useViewState, l as useEventTargetState, m as SharedViews, n as commerceFlows, o as jsx, p as jsxs, L as LoadingView, E as ErrorView, q as ConnectWidget, s as ProvidersContextProvider, t as ConnectLoader, v as ViewContextProvider } from './index-CluzFQyb.js';
2
+ import SwapWidget from './SwapWidget-DSQPb69U.js';
3
+ import BridgeWidget from './BridgeWidget-Cyu5i2LL.js';
4
+ import { O as OnRampWidget } from './OnRampWidget-JkxC8nMN.js';
5
+ import WalletWidget from './WalletWidget-C-_77Eb9.js';
6
+ import SaleWidget from './SaleWidget-aIL3dbMH.js';
7
+ import AddTokensWidget from './AddTokensWidget-BQw-P60S.js';
8
+ import './WalletApproveHero-B5TXSbim.js';
9
+ import './retry-DekCi5fl.js';
10
+ import './FeesBreakdown-C6qrQVEs.js';
11
+ import './CryptoFiatProvider-3fUUkERi.js';
12
+ import './useInterval-BstnDnYa.js';
13
+ import './index-D8cKqUD1.js';
14
+ import './TopUpView-3d5yxKuq.js';
15
+ import './SpendingCapHero-C_loMgYA.js';
16
+ import './EllipsizedText-CpY-fwmV.js';
17
+ import './HandoverContent-BENLzW4n.js';
70
18
 
71
19
  const sendCheckoutEvent = (eventTarget, detail) => {
72
20
  const event = new CustomEvent(IMTBLWidgetEvents.IMTBL_COMMERCE_WIDGET_EVENT, { detail });
@@ -424,7 +372,7 @@ const widgetEvents = [
424
372
  /**
425
373
  * Subscribe and Handle widget events
426
374
  */
427
- function useWidgetEvents(eventTarget, viewState) {
375
+ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
428
376
  const [{ history }, viewDispatch] = viewState;
429
377
  /**
430
378
  * Change view as per orchestration event requests
@@ -440,6 +388,12 @@ function useWidgetEvents(eventTarget, viewState) {
440
388
  });
441
389
  return;
442
390
  }
391
+ if (type === OrchestrationEventType.REQUEST_ONRAMP) {
392
+ const onRampEvent = data;
393
+ if (onRampEvent.provider) {
394
+ handleProviderUpdated(onRampEvent.provider);
395
+ }
396
+ }
443
397
  const flow = getViewFromOrchestrationEventType(type);
444
398
  if (!flow)
445
399
  return;
@@ -526,13 +480,56 @@ function getConnectLoaderParams(view, checkout, web3Provider) {
526
480
  }
527
481
  }
528
482
 
483
+ const initialCommerceState = {
484
+ checkout: undefined,
485
+ provider: undefined,
486
+ passport: undefined,
487
+ };
488
+ var CommerceActions;
489
+ (function (CommerceActions) {
490
+ CommerceActions["SET_CHECKOUT"] = "SET_CHECKOUT";
491
+ CommerceActions["SET_PROVIDER"] = "SET_PROVIDER";
492
+ CommerceActions["SET_PASSPORT"] = "SET_PASSPORT";
493
+ })(CommerceActions || (CommerceActions = {}));
494
+ // eslint-disable-next-line @typescript-eslint/naming-convention
495
+ const CommerceContext = reactExports.createContext({
496
+ commerceState: initialCommerceState,
497
+ commerceDispatch: () => { },
498
+ });
499
+ CommerceContext.displayName = 'CommerceContext'; // help with debugging Context in browser
500
+ const commerceReducer = (state, action) => {
501
+ switch (action.payload.type) {
502
+ case CommerceActions.SET_CHECKOUT:
503
+ return {
504
+ ...state,
505
+ checkout: action.payload.checkout,
506
+ };
507
+ case CommerceActions.SET_PROVIDER:
508
+ return {
509
+ ...state,
510
+ provider: action.payload.provider,
511
+ };
512
+ case CommerceActions.SET_PASSPORT:
513
+ return {
514
+ ...state,
515
+ passport: action.payload.passport,
516
+ };
517
+ default:
518
+ return state;
519
+ }
520
+ };
521
+
529
522
  function CommerceWidget(props) {
530
523
  const { flowParams, flowConfig, widgetsConfig, checkout, web3Provider, } = props;
531
524
  const { t } = useTranslation();
532
525
  const viewState = useViewState();
533
526
  const [{ view, history }, viewDispatch] = viewState;
534
527
  const [{ eventTarget }] = useEventTargetState();
535
- const connectLoaderParams = reactExports.useMemo(() => getConnectLoaderParams(view, checkout, web3Provider), [view, checkout, web3Provider]);
528
+ const [commerceState, commerceDispatch] = reactExports.useReducer(commerceReducer, initialCommerceState);
529
+ const commerceReducerValues = reactExports.useMemo(() => ({ commerceState, commerceDispatch }), [commerceState, commerceDispatch]);
530
+ const { provider } = commerceState;
531
+ const connectLoaderParams = reactExports.useMemo(() => getConnectLoaderParams(view, checkout, provider || web3Provider), [view, checkout, provider, web3Provider]);
532
+ const connectLoaderSuccessEvent = flowParams.flow === CommerceFlowType.ADD_TOKENS ? () => { } : undefined;
536
533
  const goToPreviousView = reactExports.useCallback(() => {
537
534
  const sharedViews = [
538
535
  SharedViews.LOADING_VIEW,
@@ -554,10 +551,29 @@ function CommerceWidget(props) {
554
551
  });
555
552
  }
556
553
  }, [history]);
554
+ const handleProviderUpdated = reactExports.useMemo(() => (updatedProvider) => {
555
+ commerceDispatch({
556
+ payload: {
557
+ type: CommerceActions.SET_PROVIDER,
558
+ provider: updatedProvider,
559
+ },
560
+ });
561
+ }, [commerceDispatch]);
557
562
  /**
558
563
  * Subscribe and Handle widget events
559
564
  */
560
- useWidgetEvents(eventTarget, viewState);
565
+ useWidgetEvents(eventTarget, viewState, handleProviderUpdated);
566
+ reactExports.useEffect(() => {
567
+ if (!web3Provider) {
568
+ return;
569
+ }
570
+ commerceDispatch({
571
+ payload: {
572
+ type: CommerceActions.SET_PROVIDER,
573
+ provider: web3Provider,
574
+ },
575
+ });
576
+ }, [commerceDispatch, web3Provider]);
561
577
  /**
562
578
  * Mount the view according to set flow in params
563
579
  */
@@ -609,7 +625,7 @@ function CommerceWidget(props) {
609
625
  * Show back button
610
626
  */
611
627
  const showBackButton = !!view.data?.showBackButton;
612
- return (jsx(ViewContextProvider, { children: jsxs(CommerceWidgetContextProvicer, { children: [view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { onCloseClick: () => {
628
+ return (jsx(ViewContextProvider, { children: jsxs(CommerceContext.Provider, { value: commerceReducerValues, children: [view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { onCloseClick: () => {
613
629
  sendCheckoutEvent(eventTarget, {
614
630
  type: CommerceEventType.CLOSE,
615
631
  data: {},
@@ -621,7 +637,7 @@ function CommerceWidget(props) {
621
637
  type: CommerceEventType.CLOSE,
622
638
  data: {},
623
639
  });
624
- }, ...(view.data.params || {}) })), view.type === CommerceFlowType.BRIDGE && (jsx(BridgeWidget, { config: widgetsConfig, checkout: checkout, web3Provider: web3Provider, showBackButton: showBackButton, ...(view.data.params || {}) })), shouldWrapWithProvidersContext && (jsx(ProvidersContextProvider, { initialState: { checkout }, children: view.type === CommerceFlowType.ADD_TOKENS && (jsx(AddTokensWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })) })), shouldWrapWithConnectLoader && (jsx(ConnectLoader, { widgetConfig: widgetsConfig, params: connectLoaderParams, closeEvent: () => {
640
+ }, ...(view.data.params || {}) })), view.type === CommerceFlowType.BRIDGE && (jsx(BridgeWidget, { config: widgetsConfig, checkout: checkout, web3Provider: web3Provider, showBackButton: showBackButton, ...(view.data.params || {}) })), shouldWrapWithProvidersContext && (jsx(ProvidersContextProvider, { initialState: { checkout }, children: view.type === CommerceFlowType.ADD_TOKENS && (jsx(AddTokensWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })) })), shouldWrapWithConnectLoader && (jsx(ConnectLoader, { widgetConfig: widgetsConfig, params: connectLoaderParams, successEvent: connectLoaderSuccessEvent, closeEvent: () => {
625
641
  sendCheckoutEvent(eventTarget, {
626
642
  type: CommerceEventType.CLOSE,
627
643
  data: {},