@imtbl/sdk 1.62.0 → 1.63.0-alpha.10

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-sxvR7yJA.js → blockchain_data-CAvjIRIV.js} +2 -2
  2. package/dist/blockchain_data.js +3 -3
  3. package/dist/browser/checkout/{AddFundsWidget-ZVSgslAw.js → AddTokensWidget-_RYa4euh.js} +190 -183
  4. package/dist/browser/checkout/{BridgeWidget-Cdho2hYD.js → BridgeWidget-BCC7YXWj.js} +9 -8
  5. package/dist/browser/checkout/{CommerceWidget-BzipzAPM.js → CommerceWidget-B4QxFLZq.js} +29 -28
  6. package/dist/browser/checkout/CryptoFiatProvider-b0KhVg3Y.js +224 -0
  7. package/dist/browser/checkout/{EllipsizedText-CvkYzx6o.js → EllipsizedText-CF9lzi6c.js} +1 -1
  8. package/dist/browser/checkout/{FeesBreakdown-2gL4cI-R.js → FeesBreakdown-BGnZxcX5.js} +1 -1
  9. package/dist/browser/checkout/{HandoverContent-Bl4qmdQg.js → HandoverContent-CESizLWk.js} +1 -1
  10. package/dist/browser/checkout/{OnRampWidget-QJuXcGjQ.js → OnRampWidget-BrGpM6Vn.js} +3 -3
  11. package/dist/browser/checkout/{SaleWidget-edWOlmfl.js → SaleWidget-iuigaIZp.js} +15 -26
  12. package/dist/browser/checkout/{SpendingCapHero-CqFT2_-Q.js → SpendingCapHero-B3sb2Wt1.js} +1 -1
  13. package/dist/browser/checkout/{SwapWidget-gFL-1ypc.js → SwapWidget-CdXf4YYP.js} +9 -8
  14. package/dist/browser/checkout/{TopUpView-BQBIv4KK.js → TopUpView-Bg-huhcb.js} +6 -239
  15. package/dist/browser/checkout/{WalletApproveHero-CLTmvRwO.js → WalletApproveHero-DW6Uw6rT.js} +3 -3
  16. package/dist/browser/checkout/{WalletWidget-DqzlgTAL.js → WalletWidget-ChYjXfAy.js} +17 -32
  17. package/dist/browser/checkout/{auto-track-B_DVujaR.js → auto-track-CgS-wbin.js} +1 -1
  18. package/dist/browser/checkout/{index-DvBzy5DX.js → index-BjLYItcm.js} +72 -69
  19. package/dist/browser/checkout/{index-DitiTTnr.js → index-BqJ9Usxu.js} +1 -1
  20. package/dist/browser/checkout/{index-DYTK3G7G.js → index-C4anNRY5.js} +2 -2
  21. package/dist/browser/checkout/{index-B_wChk6v.js → index-CshBDuS0.js} +1 -1
  22. package/dist/browser/checkout/{index-CRuWUFZW.js → index-D6TVOnc2.js} +1 -1
  23. package/dist/browser/checkout/{index-BVEcFW11.js → index-DoYS_inI.js} +1 -1
  24. package/dist/browser/checkout/{index-yoSSDRdd.js → index-LCMExv1j.js} +1 -1
  25. package/dist/browser/checkout/{index-CgtLpuEZ.js → index-bNCjF_qE.js} +1 -1
  26. package/dist/browser/checkout/{index-BGasM3FI.js → index-qYOj-RwR.js} +1 -1
  27. package/dist/browser/checkout/{index.umd-5W8TJb-e.js → index.umd-CL6Tp5Ej.js} +1 -1
  28. package/dist/browser/checkout/{retry-Bd7qMg0v.js → retry-GJcGp5Sw.js} +1 -1
  29. package/dist/browser/checkout/sdk.js +15 -15
  30. package/dist/browser/checkout/{useInterval-DI0ddcnq.js → useInterval-BfG2xnz-.js} +1 -1
  31. package/dist/browser/checkout/widgets-esm.js +1 -1
  32. package/dist/browser/checkout/widgets.js +267 -296
  33. package/dist/{checkout-C12Br7lr.js → checkout-GzXHS6tQ.js} +22 -22
  34. package/dist/checkout.d.ts +50 -50
  35. package/dist/checkout.js +5 -5
  36. package/dist/{config-BR83WwI2.js → config-D--8q9Ky.js} +1 -1
  37. package/dist/config.js +1 -1
  38. package/dist/{index-DeyLbhnj.js → index-CS6nfOqN.js} +1 -1
  39. package/dist/{index-B12uBW7v.js → index-CTG8gj6p.js} +1 -1
  40. package/dist/{index-oQTMj48l.js → index-CUn7Zo3y.js} +1 -1
  41. package/dist/{index-o82oWSK6.js → index-CY5IMe_m.js} +1 -1
  42. package/dist/{index-CA86ogWz.js → index-D7sVu0uD.js} +3 -3
  43. package/dist/{index-B3-R16ZI.js → index-Papo4AAa.js} +4 -4
  44. package/dist/index.browser.js +5 -5
  45. package/dist/index.browser.js.map +1 -1
  46. package/dist/index.cjs +93 -23
  47. package/dist/index.d.ts +63 -63
  48. package/dist/index.js +14 -14
  49. package/dist/{minting_backend-BZNiHRmU.js → minting_backend-Clnkogn9.js} +3 -3
  50. package/dist/minting_backend.js +5 -5
  51. package/dist/{orderbook-B1Tjr_q4.js → orderbook-CZN-dE1t.js} +1 -1
  52. package/dist/orderbook.js +2 -2
  53. package/dist/{passport-BSNhvk09.js → passport-pc8TWhS9.js} +73 -3
  54. package/dist/passport.js +4 -4
  55. package/dist/{webhook-2lD6l4rk.js → webhook-r7AuAOkP.js} +1 -1
  56. package/dist/webhook.js +2 -2
  57. package/dist/{x-BuvtdpOp.js → x-LQ1vUAJM.js} +3 -3
  58. package/dist/x.js +4 -4
  59. package/package.json +1 -1
@@ -1,226 +1,6 @@
1
- import { bf as Environment, c1 as axios, r as reactExports, j as jsx, q as jsxs, X as isDualVariantIcon, al as MenuItem, H as Box, l as useTranslation, aL as ViewContext, aQ as EventTargetContext, ay as useAnalytics, cr as GasEstimateType, bF as HeaderNavigation, aA as Heading, M as Body, aX as SimpleLayout, a$ as orchestrationEvents, I as IMTBLWidgetEvents, V as ViewActions } from './index-DvBzy5DX.js';
2
- import { f as formatUnits } from './index-B_wChk6v.js';
3
-
4
- /**
5
- * Class representing the configuration for the CryptoFiatModule.
6
- */
7
- class CryptoFiatConfiguration {
8
- baseConfig;
9
- /**
10
- * Creates an instance of CryptoFiatConfiguration.
11
- */
12
- constructor({ baseConfig }) {
13
- this.baseConfig = baseConfig;
14
- }
15
- }
16
-
17
- const CHECKOUT_API_BASE_URL = {
18
- [Environment.SANDBOX]: 'https://checkout-api.sandbox.immutable.com',
19
- [Environment.PRODUCTION]: 'https://checkout-api.immutable.com',
20
- };
21
- const DEFAULT_FIAT_SYMBOL = 'usd';
22
- /**
23
- * CryptoFiat module class
24
- */
25
- class CryptoFiat {
26
- coinsCache;
27
- overridesCache;
28
- config;
29
- /**
30
- * Creates an instance of CryptoFiat.
31
- * @param {CryptoFiatConfiguration} config - configuration parameters for the module
32
- */
33
- constructor(config) {
34
- this.coinsCache = null;
35
- this.overridesCache = null;
36
- this.config = config.baseConfig;
37
- }
38
- urlWithPath(path) {
39
- return CHECKOUT_API_BASE_URL[this.config.environment] + path;
40
- }
41
- // Given that we could have multiple coins with the same symbol
42
- // and we do not have the contract address we are forcing the
43
- // conversion because we are using coingecko under the hood.
44
- async fetchOverrides() {
45
- if (this.overridesCache !== null)
46
- return;
47
- const url = this.urlWithPath('/v1/fiat/coins/overrides');
48
- const response = await axios.get(url);
49
- if (response.status !== 200) {
50
- throw new Error(`Error fetching coins overrides: ${response.status} ${response.statusText}`);
51
- }
52
- this.overridesCache = new Map(Object.entries(response.data));
53
- }
54
- async fetchCoins() {
55
- if (this.coinsCache !== null)
56
- return;
57
- await this.fetchOverrides();
58
- const url = this.urlWithPath('/v1/fiat/coins/all');
59
- const response = await axios.get(url);
60
- if (response.status !== 200) {
61
- throw new Error(`Error fetching coins list: ${response.status} ${response.statusText}`);
62
- }
63
- const { data } = response;
64
- this.coinsCache = new Map();
65
- for (const coin of data) {
66
- const override = this.overridesCache.get(coin.symbol.toLowerCase());
67
- this.coinsCache.set(coin.symbol.toLowerCase(), override || coin.id.toLowerCase());
68
- }
69
- }
70
- /**
71
- * Converts tokens with fiat currencies.
72
- * @param {CryptoFiatConvertParams} - object containing the token symbols to get a conversion
73
- * for and the optional fiat symbols to convert to.
74
- * @returns {Promise<CryptoFiatConvertReturn>} - promise to return the map that associates
75
- * token symbol to its conversion value object
76
- * with fiat currencies.
77
- */
78
- async convert({ tokenSymbols, fiatSymbols = [], }) {
79
- if (!tokenSymbols || tokenSymbols.length === 0) {
80
- throw new Error('Error missing token symbols to convert');
81
- }
82
- const currencies = fiatSymbols.filter((fiatSymbol) => fiatSymbol !== '');
83
- if (currencies.length === 0)
84
- currencies.push(DEFAULT_FIAT_SYMBOL);
85
- await this.fetchCoins();
86
- const idsParam = tokenSymbols
87
- .map((tokenSymbol) => this.coinsCache.get(tokenSymbol.toLowerCase()))
88
- .filter((tokenSymbol) => tokenSymbol !== '' && tokenSymbol !== undefined)
89
- .join(',');
90
- const currenciesParam = currencies
91
- .join(',')
92
- .toLowerCase();
93
- const url = this.urlWithPath(`/v1/fiat/conversion?ids=${idsParam}&currencies=${currenciesParam}`);
94
- const response = await axios.get(url);
95
- if (response.status !== 200) {
96
- throw new Error(`Error fetching prices: ${response.status} ${response.statusText}`);
97
- }
98
- const { data } = response;
99
- const result = {};
100
- for (const symbol of tokenSymbols) {
101
- const symbolKey = symbol.toLowerCase();
102
- const coinId = this.coinsCache.get(symbolKey);
103
- result[symbolKey] = {};
104
- if (coinId)
105
- result[symbolKey] = data[coinId] || {};
106
- }
107
- return result;
108
- }
109
- }
110
-
111
- var FiatSymbols;
112
- (function (FiatSymbols) {
113
- FiatSymbols["USD"] = "usd";
114
- })(FiatSymbols || (FiatSymbols = {}));
115
- const initialCryptoFiatState = {
116
- cryptoFiat: null,
117
- fiatSymbol: FiatSymbols.USD,
118
- tokenSymbols: [],
119
- conversions: new Map(),
120
- };
121
- var CryptoFiatActions;
122
- (function (CryptoFiatActions) {
123
- CryptoFiatActions["SET_CRYPTO_FIAT"] = "SET_CRYPTO_FIAT";
124
- CryptoFiatActions["SET_FIAT_SYMBOL"] = "SET_FIAT_SYMBOL";
125
- CryptoFiatActions["SET_TOKEN_SYMBOLS"] = "SET_TOKEN_SYMBOLS";
126
- CryptoFiatActions["SET_CONVERSIONS"] = "SET_CONVERSIONS";
127
- })(CryptoFiatActions || (CryptoFiatActions = {}));
128
- // eslint-disable-next-line @typescript-eslint/naming-convention
129
- const CryptoFiatContext = reactExports.createContext({
130
- cryptoFiatState: initialCryptoFiatState,
131
- cryptoFiatDispatch: () => { },
132
- });
133
- const cryptoFiatReducer = (state, action) => {
134
- switch (action.payload.type) {
135
- case CryptoFiatActions.SET_CRYPTO_FIAT:
136
- return {
137
- ...state,
138
- cryptoFiat: action.payload.cryptoFiat,
139
- };
140
- case CryptoFiatActions.SET_FIAT_SYMBOL:
141
- return {
142
- ...state,
143
- fiatSymbol: action.payload.fiatSymbol,
144
- };
145
- case CryptoFiatActions.SET_TOKEN_SYMBOLS:
146
- return {
147
- ...state,
148
- tokenSymbols: action.payload.tokenSymbols,
149
- };
150
- case CryptoFiatActions.SET_CONVERSIONS:
151
- return {
152
- ...state,
153
- conversions: action.payload.conversions,
154
- };
155
- default:
156
- return state;
157
- }
158
- };
159
-
160
- const updateConversions = (cryptoToFiatResult, fiatSymbol) => {
161
- const conversionMap = new Map();
162
- // TODO: Consider using Object.keys(cryptoToFiatResult) instead of for...in
163
- // for...in includes properties from the prototype chain
164
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
165
- for (const tokenSymbol in cryptoToFiatResult) {
166
- const conversion = cryptoToFiatResult[tokenSymbol];
167
- const usdAmount = conversion[fiatSymbol];
168
- if (usdAmount !== undefined) {
169
- conversionMap.set(tokenSymbol, usdAmount);
170
- }
171
- }
172
- return conversionMap;
173
- };
174
- const getCryptoToFiatConversion = async (cryptoFiat, fiatSymbol, tokenSymbols) => {
175
- try {
176
- if (tokenSymbols.length === 0)
177
- return new Map();
178
- const cryptoToFiatResult = await cryptoFiat.convert({
179
- tokenSymbols,
180
- fiatSymbols: [fiatSymbol],
181
- });
182
- return updateConversions(cryptoToFiatResult, fiatSymbol);
183
- }
184
- catch (err) {
185
- return new Map();
186
- }
187
- };
188
-
189
- const DEFAULT_TOKEN_SYMBOLS = ['ETH', 'IMX'];
190
- function CryptoFiatProvider({ environment, children }) {
191
- const [cryptoFiatState, cryptoFiatDispatch] = reactExports.useReducer(cryptoFiatReducer, initialCryptoFiatState);
192
- const { cryptoFiat, fiatSymbol, tokenSymbols } = cryptoFiatState;
193
- reactExports.useEffect(() => {
194
- cryptoFiatDispatch({
195
- payload: {
196
- type: CryptoFiatActions.SET_CRYPTO_FIAT,
197
- cryptoFiat: new CryptoFiat(new CryptoFiatConfiguration({
198
- baseConfig: {
199
- environment,
200
- },
201
- })),
202
- },
203
- });
204
- }, []);
205
- reactExports.useEffect(() => {
206
- if (!cryptoFiat || !fiatSymbol)
207
- return;
208
- (async () => {
209
- const conversions = await getCryptoToFiatConversion(cryptoFiat, fiatSymbol, [...new Set([...tokenSymbols, ...DEFAULT_TOKEN_SYMBOLS])]);
210
- cryptoFiatDispatch({
211
- payload: {
212
- type: CryptoFiatActions.SET_CONVERSIONS,
213
- conversions,
214
- },
215
- });
216
- })();
217
- }, [cryptoFiat, tokenSymbols, fiatSymbol]);
218
- return (
219
- // TODO: The object passed as the value prop to the Context provider changes every render.
220
- // To fix this consider wrapping it in a useMemo hook.
221
- // eslint-disable-next-line react/jsx-no-constructed-context-values
222
- jsx(CryptoFiatContext.Provider, { value: { cryptoFiatState, cryptoFiatDispatch }, children: children }));
223
- }
1
+ import { r as reactExports, j as jsx, q as jsxs, X as isDualVariantIcon, al as MenuItem, H as Box, bg as Environment, l as useTranslation, aM as ViewContext, aR as EventTargetContext, ay as useAnalytics, cr as GasEstimateType, bG as HeaderNavigation, aB as Heading, M as Body, aY as SimpleLayout, I as IMTBLWidgetEvents, V as ViewActions, b0 as orchestrationEvents } from './index-BjLYItcm.js';
2
+ import { C as CryptoFiatContext, a as CryptoFiatActions, D as DEFAULT_TOKEN_SYMBOLS } from './CryptoFiatProvider-b0KhVg3Y.js';
3
+ import { f as formatUnits } from './index-CshBDuS0.js';
224
4
 
225
5
  var BridgeWidgetViews;
226
6
  (function (BridgeWidgetViews) {
@@ -367,7 +147,7 @@ const TOOLKIT_BASE_URL = {
367
147
  function TopUpView({ widgetEvent, checkout,
368
148
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
369
149
  provider, // Keep this for future use
370
- showOnrampOption, showSwapOption, showBridgeOption, showAddFundsOption, tokenAddress, amount, analytics, onCloseButtonClick, onBackButtonClick, heading, subheading, }) {
150
+ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analytics, onCloseButtonClick, onBackButtonClick, heading, subheading, }) {
371
151
  const { t } = useTranslation();
372
152
  const { userJourney } = analytics;
373
153
  const { viewDispatch } = reactExports.useContext(ViewContext);
@@ -394,15 +174,6 @@ showOnrampOption, showSwapOption, showBridgeOption, showAddFundsOption, tokenAdd
394
174
  useMount(() => {
395
175
  page({ userJourney, screen: 'TopUp' });
396
176
  });
397
- // Go to add funds widget if available
398
- useMount(() => {
399
- if (showAddFundsOption) {
400
- orchestrationEvents.sendRequestAddFundsEvent(eventTarget, widgetEvent, {
401
- toTokenAddress: tokenAddress ?? '',
402
- toAmount: amount ?? '',
403
- });
404
- }
405
- }, () => showAddFundsOption !== undefined, [showAddFundsOption]);
406
177
  reactExports.useEffect(() => {
407
178
  if (!cryptoFiatDispatch)
408
179
  return;
@@ -583,11 +354,7 @@ showOnrampOption, showSwapOption, showBridgeOption, showAddFundsOption, tokenAdd
583
354
  isAvailable: true,
584
355
  isEnabled: showBridgeOption,
585
356
  },
586
- ], [showAddFundsOption, showBridgeOption, showOnrampOption, showSwapOption]);
587
- // if swap is available, don't show top up view
588
- // await for redirect to add funds widget
589
- if (showAddFundsOption)
590
- return null;
357
+ ], [showBridgeOption, showOnrampOption, showSwapOption]);
591
358
  return (jsx(SimpleLayout, { header: (jsx(HeaderNavigation, { onBackButtonClick: onBackButtonClick, onCloseButtonClick: onCloseButtonClick, showBack: true })), children: jsxs(Box, { sx: { paddingX: 'base.spacing.x4', paddingY: 'base.spacing.x4' }, children: [jsx(Heading, { size: "small", children: title }), description && (jsx(Body, { size: "small", sx: { color: 'base.color.text.body.secondary' }, children: description })), jsx(Box, { sx: { paddingY: 'base.spacing.x4' }, children: topUpFeatures
592
359
  .sort((a, b) => Number(b.isAvailable) - Number(a.isAvailable))
593
360
  .map((element) => element.isEnabled && (jsx(TopUpMenuItem, { testId: element.testId, icon: element.icon, iconVariant: element.iconVariant, intentIcon: element.intentIcon, heading: t(`${element.textConfigKey}.heading`), caption: !element.isAvailable
@@ -595,4 +362,4 @@ showOnrampOption, showSwapOption, showBridgeOption, showAddFundsOption, tokenAdd
595
362
  : t(`${element.textConfigKey}.caption`), onClick: element.onClickEvent, renderFeeFunction: element.fee, isDisabled: !element.isAvailable }, t(`${element.textConfigKey}.heading`).toLowerCase()))) })] }) }));
596
363
  }
597
364
 
598
- export { BridgeWidgetViews as B, CryptoFiatContext as C, OnRampWidgetViews as O, SwapWidgetViews as S, TopUpView as T, CryptoFiatActions as a, useAsyncMemo as b, CryptoFiatProvider as c, useMount as u };
365
+ export { BridgeWidgetViews as B, OnRampWidgetViews as O, SwapWidgetViews as S, TopUpView as T, useMount as u };
@@ -1,6 +1,6 @@
1
- import { a9 as hFlex, j as jsx, ar as motion, _ as _objectWithoutProperties, x as useTheme, r as reactExports, Y as _slicedToArray, z as useGetSubcomponentChild, D as merge, q as jsxs, a0 as BaseClickable, R as ButtCon, G as SmartClone, dk as AnimatePresence, H as Box, a8 as Stack, a1 as ClassNames, U as _defineProperty, dl as getTertiaryButtonStyles, K as flattenChildren, J as isChildSubcomponent, at as Divider, dm as TextInput, dn as FormControlWrapper, l as useTranslation, al as MenuItem, ax as Drawer, M as Body, dp as Select, bf as Environment, d6 as WidgetTheme, dq as DuoCon, aA as Heading, T as Button, cp as NATIVE, a_ as getTokenImageByAddress, aZ as isNativeToken, df as DEFAULT_BALANCE_RETRY_POLICY, aN as getRemoteImage, ci as getChainNameById, i as getL1ChainId, ca as isWalletConnectProvider, cl as isMetaMaskProvider, bm as CloudImage, bJ as FooterLogo, co as formatZeroAmount, am as tokenValueFormat, c4 as ShimmerBox, bh as PriceDisplay, au as Fragment, cz as heroBackGroundStyles, cA as heroImageStyles, dr as heroImageBottomAlign } from './index-DvBzy5DX.js';
2
- import { T as TokenImage, r as retry } from './retry-Bd7qMg0v.js';
3
- import { F as FeesBreakdown } from './FeesBreakdown-2gL4cI-R.js';
1
+ import { a9 as hFlex, j as jsx, ar as motion, _ as _objectWithoutProperties, x as useTheme, r as reactExports, Y as _slicedToArray, z as useGetSubcomponentChild, D as merge, q as jsxs, a0 as BaseClickable, R as ButtCon, G as SmartClone, dk as AnimatePresence, H as Box, a8 as Stack, a1 as ClassNames, U as _defineProperty, dl as getTertiaryButtonStyles, K as flattenChildren, J as isChildSubcomponent, at as Divider, dm as TextInput, dn as FormControlWrapper, l as useTranslation, al as MenuItem, ax as Drawer, M as Body, dp as Select, bg as Environment, d6 as WidgetTheme, dq as DuoCon, aB as Heading, T as Button, cp as NATIVE, a$ as getTokenImageByAddress, a_ as isNativeToken, df as DEFAULT_BALANCE_RETRY_POLICY, aO as getRemoteImage, ci as getChainNameById, i as getL1ChainId, ca as isWalletConnectProvider, cl as isMetaMaskProvider, bn as CloudImage, bJ as FooterLogo, co as formatZeroAmount, am as tokenValueFormat, c4 as ShimmerBox, bi as PriceDisplay, au as Fragment, cz as heroBackGroundStyles, cA as heroImageStyles, dr as heroImageBottomAlign } from './index-BjLYItcm.js';
2
+ import { T as TokenImage, r as retry } from './retry-GJcGp5Sw.js';
3
+ import { F as FeesBreakdown } from './FeesBreakdown-BGnZxcX5.js';
4
4
 
5
5
  function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -1,8 +1,7 @@
1
- import { R as ButtCon, T as Button, _ as _objectWithoutProperties, x as useTheme, $ as getStartingSize, ds as DEFAULT_BUTTON_SIZE, D as merge, r as reactExports, K as flattenChildren, j as jsx, J as isChildSubcomponent, G as SmartClone, H as Box, dt as getResponsiveSx, du as BUTTON_SIZES, dv as setDefaultSxBackgroundColor, a1 as ClassNames, U as _defineProperty, aY as TokenFilterTypes, l as useTranslation, aL as ViewContext, q as jsxs, M as Body, V as ViewActions, bV as ConnectLoaderContext, ay as useAnalytics, co as formatZeroAmount, aQ as EventTargetContext, bI as isPassportProvider, h as getL2ChainId, i as getL1ChainId, bf as Environment, al as MenuItem, am as tokenValueFormat, az as UserJourney, a$ as orchestrationEvents, I as IMTBLWidgetEvents, dw as ZERO_BALANCE_STRING, aZ as isNativeToken, dx as sendNetworkSwitchEvent, c2 as CheckoutErrorType, o as SharedViews, dy as NetworkFilterTypes, dz as sortNetworksCompareFn, c7 as getChainImage, df as DEFAULT_BALANCE_RETRY_POLICY, dA as sortTokensByAmount, a_ as getTokenImageByAddress, by as calculateCryptoToFiat, bF as HeaderNavigation, cn as ButtonNavigationStyles, dB as sendWalletWidgetCloseEvent, bJ as FooterLogo, aX as SimpleLayout, cm as WalletProviderName, cj as getWalletProviderNameByProvider, X as isDualVariantIcon, bO as abbreviateWalletAddress, aA as Heading, ax as Drawer, c9 as useWalletConnect, dC as sendDisconnectWalletEvent, ca as isWalletConnectProvider, cz as heroBackGroundStyles, cA as heroImageStyles, dr as heroImageBottomAlign, cB as SimpleTextBody, dD as FAQS_LINK, aT as Link, bi as viewReducer, bj as initialViewState, L as LoadingView, E as ErrorView } from './index-DvBzy5DX.js';
2
- import { C as CryptoFiatContext, a as CryptoFiatActions, c as CryptoFiatProvider, T as TopUpView } from './TopUpView-BQBIv4KK.js';
3
- import { T as TokenImage, r as retry } from './retry-Bd7qMg0v.js';
4
- import { u as useInterval } from './useInterval-DI0ddcnq.js';
5
- import './index-B_wChk6v.js';
1
+ import { R as ButtCon, T as Button, _ as _objectWithoutProperties, x as useTheme, $ as getStartingSize, dw as DEFAULT_BUTTON_SIZE, D as merge, r as reactExports, K as flattenChildren, j as jsx, J as isChildSubcomponent, G as SmartClone, H as Box, dx as getResponsiveSx, dy as BUTTON_SIZES, dz as setDefaultSxBackgroundColor, a1 as ClassNames, U as _defineProperty, aZ as TokenFilterTypes, l as useTranslation, aM as ViewContext, q as jsxs, M as Body, V as ViewActions, bV as ConnectLoaderContext, ay as useAnalytics, co as formatZeroAmount, aR as EventTargetContext, aA as isPassportProvider, h as getL2ChainId, i as getL1ChainId, bg as Environment, al as MenuItem, am as tokenValueFormat, az as UserJourney, b0 as orchestrationEvents, I as IMTBLWidgetEvents, dA as ZERO_BALANCE_STRING, a_ as isNativeToken, dB as sendNetworkSwitchEvent, c2 as CheckoutErrorType, o as SharedViews, dC as NetworkFilterTypes, dD as sortNetworksCompareFn, c7 as getChainImage, df as DEFAULT_BALANCE_RETRY_POLICY, dE as sortTokensByAmount, a$ as getTokenImageByAddress, bz as calculateCryptoToFiat, bG as HeaderNavigation, cn as ButtonNavigationStyles, dF as sendWalletWidgetCloseEvent, bJ as FooterLogo, aY as SimpleLayout, cm as WalletProviderName, cj as getWalletProviderNameByProvider, X as isDualVariantIcon, bO as abbreviateWalletAddress, aB as Heading, ax as Drawer, c9 as useWalletConnect, dG as sendDisconnectWalletEvent, ca as isWalletConnectProvider, cz as heroBackGroundStyles, cA as heroImageStyles, dr as heroImageBottomAlign, cB as SimpleTextBody, dH as FAQS_LINK, aU as Link, bj as viewReducer, bk as initialViewState, L as LoadingView, E as ErrorView } from './index-BjLYItcm.js';
2
+ import { C as CryptoFiatContext, a as CryptoFiatActions, b as CryptoFiatProvider } from './CryptoFiatProvider-b0KhVg3Y.js';
3
+ import { T as TokenImage, r as retry } from './retry-GJcGp5Sw.js';
4
+ import { u as useInterval } from './useInterval-BfG2xnz-.js';
6
5
 
7
6
  var horizontalMenuSxProps = {
8
7
  justifyContent: "stretch",
@@ -254,9 +253,8 @@ const walletReducer = (state, action) => {
254
253
  isSwapEnabled: action.payload.supportedTopUps.isSwapEnabled ?? true,
255
254
  isOnRampEnabled: action.payload.supportedTopUps.isOnRampEnabled ?? true,
256
255
  isBridgeEnabled: action.payload.supportedTopUps.isBridgeEnabled ?? true,
257
- isAddFundsEnabled: action.payload.supportedTopUps.isAddFundsEnabled ?? true,
256
+ isAddTokensEnabled: action.payload.supportedTopUps.isAddTokensEnabled ?? true,
258
257
  isSwapAvailable: action.payload.supportedTopUps.isSwapAvailable ?? true,
259
- isAddFundsAvailable: action.payload.supportedTopUps.isAddFundsAvailable ?? true,
260
258
  },
261
259
  };
262
260
  default:
@@ -332,7 +330,7 @@ function BalanceItem({ balanceInfo, theme, bridgeToL2OnClick, }) {
332
330
  const [isOnRampEnabled, setIsOnRampEnabled] = reactExports.useState();
333
331
  const [isBridgeEnabled, setIsBridgeEnabled] = reactExports.useState();
334
332
  const [isSwapEnabled, setIsSwapEnabled] = reactExports.useState();
335
- const [isAddFundsEnabled, setIsAddFundsEnabled] = reactExports.useState();
333
+ const [isAddTokensEnabled, setIsAddTokensEnabled] = reactExports.useState();
336
334
  const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
337
335
  const [onRampAllowedTokens, setOnRampAllowedTokens] = reactExports.useState([]);
338
336
  const [swapAllowedTokens, setSwapAllowedTokens] = reactExports.useState([]);
@@ -357,9 +355,9 @@ function BalanceItem({ balanceInfo, theme, bridgeToL2OnClick, }) {
357
355
  reactExports.useEffect(() => {
358
356
  if (!network || !supportedTopUps || !checkout)
359
357
  return;
360
- const enableAddCoin = (supportedTopUps?.isAddFundsEnabled ?? true)
358
+ const enableAddCoin = (supportedTopUps?.isAddTokensEnabled ?? true)
361
359
  && (supportedTopUps?.isSwapAvailable ?? true);
362
- setIsAddFundsEnabled(enableAddCoin);
360
+ setIsAddTokensEnabled(enableAddCoin);
363
361
  const enableBuyCoin = !enableAddCoin
364
362
  && network.chainId === getL2ChainId(checkout.config)
365
363
  && (supportedTopUps?.isOnRampEnabled ?? true);
@@ -379,14 +377,14 @@ function BalanceItem({ balanceInfo, theme, bridgeToL2OnClick, }) {
379
377
  const canBuy = Boolean(isOnRampEnabled
380
378
  && onRampAllowedTokens.length > 0
381
379
  && onRampAllowedTokens.find((token) => token.address?.toLowerCase() === balanceInfo.address?.toLowerCase()));
382
- const canAdd = Boolean(isAddFundsEnabled
380
+ const canAdd = Boolean(isAddTokensEnabled
383
381
  && swapAllowedTokens.length > 0
384
382
  && swapAllowedTokens.find((token) => token.address?.toLowerCase() === balanceInfo.address?.toLowerCase()));
385
383
  return canBuy || canAdd;
386
384
  }, [
387
385
  isOnRampEnabled,
388
386
  onRampAllowedTokens,
389
- isAddFundsEnabled,
387
+ isAddTokensEnabled,
390
388
  swapAllowedTokens,
391
389
  ]);
392
390
  const handleAddTokenClick = () => {
@@ -400,8 +398,8 @@ function BalanceItem({ balanceInfo, theme, bridgeToL2OnClick, }) {
400
398
  tokenAddress: balanceInfo.address,
401
399
  },
402
400
  });
403
- if (isAddFundsEnabled) {
404
- orchestrationEvents.sendRequestAddFundsEvent(eventTarget, IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT, {
401
+ if (isAddTokensEnabled) {
402
+ orchestrationEvents.sendRequestAddTokensEvent(eventTarget, IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT, {
405
403
  toAmount: '',
406
404
  toTokenAddress: balanceInfo.address ?? '',
407
405
  });
@@ -412,7 +410,7 @@ function BalanceItem({ balanceInfo, theme, bridgeToL2OnClick, }) {
412
410
  amount: '',
413
411
  });
414
412
  };
415
- return (jsxs(MenuItem, { testId: `balance-item-${balanceInfo.symbol}`, emphasized: true, children: [jsx(MenuItem.FramedImage, { use: (jsx(TokenImage, { theme: theme, src: balanceInfo.icon, name: balanceInfo.symbol, environment: checkout?.config.environment ?? Environment.PRODUCTION })), circularFrame: true }), jsx(MenuItem.Label, { children: balanceInfo.symbol }), jsx(MenuItem.Caption, { children: balanceInfo.description }), jsx(MenuItem.PriceDisplay, { testId: `balance-item-${balanceInfo.symbol}`, price: tokenValueFormat(balanceInfo.balance), fiatAmount: fiatAmount }), (isOnRampEnabled || isSwapEnabled || isBridgeEnabled || isAddFundsEnabled) && (jsxs(MenuItem.OverflowPopoverMenu, { size: "small", testId: "token-menu", onClick: () => {
413
+ return (jsxs(MenuItem, { testId: `balance-item-${balanceInfo.symbol}`, emphasized: true, children: [jsx(MenuItem.FramedImage, { use: (jsx(TokenImage, { theme: theme, src: balanceInfo.icon, name: balanceInfo.symbol, environment: checkout?.config.environment ?? Environment.PRODUCTION })), circularFrame: true }), jsx(MenuItem.Label, { children: balanceInfo.symbol }), jsx(MenuItem.Caption, { children: balanceInfo.description }), jsx(MenuItem.PriceDisplay, { testId: `balance-item-${balanceInfo.symbol}`, price: tokenValueFormat(balanceInfo.balance), fiatAmount: fiatAmount }), (isOnRampEnabled || isSwapEnabled || isBridgeEnabled || isAddTokensEnabled) && (jsxs(MenuItem.OverflowPopoverMenu, { size: "small", testId: "token-menu", onClick: () => {
416
414
  track({
417
415
  userJourney: UserJourney.WALLET,
418
416
  screen: 'WalletBalances',
@@ -701,12 +699,7 @@ function WalletBalances({ balancesLoading, theme, showNetworkMenu, }) {
701
699
  control: 'AddCoins',
702
700
  controlType: 'Button',
703
701
  });
704
- viewDispatch({
705
- payload: {
706
- type: ViewActions.UPDATE_VIEW,
707
- view: { type: SharedViews.TOP_UP_VIEW },
708
- },
709
- });
702
+ orchestrationEvents.sendRequestAddTokensEvent(eventTarget, IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT, {});
710
703
  };
711
704
  const handleBridgeToL2OnClick = (address) => {
712
705
  orchestrationEvents.sendRequestBridgeEvent(eventTarget, IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT, {
@@ -952,7 +945,7 @@ function WalletWidget(props) {
952
945
  const errorActionText = t('views.ERROR_VIEW.actionText');
953
946
  const loadingText = t('views.LOADING_VIEW.text');
954
947
  const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
955
- const { config: { environment, isOnRampEnabled, isSwapEnabled, isBridgeEnabled, isAddFundsEnabled, theme, }, walletConfig: { showDisconnectButton, showNetworkMenu, }, } = props;
948
+ const { config: { environment, isOnRampEnabled, isSwapEnabled, isBridgeEnabled, isAddTokensEnabled, theme, }, walletConfig: { showDisconnectButton, showNetworkMenu, }, } = props;
956
949
  const { connectLoaderState: { checkout, provider }, } = reactExports.useContext(ConnectLoaderContext);
957
950
  const [viewState, viewDispatch] = reactExports.useReducer(viewReducer, {
958
951
  ...initialViewState,
@@ -961,7 +954,6 @@ function WalletWidget(props) {
961
954
  const [walletState, walletDispatch] = reactExports.useReducer(walletReducer, { ...initialWalletState, walletConfig: { showDisconnectButton, showNetworkMenu } });
962
955
  const walletReducerValues = reactExports.useMemo(() => ({ walletState, walletDispatch }), [walletState, walletDispatch]);
963
956
  const viewReducerValues = reactExports.useMemo(() => ({ viewState, viewDispatch }), [viewState, viewDispatch]);
964
- const { supportedTopUps } = walletState;
965
957
  const { balancesLoading, refreshBalances } = useBalance({
966
958
  checkout,
967
959
  provider,
@@ -997,12 +989,6 @@ function WalletWidget(props) {
997
989
  checkSwapAvailable = await checkout.isSwapAvailable();
998
990
  }
999
991
  catch { /* */ }
1000
- let checkAddFundsEnabled = isAddFundsEnabled;
1001
- try {
1002
- const addFundsConfig = await checkout.config.remote.getConfig('addfunds');
1003
- checkAddFundsEnabled = addFundsConfig.enabled && isAddFundsEnabled;
1004
- }
1005
- catch { /* */ }
1006
992
  walletDispatch({
1007
993
  payload: {
1008
994
  type: WalletActions.SET_SUPPORTED_TOP_UPS,
@@ -1011,8 +997,7 @@ function WalletWidget(props) {
1011
997
  isSwapEnabled,
1012
998
  isOnRampEnabled,
1013
999
  isSwapAvailable: checkSwapAvailable,
1014
- isAddFundsEnabled: checkAddFundsEnabled,
1015
- isAddFundsAvailable: checkSwapAvailable && checkAddFundsEnabled,
1000
+ isAddTokensEnabled,
1016
1001
  },
1017
1002
  },
1018
1003
  });
@@ -1074,7 +1059,7 @@ function WalletWidget(props) {
1074
1059
  await initialiseWallet();
1075
1060
  };
1076
1061
  return (jsx(ViewContext.Provider, { value: viewReducerValues, children: jsx(CryptoFiatProvider, { environment: environment, children: jsxs(WalletContext.Provider, { value: walletReducerValues, children: [viewState.view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: loadingText })), viewState.view.type === WalletWidgetViews.WALLET_BALANCES && (jsx(WalletBalances, { balancesLoading: balancesLoading, theme: theme, showNetworkMenu: showNetworkMenu })), viewState.view.type === WalletWidgetViews.SETTINGS
1077
- && (jsx(Settings, { showDisconnectButton: showDisconnectButton })), viewState.view.type === WalletWidgetViews.COIN_INFO && (jsx(CoinInfo, {})), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: errorActionText, onActionClick: errorAction, onCloseClick: () => sendWalletWidgetCloseEvent(eventTarget) })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx(TopUpView, { analytics: { userJourney: UserJourney.WALLET }, widgetEvent: IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT, checkout: checkout, showOnrampOption: isOnRampEnabled, showSwapOption: isSwapEnabled, showBridgeOption: isBridgeEnabled, showAddFundsOption: supportedTopUps?.isAddFundsAvailable, onCloseButtonClick: () => sendWalletWidgetCloseEvent(eventTarget) }))] }) }) }));
1062
+ && (jsx(Settings, { showDisconnectButton: showDisconnectButton })), viewState.view.type === WalletWidgetViews.COIN_INFO && (jsx(CoinInfo, {})), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: errorActionText, onActionClick: errorAction, onCloseClick: () => sendWalletWidgetCloseEvent(eventTarget) }))] }) }) }));
1078
1063
  }
1079
1064
 
1080
1065
  export { WalletWidget as default };
@@ -1,4 +1,4 @@
1
- import { ea as pTimeout } from './index-DvBzy5DX.js';
1
+ import { ea as pTimeout } from './index-BjLYItcm.js';
2
2
 
3
3
  // Check if a user is opening the link in a new tab
4
4
  function userNewTab(event) {