@imtbl/checkout-widgets 2.24.8 → 2.24.9-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{AddTokensWidget-BQfrLKCo.js → AddTokensWidget-CIR8BF_I.js} +24 -297
- package/dist/browser/{BridgeWidget-6KlgTXwZ.js → BridgeWidget-C5Uljhhx.js} +13 -294
- package/dist/browser/{CommerceWidget-CcCuv661.js → CommerceWidget-CeBBYCbK.js} +17 -47
- package/dist/browser/{FeesBreakdown-DvoQJlP-.js → FeesBreakdown-BU4haotD.js} +1 -1
- package/dist/browser/{OnRampWidget-DaL34PiA.js → OnRampWidget-Ccvb3QkT.js} +5 -80
- package/dist/browser/{SaleWidget-D-IBBRTL.js → SaleWidget-CPARFlzv.js} +61 -219
- package/dist/browser/{SpendingCapHero-Z5NIcrWw.js → SpendingCapHero-B-0YYZho.js} +1 -1
- package/dist/browser/{SwapWidget-C4B2Answ.js → SwapWidget-ujE6uX-N.js} +12 -206
- package/dist/browser/{TokenImage-DucOedrZ.js → TokenImage-BeUf_Ulv.js} +1 -1
- package/dist/browser/{TopUpView-BIvdNYib.js → TopUpView-GMv3360Q.js} +3 -54
- package/dist/browser/{WalletApproveHero-ge2JSOYk.js → WalletApproveHero-BJi7ufqM.js} +4 -12
- package/dist/browser/{WalletWidget-hiUotMuQ.js → WalletWidget-BABrqsfd.js} +4 -96
- package/dist/browser/{index-2esq4Cem.js → index-CcxHW36j.js} +1275 -9717
- package/dist/browser/{index-DWNAmu0n.js → index-Cp1w6map.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{useInterval-1gu4cbu3.js → useInterval-DbCsm_gG.js} +1 -1
- package/dist/types/components/FormComponents/SelectForm/SelectForm.d.ts +1 -5
- package/dist/types/components/FormComponents/SelectInput/SelectInput.d.ts +1 -5
- package/dist/types/components/Transak/TransakIframe.d.ts +0 -1
- package/dist/types/components/Transak/useTransakEvents.d.ts +0 -4
- package/dist/types/components/WalletDrawer/ConnectWalletDrawer.d.ts +1 -2
- package/dist/types/lib/squid/hooks/useExecute.d.ts +1 -2
- package/dist/types/views/top-up/TopUpView.d.ts +1 -5
- package/dist/types/widgets/add-tokens/hooks/useError.d.ts +1 -1
- package/dist/types/widgets/purchase/components/PurchaseConnectWalletDrawer.d.ts +1 -3
- package/dist/types/widgets/sale/hooks/useSaleEvents.d.ts +5 -31
- package/dist/types/widgets/swap/components/Fees.d.ts +1 -1
- package/package.json +7 -9
- package/src/components/ConnectLoader/ConnectLoader.tsx +0 -16
- package/src/components/FormComponents/SelectForm/SelectForm.tsx +2 -18
- package/src/components/FormComponents/SelectInput/SelectInput.tsx +1 -12
- package/src/components/RouteOptionsDrawer/RouteOptionsDrawer.tsx +2 -26
- package/src/components/Transactions/ChangeWallet.tsx +1 -12
- package/src/components/Transactions/ClaimWithdrawalInProgress.tsx +0 -11
- package/src/components/Transactions/NoTransactions.tsx +0 -10
- package/src/components/Transactions/TransactionItemWithdrawPending.tsx +1 -13
- package/src/components/Transactions/Transactions.tsx +2 -28
- package/src/components/Transak/TransakIframe.tsx +0 -6
- package/src/components/Transak/useTransakEvents.ts +1 -70
- package/src/components/WalletDrawer/ConnectWalletDrawer.tsx +2 -35
- package/src/components/WalletDrawer/PayWithWalletDrawer.tsx +0 -1
- package/src/context/view-context/test-components/ViewContextTestComponent.tsx +14 -15
- package/src/lib/squid/hooks/useExecute.ts +5 -18
- package/src/views/top-up/TopUpView.tsx +5 -56
- package/src/widgets/add-tokens/AddTokensRoot.tsx +28 -29
- package/src/widgets/add-tokens/AddTokensWidget.tsx +2 -17
- package/src/widgets/add-tokens/components/TokenDrawerMenu.tsx +2 -18
- package/src/widgets/add-tokens/hooks/useError.tsx +1 -18
- package/src/widgets/add-tokens/hooks/useErrorHandler.ts +2 -12
- package/src/widgets/add-tokens/views/AddTokens.tsx +8 -154
- package/src/widgets/add-tokens/views/Review.tsx +6 -94
- package/src/widgets/bridge/BridgeWidget.tsx +0 -35
- package/src/widgets/bridge/BridgeWidgetRoot.tsx +17 -18
- package/src/widgets/bridge/components/BridgeForm.tsx +0 -20
- package/src/widgets/bridge/components/BridgeReviewSummary.tsx +1 -49
- package/src/widgets/bridge/components/WalletAndNetworkSelector.tsx +3 -122
- package/src/widgets/bridge/views/ApproveTransaction.tsx +1 -15
- package/src/widgets/bridge/views/Bridge.tsx +1 -16
- package/src/widgets/bridge/views/BridgeReview.tsx +1 -12
- package/src/widgets/bridge/views/ClaimWithdrawal.tsx +0 -11
- package/src/widgets/bridge/views/MoveInProgress.tsx +0 -24
- package/src/widgets/bridge/views/WalletNetworkSelectionView.tsx +1 -12
- package/src/widgets/connect/ConnectWidget.tsx +2 -18
- package/src/widgets/connect/ConnectWidgetRoot.tsx +15 -16
- package/src/widgets/connect/components/WalletList.tsx +6 -55
- package/src/widgets/connect/views/ConnectWallet.tsx +1 -12
- package/src/widgets/connect/views/ReadyToConnect.tsx +2 -29
- package/src/widgets/connect/views/SwitchNetworkEth.tsx +3 -22
- package/src/widgets/connect/views/SwitchNetworkZkEVM.tsx +0 -18
- package/src/widgets/immutable-commerce/CommerceWidgetRoot.tsx +17 -19
- package/src/widgets/on-ramp/OnRampWidget.tsx +0 -2
- package/src/widgets/on-ramp/OnRampWidgetRoot.tsx +23 -24
- package/src/widgets/on-ramp/views/OnRampMain.tsx +1 -91
- package/src/widgets/purchase/PurchaseWidgetRoot.tsx +22 -23
- package/src/widgets/purchase/components/PurchaseConnectWalletDrawer.tsx +2 -34
- package/src/widgets/purchase/components/PurchaseDeliverToWalletDrawer.tsx +0 -1
- package/src/widgets/purchase/components/PurchasePayWithWalletDrawer.tsx +0 -2
- package/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.tsx +1 -30
- package/src/widgets/purchase/components/WithCard.tsx +0 -4
- package/src/widgets/purchase/views/Purchase.tsx +1 -2
- package/src/widgets/sale/SaleWidget.tsx +0 -2
- package/src/widgets/sale/SaleWidgetRoot.tsx +32 -33
- package/src/widgets/sale/components/OrderReview.tsx +2 -29
- package/src/widgets/sale/components/WithCard.tsx +0 -2
- package/src/widgets/sale/hooks/useSaleEvents.ts +3 -185
- package/src/widgets/sale/views/OrderSummary.tsx +2 -15
- package/src/widgets/sale/views/PayWithCard.tsx +4 -46
- package/src/widgets/sale/views/PayWithCoins.tsx +4 -9
- package/src/widgets/sale/views/PaymentMethods.tsx +3 -6
- package/src/widgets/sale/views/SaleErrorView.tsx +1 -1
- package/src/widgets/swap/SwapWidget.tsx +0 -24
- package/src/widgets/swap/SwapWidgetRoot.tsx +29 -30
- package/src/widgets/swap/components/Fees.tsx +1 -1
- package/src/widgets/swap/components/SwapForm.tsx +2 -140
- package/src/widgets/swap/views/ApproveERC20Onboarding.tsx +1 -36
- package/src/widgets/swap/views/SwapCoins.tsx +0 -17
- package/src/widgets/swap/views/SwapInProgress.tsx +0 -14
- package/src/widgets/transfer/TransferForm.tsx +3 -25
- package/src/widgets/transfer/TransferWidget.tsx +1 -23
- package/src/widgets/wallet/WalletWidgetRoot.tsx +24 -25
- package/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx +1 -50
- package/src/widgets/wallet/components/NetworkMenu/NetworkMenu.tsx +0 -13
- package/src/widgets/wallet/components/WalletAddress/WalletAddress.tsx +0 -13
- package/src/widgets/wallet/views/CoinInfo.tsx +1 -12
- package/src/widgets/wallet/views/Settings.tsx +1 -15
- package/src/widgets/wallet/views/WalletBalances.tsx +0 -24
- package/tsconfig.json +0 -1
- package/dist/browser/auto-track-C-H4NHVE.js +0 -105
- package/dist/browser/index-CcQ-5rAF.js +0 -446
- package/dist/browser/index-CvpdSuud.js +0 -5634
- package/dist/browser/index-D3m5uC9C.js +0 -60
- package/dist/browser/index-DJEaNohG.js +0 -65
- package/dist/browser/index-DPz4F2rf.js +0 -27
- package/dist/browser/index-DQZhPkHy.js +0 -65
- package/dist/browser/index.umd-brf0Qwxh.js +0 -32
- package/dist/browser/is-plan-event-enabled-mXX0dwl-.js +0 -17
- package/dist/types/context/analytics-provider/CustomAnalyticsProvider.d.ts +0 -7
- package/dist/types/context/analytics-provider/SegmentAnalyticsProvider.d.ts +0 -42
- package/dist/types/context/analytics-provider/SetupAnalytics.d.ts +0 -7
- package/dist/types/lib/analytics/identifyUser.d.ts +0 -8
- package/dist/types/lib/analytics/identifyUser.test.d.ts +0 -1
- package/src/context/analytics-provider/CustomAnalyticsProvider.tsx +0 -22
- package/src/context/analytics-provider/SegmentAnalyticsProvider.ts +0 -41
- package/src/context/analytics-provider/SetupAnalytics.tsx +0 -35
- package/src/lib/analytics/identifyUser.test.ts +0 -44
- package/src/lib/analytics/identifyUser.ts +0 -26
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { u as useTranslation, s as jsxs,
|
|
2
|
-
import { S as SelectForm, T as TextInputForm, A as Accordion, b as gasAmountAccordionStyles, a as TransactionRejected, N as NetworkSwitchDrawer, W as WalletApproveHero, g as getAllowedBalances } from './WalletApproveHero-
|
|
3
|
-
import { u as useInterval } from './useInterval-
|
|
4
|
-
import { S as SwapWidgetViews, T as TopUpView } from './TopUpView-
|
|
5
|
-
import { F as FeesBreakdown, f as fetchRiskAssessmentV2, i as isSingleAddressSanctioned } from './FeesBreakdown-
|
|
6
|
-
import { S as SpendingCapHero } from './SpendingCapHero-
|
|
1
|
+
import { u as useTranslation, s as jsxs, d6 as quickswapFooterStyles, t as Box, d7 as quickswapFooterLogoStyles, q as jsx, y as Body, d8 as quickswapFooterDisclaimerTextStyles, d9 as WidgetTheme, R as getRemoteImage, r as reactExports, v as Button, ay as Drawer, Q as CloudImage, H as Heading, cw as Logo, da as getImxTokenImage, c3 as formatUnits, j as calculateCryptoToFiat, D as tokenValueFormat, ca as isGasFree, p as parseUnits, i as formatZeroAmount, cr as ShimmerBox, bz as PriceDisplay, aD as Fragment, db as getCryptoToUSDConversion, X as ConnectLoaderContext, aW as isNativeToken, cI as NATIVE, aP as ViewContext, dc as calculateFeesFiat, cL as DEFAULT_QUOTE_REFRESH_INTERVAL, aG as isPassportProvider, dd as parseEther, M as amountInputValidation, a_ as ButtCon, be as motion, b3 as Tooltip, b8 as Icon, bG as r, V as ViewActions, a3 as SharedViews, F as getDefaultTokenImage, de as ESTIMATE_DEBOUNCE, df as DEFAULT_TOKEN_VALIDATION_DECIMALS, cR as parseChainId, cQ as DEFAULT_TOKEN_DECIMALS, E as EventTargetContext, _ as LoadingView, x as SimpleLayout, dg as sendSwapWidgetCloseEvent, K as orchestrationEvents, I as IMTBLWidgetEvents, G as HeaderNavigation, cP as IMX_TOKEN_SYMBOL, cq as CheckoutErrorType, cV as SimpleTextBody, cW as FooterButton, dh as CheckoutError, cT as heroBackGroundStyles, cU as heroImageStyles, bu as Trans, L as Link, aQ as useHandover, bC as viewReducer, bD as initialViewState, di as DEFAULT_BALANCE_RETRY_POLICY, dj as SwapDirection$1, c$ as StatusView, dk as sendSwapSuccessEvent, b_ as StatusType, dl as sendSwapFailedEvent, dm as sendSwapRejectedEvent, a4 as ErrorView, bK as ServiceUnavailableErrorView, l as TokenFilterTypes, cG as WalletProviderName } from './index-CcxHW36j.js';
|
|
2
|
+
import { S as SelectForm, T as TextInputForm, A as Accordion, b as gasAmountAccordionStyles, a as TransactionRejected, N as NetworkSwitchDrawer, W as WalletApproveHero, g as getAllowedBalances } from './WalletApproveHero-BJi7ufqM.js';
|
|
3
|
+
import { u as useInterval } from './useInterval-DbCsm_gG.js';
|
|
4
|
+
import { S as SwapWidgetViews, T as TopUpView } from './TopUpView-GMv3360Q.js';
|
|
5
|
+
import { F as FeesBreakdown, f as fetchRiskAssessmentV2, i as isSingleAddressSanctioned } from './FeesBreakdown-BU4haotD.js';
|
|
6
|
+
import { S as SpendingCapHero } from './SpendingCapHero-B-0YYZho.js';
|
|
7
7
|
|
|
8
8
|
function QuickswapFooter({ theme, environment }) {
|
|
9
9
|
const { t } = useTranslation();
|
|
@@ -98,8 +98,8 @@ const inputStyle = {
|
|
|
98
98
|
flex: 2,
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
function SelectInput({ testId, options, textInputValue, textInputPlaceholder, textInputValidator, textInputType, onTextInputChange, onTextInputBlur, onTextInputFocus, textInputTextAlign, textInputSubtext, textInputErrorMessage, testInputMode, selectTextAlign, selectSubtext, selectErrorMessage, textInputMaxButtonClick, onSelectChange, textInputDisabled, selectInputDisabled, selectedOption, coinSelectorHeading, defaultTokenImage,
|
|
102
|
-
return (jsxs(Box, { sx: selectInputBoxStyle, children: [jsx(Box, { sx: selectStyle, children: jsx(SelectForm, { testId: `${testId}-select-form`, options: options, subtext: selectSubtext, textAlign: selectTextAlign, errorMessage: selectErrorMessage, onSelectChange: onSelectChange, disabled: selectInputDisabled, selectedOption: selectedOption, coinSelectorHeading: coinSelectorHeading, defaultTokenImage: defaultTokenImage,
|
|
101
|
+
function SelectInput({ testId, options, textInputValue, textInputPlaceholder, textInputValidator, textInputType, onTextInputChange, onTextInputBlur, onTextInputFocus, textInputTextAlign, textInputSubtext, textInputErrorMessage, testInputMode, selectTextAlign, selectSubtext, selectErrorMessage, textInputMaxButtonClick, onSelectChange, textInputDisabled, selectInputDisabled, selectedOption, coinSelectorHeading, defaultTokenImage, environment, theme, themeOverrides, }) {
|
|
102
|
+
return (jsxs(Box, { sx: selectInputBoxStyle, children: [jsx(Box, { sx: selectStyle, children: jsx(SelectForm, { testId: `${testId}-select-form`, options: options, subtext: selectSubtext, textAlign: selectTextAlign, errorMessage: selectErrorMessage, onSelectChange: onSelectChange, disabled: selectInputDisabled, selectedOption: selectedOption, coinSelectorHeading: coinSelectorHeading, defaultTokenImage: defaultTokenImage, environment: environment, theme: theme, themeOverrides: themeOverrides }) }), jsx(Box, { sx: inputStyle, children: jsx(TextInputForm, { type: textInputType, testId: `${testId}-text-form`, value: textInputValue, placeholder: textInputPlaceholder, subtext: textInputSubtext, textAlign: textInputTextAlign, errorMessage: textInputErrorMessage, validator: textInputValidator, onTextInputChange: onTextInputChange, onTextInputBlur: onTextInputBlur, onTextInputFocus: onTextInputFocus, maxButtonClick: textInputMaxButtonClick, disabled: textInputDisabled, inputMode: testInputMode }) })] }));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function validateFromToken(fromToken) {
|
|
@@ -526,7 +526,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
526
526
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
527
527
|
const [direction, setDirection] = reactExports.useState(SwapDirection.FROM);
|
|
528
528
|
const [loading, setLoading] = reactExports.useState(false);
|
|
529
|
-
const { track } = useAnalytics();
|
|
530
529
|
// Form State
|
|
531
530
|
const [fromAmount, setFromAmount] = reactExports.useState(data?.fromAmount || '');
|
|
532
531
|
const [fromAmountError, setFromAmountError] = reactExports.useState('');
|
|
@@ -614,20 +613,7 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
614
613
|
]);
|
|
615
614
|
const onQuoteError = reactExports.useCallback((error) => {
|
|
616
615
|
setQuoteError(error);
|
|
617
|
-
|
|
618
|
-
userJourney: UserJourney.SWAP,
|
|
619
|
-
screen: 'SwapCoins',
|
|
620
|
-
control: 'UnableToSwapDrawer',
|
|
621
|
-
controlType: 'Button',
|
|
622
|
-
extras: {
|
|
623
|
-
fromToken,
|
|
624
|
-
toToken,
|
|
625
|
-
fromAmount,
|
|
626
|
-
toAmount,
|
|
627
|
-
error: 'message' in error ? error.message : error,
|
|
628
|
-
},
|
|
629
|
-
});
|
|
630
|
-
}, [track, fromToken, toToken, fromAmount, toAmount]);
|
|
616
|
+
}, [fromToken, toToken, fromAmount, toAmount]);
|
|
631
617
|
const tokensOptionsTo = reactExports.useMemo(() => allowedTokens
|
|
632
618
|
.map((token) => ({
|
|
633
619
|
id: formatTokenOptionsId(token.symbol, token.address),
|
|
@@ -894,17 +880,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
894
880
|
setFromToken(selected.token);
|
|
895
881
|
setFromBalance(selected.formattedBalance);
|
|
896
882
|
setFromTokenError('');
|
|
897
|
-
track({
|
|
898
|
-
userJourney: UserJourney.SWAP,
|
|
899
|
-
screen: 'SwapCoins',
|
|
900
|
-
control: 'SelectFrom',
|
|
901
|
-
controlType: 'Select',
|
|
902
|
-
extras: {
|
|
903
|
-
fromBalance: selected.formattedBalance,
|
|
904
|
-
fromToken: selected.token,
|
|
905
|
-
fromAmount,
|
|
906
|
-
},
|
|
907
|
-
});
|
|
908
883
|
}, [toToken]);
|
|
909
884
|
const onFromTextInputFocus = () => {
|
|
910
885
|
setDirection(SwapDirection.FROM);
|
|
@@ -920,17 +895,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
920
895
|
setLoading(true);
|
|
921
896
|
}
|
|
922
897
|
setFromAmount(value);
|
|
923
|
-
track({
|
|
924
|
-
userJourney: UserJourney.SWAP,
|
|
925
|
-
screen: 'SwapCoins',
|
|
926
|
-
control: 'InputFrom',
|
|
927
|
-
controlType: 'TextInput',
|
|
928
|
-
extras: {
|
|
929
|
-
fromBalance,
|
|
930
|
-
fromToken,
|
|
931
|
-
fromAmount: value,
|
|
932
|
-
},
|
|
933
|
-
});
|
|
934
898
|
};
|
|
935
899
|
const textInputMaxButtonClick = () => {
|
|
936
900
|
if (!fromBalance)
|
|
@@ -949,16 +913,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
949
913
|
else {
|
|
950
914
|
setFromAmount(fromBalanceTruncated);
|
|
951
915
|
}
|
|
952
|
-
track({
|
|
953
|
-
userJourney: UserJourney.SWAP,
|
|
954
|
-
screen: 'SwapCoins',
|
|
955
|
-
control: 'MaxFrom',
|
|
956
|
-
controlType: 'Button',
|
|
957
|
-
extras: {
|
|
958
|
-
fromBalance,
|
|
959
|
-
fromBalanceTruncated,
|
|
960
|
-
},
|
|
961
|
-
});
|
|
962
916
|
};
|
|
963
917
|
// ------------//
|
|
964
918
|
// TO //
|
|
@@ -972,16 +926,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
972
926
|
}
|
|
973
927
|
setToToken(selected);
|
|
974
928
|
setToTokenError('');
|
|
975
|
-
track({
|
|
976
|
-
userJourney: UserJourney.SWAP,
|
|
977
|
-
screen: 'SwapCoins',
|
|
978
|
-
control: 'SelectTo',
|
|
979
|
-
controlType: 'Select',
|
|
980
|
-
extras: {
|
|
981
|
-
toToken: selected,
|
|
982
|
-
toAmount,
|
|
983
|
-
},
|
|
984
|
-
});
|
|
985
929
|
}, [fromToken]);
|
|
986
930
|
const onToTextInputFocus = () => {
|
|
987
931
|
setDirection(SwapDirection.TO);
|
|
@@ -998,21 +942,10 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
998
942
|
setLoading(true);
|
|
999
943
|
}
|
|
1000
944
|
setToAmount(value);
|
|
1001
|
-
track({
|
|
1002
|
-
userJourney: UserJourney.SWAP,
|
|
1003
|
-
screen: 'SwapCoins',
|
|
1004
|
-
control: 'InputTo',
|
|
1005
|
-
controlType: 'TextInput',
|
|
1006
|
-
extras: {
|
|
1007
|
-
toToken,
|
|
1008
|
-
toAmount: value,
|
|
1009
|
-
},
|
|
1010
|
-
});
|
|
1011
945
|
};
|
|
1012
946
|
const reverseTokens = () => {
|
|
1013
947
|
const currentFromToken = fromToken;
|
|
1014
948
|
const currentToToken = toToken;
|
|
1015
|
-
const currentFromAmount = fromAmount;
|
|
1016
949
|
const currentToAmount = toAmount;
|
|
1017
950
|
setReverseRotation((prev) => (prev === 0 ? 180 : 0));
|
|
1018
951
|
resetFormErrors();
|
|
@@ -1039,19 +972,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
1039
972
|
setToToken(currentFromToken);
|
|
1040
973
|
setToAmount(fromAmount);
|
|
1041
974
|
}
|
|
1042
|
-
track({
|
|
1043
|
-
userJourney: UserJourney.SWAP,
|
|
1044
|
-
screen: 'SwapCoins',
|
|
1045
|
-
control: 'Flip',
|
|
1046
|
-
controlType: 'Button',
|
|
1047
|
-
extras: {
|
|
1048
|
-
fromToken: currentFromToken,
|
|
1049
|
-
fromAmount: currentFromAmount,
|
|
1050
|
-
toToken: currentToToken,
|
|
1051
|
-
toAmount: currentToAmount,
|
|
1052
|
-
isCurrentToTokenInSellList,
|
|
1053
|
-
},
|
|
1054
|
-
});
|
|
1055
975
|
};
|
|
1056
976
|
const openNotEnoughImxDrawer = () => {
|
|
1057
977
|
setShowNotEnoughImxDrawer(true);
|
|
@@ -1084,22 +1004,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
1084
1004
|
|| (validateFromAmountError && direction === SwapDirection.FROM)
|
|
1085
1005
|
|| (validateToAmountError && direction === SwapDirection.TO))
|
|
1086
1006
|
isSwapFormValid = false;
|
|
1087
|
-
track({
|
|
1088
|
-
userJourney: UserJourney.SWAP,
|
|
1089
|
-
screen: 'SwapCoins',
|
|
1090
|
-
control: 'FormValid',
|
|
1091
|
-
controlType: 'Button',
|
|
1092
|
-
extras: {
|
|
1093
|
-
isSwapFormValid,
|
|
1094
|
-
swapFromAddress: fromToken?.address,
|
|
1095
|
-
swapFromAmount: fromAmount,
|
|
1096
|
-
swapFromTokenSymbol: fromToken?.symbol,
|
|
1097
|
-
swapToAddress: toToken?.address,
|
|
1098
|
-
swapToAmount: toAmount,
|
|
1099
|
-
swapToTokenSymbol: toToken?.symbol,
|
|
1100
|
-
autoProceed,
|
|
1101
|
-
},
|
|
1102
|
-
});
|
|
1103
1007
|
return isSwapFormValid;
|
|
1104
1008
|
};
|
|
1105
1009
|
const isFormValidForAutoProceed = reactExports.useMemo(() => {
|
|
@@ -1126,24 +1030,6 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
1126
1030
|
return;
|
|
1127
1031
|
const transaction = quote;
|
|
1128
1032
|
const isValid = SwapFormValidator();
|
|
1129
|
-
// Tracking swap from data here and is valid or not to understand behaviour
|
|
1130
|
-
track({
|
|
1131
|
-
userJourney: UserJourney.SWAP,
|
|
1132
|
-
screen: 'SwapCoins',
|
|
1133
|
-
control: 'Swap',
|
|
1134
|
-
controlType: 'Button',
|
|
1135
|
-
extras: {
|
|
1136
|
-
swapFromAddress: fromToken?.address,
|
|
1137
|
-
swapFromAmount: fromAmount,
|
|
1138
|
-
swapFromTokenSymbol: fromToken?.symbol,
|
|
1139
|
-
swapToAddress: toToken?.address,
|
|
1140
|
-
swapToAmount: toAmount,
|
|
1141
|
-
swapToTokenSymbol: toToken?.symbol,
|
|
1142
|
-
isSwapFormValid: isValid,
|
|
1143
|
-
hasFundsForGas: !insufficientFundsForGas,
|
|
1144
|
-
autoProceed,
|
|
1145
|
-
},
|
|
1146
|
-
});
|
|
1147
1033
|
if (!isValid)
|
|
1148
1034
|
return;
|
|
1149
1035
|
if (!checkout || !provider || !transaction)
|
|
@@ -1245,7 +1131,7 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
1245
1131
|
: '', selectTextAlign: "left", textInputType: "number", testInputMode: "decimal", textInputValue: fromAmount, textInputPlaceholder: t('views.SWAP.swapForm.from.inputPlaceholder'), textInputSubtext: `${t('views.SWAP.content.fiatPricePrefix')}
|
|
1246
1132
|
$${formatZeroAmount(fromFiatValue, true)}`, textInputTextAlign: "right", textInputValidator: amountInputValidation, onTextInputChange: (v) => onFromTextInputChange(v), onTextInputFocus: onFromTextInputFocus, textInputMaxButtonClick: textInputMaxButtonClick, onSelectChange: onFromSelectChange, textInputErrorMessage: t(fromAmountError), selectErrorMessage: t(fromTokenError), selectedOption: fromToken
|
|
1247
1133
|
? formatTokenOptionsId(fromToken.symbol, fromToken.address)
|
|
1248
|
-
: undefined, coinSelectorHeading: t('views.SWAP.swapForm.from.selectorTitle'), defaultTokenImage: defaultTokenImage,
|
|
1134
|
+
: undefined, coinSelectorHeading: t('views.SWAP.swapForm.from.selectorTitle'), defaultTokenImage: defaultTokenImage, environment: checkout?.config.environment, theme: theme, themeOverrides: themeOverrides })] }), jsx(Box, { sx: {
|
|
1249
1135
|
display: 'flex',
|
|
1250
1136
|
justifyContent: 'center',
|
|
1251
1137
|
alignItems: 'center',
|
|
@@ -1262,14 +1148,7 @@ function SwapForm({ data, theme, themeOverrides, cancelAutoProceed, subTitle, })
|
|
|
1262
1148
|
w: 'base.icon.size.300',
|
|
1263
1149
|
} }) }), jsx(Tooltip.Content, { children: swapConversionRateTooltip })] }))] }), jsx(SelectInput, { testId: "toTokenInputs", options: tokensOptionsTo, selectTextAlign: "left", textInputType: "number", testInputMode: "decimal", textInputValue: toAmount, textInputPlaceholder: t('views.SWAP.swapForm.to.inputPlaceholder'), textInputTextAlign: "right", textInputValidator: amountInputValidation, onTextInputChange: (v) => onToTextInputChange(v), onTextInputFocus: onToTextInputFocus, onSelectChange: onToSelectChange, textInputErrorMessage: t(toAmountError), selectErrorMessage: t(toTokenError), selectedOption: toToken
|
|
1264
1150
|
? formatTokenOptionsId(toToken.symbol, toToken.address)
|
|
1265
|
-
: undefined, coinSelectorHeading: t('views.SWAP.swapForm.to.selectorTitle'), defaultTokenImage: defaultTokenImage,
|
|
1266
|
-
track({
|
|
1267
|
-
userJourney: UserJourney.SWAP,
|
|
1268
|
-
screen: 'SwapCoins',
|
|
1269
|
-
control: 'ViewFees',
|
|
1270
|
-
controlType: 'Button',
|
|
1271
|
-
});
|
|
1272
|
-
}, sx: {
|
|
1151
|
+
: undefined, coinSelectorHeading: t('views.SWAP.swapForm.to.selectorTitle'), defaultTokenImage: defaultTokenImage, environment: checkout?.config.environment, theme: theme, themeOverrides: themeOverrides })] })] }), jsx(Fees, { feeFiatValue: feeFiatValue, gasFeeToken: gasFeeToken, fees: formattedFees, sx: {
|
|
1273
1152
|
paddingBottom: '0',
|
|
1274
1153
|
}, loading: loading })] }), quoteError && (jsxs(Box, { sx: {
|
|
1275
1154
|
paddingX: 'base.spacing.x4',
|
|
@@ -1319,19 +1198,6 @@ function SwapCoins({ theme, themeOverrides, cancelAutoProceed, fromAmount, toAmo
|
|
|
1319
1198
|
const { swapState: { tokenBalances, autoProceed, }, } = reactExports.useContext(SwapContext);
|
|
1320
1199
|
const { connectLoaderState: { checkout, provider, }, } = reactExports.useContext(ConnectLoaderContext);
|
|
1321
1200
|
const [showNotEnoughImxDrawer, setShowNotEnoughImxDrawer] = reactExports.useState(false);
|
|
1322
|
-
const { page } = useAnalytics();
|
|
1323
|
-
reactExports.useEffect(() => {
|
|
1324
|
-
page({
|
|
1325
|
-
userJourney: UserJourney.SWAP,
|
|
1326
|
-
screen: 'SwapCoins',
|
|
1327
|
-
extras: {
|
|
1328
|
-
fromAmount,
|
|
1329
|
-
toAmount,
|
|
1330
|
-
fromTokenAddress,
|
|
1331
|
-
toTokenAddress,
|
|
1332
|
-
},
|
|
1333
|
-
});
|
|
1334
|
-
}, []);
|
|
1335
1201
|
reactExports.useEffect(() => {
|
|
1336
1202
|
if (hasZeroBalance(tokenBalances, IMX_TOKEN_SYMBOL) && !isPassportProvider(provider)) {
|
|
1337
1203
|
setShowNotEnoughImxDrawer(true);
|
|
@@ -1366,16 +1232,6 @@ function SwapCoins({ theme, themeOverrides, cancelAutoProceed, fromAmount, toAmo
|
|
|
1366
1232
|
function SwapInProgress({ transactionResponse, swapForm, }) {
|
|
1367
1233
|
const { t } = useTranslation();
|
|
1368
1234
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
1369
|
-
const { page } = useAnalytics();
|
|
1370
|
-
reactExports.useEffect(() => {
|
|
1371
|
-
page({
|
|
1372
|
-
userJourney: UserJourney.SWAP,
|
|
1373
|
-
screen: 'SwapInProgress',
|
|
1374
|
-
extras: {
|
|
1375
|
-
swapFormInfo: swapForm,
|
|
1376
|
-
},
|
|
1377
|
-
});
|
|
1378
|
-
}, []);
|
|
1379
1235
|
reactExports.useEffect(() => {
|
|
1380
1236
|
(async () => {
|
|
1381
1237
|
try {
|
|
@@ -1426,8 +1282,6 @@ function SwapInProgress({ transactionResponse, swapForm, }) {
|
|
|
1426
1282
|
return (jsx(LoadingView, { loadingText: t('views.SWAP.IN_PROGRESS.loading.text') }));
|
|
1427
1283
|
}
|
|
1428
1284
|
|
|
1429
|
-
const APPROVE_SPENDING = 'ApproveSpending';
|
|
1430
|
-
const APPROVE_SWAP = 'ApproveSwap';
|
|
1431
1285
|
function ApproveERC20Onboarding({ data }) {
|
|
1432
1286
|
const { t } = useTranslation();
|
|
1433
1287
|
const { swapState: { allowedTokens } } = reactExports.useContext(SwapContext);
|
|
@@ -1445,16 +1299,6 @@ function ApproveERC20Onboarding({ data }) {
|
|
|
1445
1299
|
// reject transaction flags
|
|
1446
1300
|
const [rejectedSpending, setRejectedSpending] = reactExports.useState(false);
|
|
1447
1301
|
const [rejectedSwap, setRejectedSwap] = reactExports.useState(false);
|
|
1448
|
-
const { page, track } = useAnalytics();
|
|
1449
|
-
reactExports.useEffect(() => {
|
|
1450
|
-
page({
|
|
1451
|
-
userJourney: UserJourney.SWAP,
|
|
1452
|
-
screen: noApprovalTransaction ? APPROVE_SWAP : APPROVE_SPENDING,
|
|
1453
|
-
extras: {
|
|
1454
|
-
swapFormInfo: data.swapFormInfo,
|
|
1455
|
-
},
|
|
1456
|
-
});
|
|
1457
|
-
}, []);
|
|
1458
1302
|
// Get symbol from swap info for approve amount text
|
|
1459
1303
|
const fromToken = reactExports.useMemo(() => allowedTokens.find((token) => token.address === data.swapFormInfo.fromTokenAddress), [allowedTokens, data.swapFormInfo.fromTokenAddress]);
|
|
1460
1304
|
// Common error view function
|
|
@@ -1532,15 +1376,6 @@ function ApproveERC20Onboarding({ data }) {
|
|
|
1532
1376
|
const handleApproveSpendingClick = reactExports.useCallback(async () => {
|
|
1533
1377
|
if (loading)
|
|
1534
1378
|
return;
|
|
1535
|
-
track({
|
|
1536
|
-
userJourney: UserJourney.SWAP,
|
|
1537
|
-
screen: APPROVE_SPENDING,
|
|
1538
|
-
control: APPROVE_SPENDING,
|
|
1539
|
-
controlType: 'Button',
|
|
1540
|
-
extras: {
|
|
1541
|
-
autoProceed: data.autoProceed,
|
|
1542
|
-
},
|
|
1543
|
-
});
|
|
1544
1379
|
setLoading(true);
|
|
1545
1380
|
if (!checkout || !provider) {
|
|
1546
1381
|
showErrorView();
|
|
@@ -1608,15 +1443,6 @@ function ApproveERC20Onboarding({ data }) {
|
|
|
1608
1443
|
const handleApproveSwapClick = reactExports.useCallback(async () => {
|
|
1609
1444
|
if (loading)
|
|
1610
1445
|
return;
|
|
1611
|
-
track({
|
|
1612
|
-
userJourney: UserJourney.SWAP,
|
|
1613
|
-
screen: APPROVE_SWAP,
|
|
1614
|
-
control: APPROVE_SWAP,
|
|
1615
|
-
controlType: 'Button',
|
|
1616
|
-
extras: {
|
|
1617
|
-
autoProceed: data.autoProceed,
|
|
1618
|
-
},
|
|
1619
|
-
});
|
|
1620
1446
|
setLoading(true);
|
|
1621
1447
|
if (!checkout || !provider) {
|
|
1622
1448
|
showErrorView();
|
|
@@ -1773,7 +1599,6 @@ function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProc
|
|
|
1773
1599
|
history: [],
|
|
1774
1600
|
});
|
|
1775
1601
|
const [swapState, swapDispatch] = reactExports.useReducer(swapReducer, initialSwapState);
|
|
1776
|
-
const { page } = useAnalytics();
|
|
1777
1602
|
const [errorViewLoading, setErrorViewLoading] = reactExports.useState(false);
|
|
1778
1603
|
const swapReducerValues = reactExports.useMemo(() => ({ swapState, swapDispatch }), [swapState, swapDispatch]);
|
|
1779
1604
|
const viewReducerValues = reactExports.useMemo(() => ({ viewState, viewDispatch }), [viewState, viewDispatch]);
|
|
@@ -1891,22 +1716,8 @@ function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProc
|
|
|
1891
1716
|
return optionsArray;
|
|
1892
1717
|
}, []);
|
|
1893
1718
|
return (jsx(GeoblockLoader, { checkout: checkout, widget: (jsx(ViewContext.Provider, { value: viewReducerValues, children: jsxs(SwapContext.Provider, { value: swapReducerValues, children: [viewState.view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), viewState.view.type === SwapWidgetViews.SWAP && (jsx(SwapCoins, { theme: theme, themeOverrides: themeOverrides, cancelAutoProceed: cancelAutoProceed, fromAmount: viewState.view.data?.fromAmount ?? fromAmount, toAmount: viewState.view.data?.toAmount ?? toAmount, fromTokenAddress: viewState.view.data?.fromTokenAddress ?? fromTokenAddress, toTokenAddress: viewState.view.data?.toTokenAddress ?? toTokenAddress, showBackButton: showBackButton, showHeader: showHeader ?? true, title: customTitle ?? t('views.SWAP.header.title'), subTitle: customSubTitle ?? t('views.SWAP.content.title') })), viewState.view.type === SwapWidgetViews.IN_PROGRESS && (jsx(SwapInProgress, { transactionResponse: viewState.view.data.transactionResponse, swapForm: viewState.view.data.swapForm })), viewState.view.type === SwapWidgetViews.APPROVE_ERC20 && (jsx(ApproveERC20Onboarding, { data: viewState.view.data })), viewState.view.type === SwapWidgetViews.SUCCESS && (jsx(StatusView, { statusText: t('views.SWAP.success.text'), actionText: t('views.SWAP.success.actionText'), onRenderEvent: () => {
|
|
1894
|
-
page({
|
|
1895
|
-
userJourney: UserJourney.SWAP,
|
|
1896
|
-
screen: 'SwapSuccess',
|
|
1897
|
-
extras: {
|
|
1898
|
-
fromTokenAddress: viewState.view.data?.fromTokenAddress,
|
|
1899
|
-
fromAmount: viewState.view.data?.fromAmount,
|
|
1900
|
-
toTokenAddress: viewState.view.data?.toTokenAddress,
|
|
1901
|
-
toAmount: viewState.view.data?.toAmount,
|
|
1902
|
-
},
|
|
1903
|
-
});
|
|
1904
1719
|
sendSwapSuccessEvent(eventTarget, viewState.view.data.transactionHash);
|
|
1905
1720
|
}, onActionClick: () => sendSwapWidgetCloseEvent(eventTarget), statusType: StatusType.SUCCESS, testId: "success-view" })), viewState.view.type === SwapWidgetViews.FAIL && (jsx(StatusView, { statusText: t('views.SWAP.failed.text'), actionText: t('views.SWAP.failed.actionText'), onRenderEvent: () => {
|
|
1906
|
-
page({
|
|
1907
|
-
userJourney: UserJourney.SWAP,
|
|
1908
|
-
screen: 'SwapFailed',
|
|
1909
|
-
});
|
|
1910
1721
|
sendSwapFailedEvent(eventTarget, 'Transaction failed');
|
|
1911
1722
|
}, onActionClick: () => {
|
|
1912
1723
|
if (viewState.view.type === SwapWidgetViews.FAIL) {
|
|
@@ -1921,11 +1732,6 @@ function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProc
|
|
|
1921
1732
|
});
|
|
1922
1733
|
}
|
|
1923
1734
|
}, statusType: StatusType.FAILURE, onCloseClick: () => sendSwapWidgetCloseEvent(eventTarget), testId: "fail-view" })), viewState.view.type === SwapWidgetViews.PRICE_SURGE && (jsx(StatusView, { statusText: t('views.SWAP.rejected.text'), actionText: t('views.SWAP.rejected.actionText'), onRenderEvent: () => {
|
|
1924
|
-
page({
|
|
1925
|
-
userJourney: UserJourney.SWAP,
|
|
1926
|
-
screen: 'PriceSurge',
|
|
1927
|
-
extras: viewState.view.data,
|
|
1928
|
-
});
|
|
1929
1735
|
sendSwapRejectedEvent(eventTarget, 'Price surge');
|
|
1930
1736
|
}, onActionClick: () => {
|
|
1931
1737
|
if (viewState.view.type === SwapWidgetViews.PRICE_SURGE) {
|
|
@@ -1954,7 +1760,7 @@ function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProc
|
|
|
1954
1760
|
viewDispatch({
|
|
1955
1761
|
payload: { type: ViewActions.UPDATE_VIEW, view: { type: SwapWidgetViews.SWAP } },
|
|
1956
1762
|
});
|
|
1957
|
-
} })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx(TopUpView, {
|
|
1763
|
+
} })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx(TopUpView, { checkout: checkout, provider: provider, widgetEvent: IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT, showOnrampOption: isOnRampEnabled, showSwapOption: isSwapEnabled, showBridgeOption: isBridgeEnabled, onCloseButtonClick: () => sendSwapWidgetCloseEvent(eventTarget) }))] }) })), serviceUnavailableView: (jsx(ServiceUnavailableToRegionErrorView, { service: ServiceType.SWAP, onCloseClick: () => sendSwapWidgetCloseEvent(window), showHeader: showHeader, primaryActionText: topUpOptions && topUpOptions?.length > 0
|
|
1958
1764
|
? t(topUpOptions[0].textKey)
|
|
1959
1765
|
: undefined, onPrimaryButtonClick: topUpOptions && topUpOptions?.length > 0
|
|
1960
1766
|
? topUpOptions[0].action
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as reactExports,
|
|
1
|
+
import { r as reactExports, F as getDefaultTokenImage, q as jsx } from './index-CcxHW36j.js';
|
|
2
2
|
|
|
3
3
|
function TokenImage({ src, name, environment, theme, defaultImage, ...forwardedProps }) {
|
|
4
4
|
const [error, setError] = reactExports.useState(false);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c3 as formatUnits, q as jsx, s as jsxs, dA as isDualVariantIcon, aK as MenuItem, t as Box, r as reactExports, u as useTranslation, aP as ViewContext, z as CryptoFiatContext, E as EventTargetContext, $ as CryptoFiatActions, dB as DEFAULT_TOKEN_SYMBOLS, cK as GasEstimateType, G as HeaderNavigation, H as Heading, y as Body, x as SimpleLayout, I as IMTBLWidgetEvents, V as ViewActions, K as orchestrationEvents, bG as r } from './index-CcxHW36j.js';
|
|
2
2
|
|
|
3
3
|
var BridgeWidgetViews;
|
|
4
4
|
(function (BridgeWidgetViews) {
|
|
@@ -16,32 +16,6 @@ var BridgeWidgetViews;
|
|
|
16
16
|
BridgeWidgetViews["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
|
|
17
17
|
})(BridgeWidgetViews || (BridgeWidgetViews = {}));
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* useMount hook to runs only once when the component mounts
|
|
21
|
-
* after mounting condition is met
|
|
22
|
-
*
|
|
23
|
-
* @param fn function to run
|
|
24
|
-
* @param shouldMount function to check mount condition
|
|
25
|
-
* @param deps dependencies to watch for changes
|
|
26
|
-
*/
|
|
27
|
-
const useMount = (fn, shouldMount, deps) => {
|
|
28
|
-
const isMounted = reactExports.useRef(false);
|
|
29
|
-
const shouldMountCheck = () => {
|
|
30
|
-
if (typeof shouldMount === 'function') {
|
|
31
|
-
return shouldMount();
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
reactExports.useEffect(() => {
|
|
36
|
-
if (isMounted.current)
|
|
37
|
-
return;
|
|
38
|
-
if (!shouldMountCheck())
|
|
39
|
-
return;
|
|
40
|
-
fn();
|
|
41
|
-
isMounted.current = true;
|
|
42
|
-
}, deps || []);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
19
|
var SwapWidgetViews;
|
|
46
20
|
(function (SwapWidgetViews) {
|
|
47
21
|
SwapWidgetViews["SWAP"] = "SWAP";
|
|
@@ -147,9 +121,8 @@ const TOOLKIT_BASE_URL = {
|
|
|
147
121
|
function TopUpView({ widgetEvent, checkout,
|
|
148
122
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
149
123
|
provider, // Keep this for future use
|
|
150
|
-
showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount,
|
|
124
|
+
showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, onCloseButtonClick, onBackButtonClick, heading, subheading, }) {
|
|
151
125
|
const { t } = useTranslation();
|
|
152
|
-
const { userJourney } = analytics;
|
|
153
126
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
154
127
|
const { cryptoFiatState, cryptoFiatDispatch } = reactExports.useContext(CryptoFiatContext);
|
|
155
128
|
const { conversions, fiatSymbol } = cryptoFiatState;
|
|
@@ -160,7 +133,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
160
133
|
const [, setBridgeFeesInFiat] = reactExports.useState('-.--');
|
|
161
134
|
const title = heading ? t(...heading) : t('views.TOP_UP_VIEW.header.title');
|
|
162
135
|
const description = subheading ? t(...subheading) : null;
|
|
163
|
-
const { page, track } = useAnalytics();
|
|
164
136
|
const isSwapAvailable = useAsyncMemo(async () => {
|
|
165
137
|
if (!checkout)
|
|
166
138
|
return undefined;
|
|
@@ -171,9 +143,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
171
143
|
return false;
|
|
172
144
|
}
|
|
173
145
|
}, [checkout]);
|
|
174
|
-
useMount(() => {
|
|
175
|
-
page({ userJourney, screen: 'TopUp' });
|
|
176
|
-
});
|
|
177
146
|
reactExports.useEffect(() => {
|
|
178
147
|
if (!cryptoFiatDispatch)
|
|
179
148
|
return;
|
|
@@ -206,15 +175,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
206
175
|
setOnRampFeesPercentage(onRampFees);
|
|
207
176
|
})();
|
|
208
177
|
}, [checkout !== undefined]);
|
|
209
|
-
const localTrack = (control, extras, controlType = 'Button') => {
|
|
210
|
-
track({
|
|
211
|
-
userJourney,
|
|
212
|
-
screen: 'TopUp',
|
|
213
|
-
control,
|
|
214
|
-
controlType,
|
|
215
|
-
extras,
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
178
|
const onClickSwap = () => {
|
|
219
179
|
if (widgetEvent === IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT) {
|
|
220
180
|
const data = {
|
|
@@ -231,7 +191,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
231
191
|
},
|
|
232
192
|
},
|
|
233
193
|
});
|
|
234
|
-
localTrack('Swap', { ...data, widgetEvent });
|
|
235
194
|
return;
|
|
236
195
|
}
|
|
237
196
|
const data = {
|
|
@@ -240,7 +199,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
240
199
|
amount: '',
|
|
241
200
|
};
|
|
242
201
|
orchestrationEvents.sendRequestSwapEvent(eventTarget, widgetEvent, data);
|
|
243
|
-
localTrack('Swap', { ...data, widgetEvent });
|
|
244
202
|
};
|
|
245
203
|
const onClickBridge = () => {
|
|
246
204
|
if (widgetEvent === IMTBLWidgetEvents.IMTBL_BRIDGE_WIDGET_EVENT) {
|
|
@@ -257,7 +215,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
257
215
|
},
|
|
258
216
|
},
|
|
259
217
|
});
|
|
260
|
-
localTrack('Bridge', { ...data, widgetEvent });
|
|
261
218
|
return;
|
|
262
219
|
}
|
|
263
220
|
const data = {
|
|
@@ -265,7 +222,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
265
222
|
amount: '',
|
|
266
223
|
};
|
|
267
224
|
orchestrationEvents.sendRequestBridgeEvent(eventTarget, widgetEvent, data);
|
|
268
|
-
localTrack('Bridge', { ...data, widgetEvent });
|
|
269
225
|
};
|
|
270
226
|
const onClickOnRamp = () => {
|
|
271
227
|
if (widgetEvent === IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT) {
|
|
@@ -282,7 +238,6 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
282
238
|
},
|
|
283
239
|
},
|
|
284
240
|
});
|
|
285
|
-
localTrack('OnRamp', { ...data, widgetEvent });
|
|
286
241
|
return;
|
|
287
242
|
}
|
|
288
243
|
const data = {
|
|
@@ -290,15 +245,9 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
290
245
|
amount: amount ?? '',
|
|
291
246
|
};
|
|
292
247
|
orchestrationEvents.sendRequestOnrampEvent(eventTarget, widgetEvent, data);
|
|
293
|
-
localTrack('OnRamp', { ...data, widgetEvent });
|
|
294
248
|
};
|
|
295
249
|
const onClickAdvancedOptions = () => {
|
|
296
250
|
const toolkitBaseUrl = TOOLKIT_BASE_URL[environment];
|
|
297
|
-
const data = {
|
|
298
|
-
tokenAddress: tokenAddress ?? '',
|
|
299
|
-
amount: amount ?? '',
|
|
300
|
-
};
|
|
301
|
-
localTrack('AdvancedOptions', { ...data, widgetEvent });
|
|
302
251
|
window.open(`${toolkitBaseUrl}/squid-bridge/`, '_blank');
|
|
303
252
|
};
|
|
304
253
|
const renderFees = (txt) => (jsx(Box, { sx: {
|
|
@@ -362,4 +311,4 @@ showOnrampOption, showSwapOption, showBridgeOption, tokenAddress, amount, analyt
|
|
|
362
311
|
: t(`${element.textConfigKey}.caption`), onClick: element.onClickEvent, renderFeeFunction: element.fee, isDisabled: !element.isAvailable }, t(`${element.textConfigKey}.heading`).toLowerCase()))) })] }) }));
|
|
363
312
|
}
|
|
364
313
|
|
|
365
|
-
export { BridgeWidgetViews as B, OnRampWidgetViews as O, SwapWidgetViews as S, TopUpView as T
|
|
314
|
+
export { BridgeWidgetViews as B, OnRampWidgetViews as O, SwapWidgetViews as S, TopUpView as T };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { T as TokenImage } from './TokenImage-
|
|
1
|
+
import { aa as hFlex, q as jsx, dn as motion, ac as _objectWithoutProperties, N as useTheme, r as reactExports, ae as _slicedToArray, ao as useGetSubcomponentChild, aj as merge, s as jsxs, dp as BaseClickable, a_ as ButtCon, as as SmartClone, dq as AnimatePresence, t as Box, w as Stack, dr as ClassNames, ab as _defineProperty, ds as getTertiaryButtonStyles, ap as flattenChildren, dt as isChildSubcomponent, az as Divider, a$ as TextInput, du as FormControlWrapper, u as useTranslation, aK as MenuItem, ay as Drawer, y as Body, aD as Fragment, dv as Select, bG as r, dw as DuoCon, H as Heading, v as Button, cB as retry, cI as NATIVE, aX as getTokenImageByAddress, aW as isNativeToken, di as DEFAULT_BALANCE_RETRY_POLICY, aG as isPassportProvider, dx as isMetaMaskProvider, Q as CloudImage, bZ as FooterLogo, R as getRemoteImage, cE as getChainNameById, cy as isWalletConnectProvider, cT as heroBackGroundStyles, cU as heroImageStyles, dy as heroImageBottomAlign } from './index-CcxHW36j.js';
|
|
2
|
+
import { T as TokenImage } from './TokenImage-BeUf_Ulv.js';
|
|
3
3
|
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -371,8 +371,7 @@ function CoinSelector({ heading, options, defaultTokenImage, optionsLoading, chi
|
|
|
371
371
|
return (jsxs(Drawer, { headerBarTitle: heading, size: "full", onCloseDrawer: handleCloseDrawer, visible: visible, bgOverlaySx: drawerBackground ? { background: drawerBackground } : undefined, children: [jsx(Drawer.Target, { children: children }), jsx(Drawer.Content, { children: jsxs(Box, { sx: selectOptionsContainerStyles, children: [optionsLoading && options.length === 0 && (jsxs(Box, { sx: selectOptionsLoadingIconStyles, children: [jsx(MenuItem, { shimmer: true, emphasized: true, testId: "balance-item-shimmer--1" }), jsx(MenuItem, { shimmer: true, emphasized: true, testId: "balance-item-shimmer--2" }), jsx(MenuItem, { shimmer: true, emphasized: true, testId: "balance-item-shimmer--3" })] })), !optionsLoading && options.length === 0 && (jsx(Body, { sx: { padding: 'base.spacing.x4' }, children: t('drawers.coinSelector.noCoins') })), !optionsLoading ? (jsxs(Fragment, { children: [jsx(TextInput, { sx: { marginBottom: 'base.spacing.x4', minWidth: '100%' }, testId: "search-text", onChange: (event) => handleOnChange(event), sizeVariant: "large", value: searchValue, inputMode: "search", placeholder: "name/symbol/contract address", onClearValue: () => setSearchValue(''), hideClearValueButton: false, autoFocus: true, children: jsx(TextInput.Icon, { icon: "Search" }) }), filteredOptions.map(({ onClick, icon, name, symbol, balance, id, testId, }) => (jsx(CoinSelectorOption, { id: id, testId: testId, onClick: onClick, icon: icon, name: name, symbol: symbol, balance: balance, defaultTokenImage: defaultTokenImage }, `${symbol}-${name}`)))] })) : null] }) })] }));
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
function SelectForm({ testId, options, optionsLoading, subtext, onSelectChange, textAlign, errorMessage, disabled, selectedOption, coinSelectorHeading, defaultTokenImage,
|
|
375
|
-
const { track } = useAnalytics();
|
|
374
|
+
function SelectForm({ testId, options, optionsLoading, subtext, onSelectChange, textAlign, errorMessage, disabled, selectedOption, coinSelectorHeading, defaultTokenImage, environment = r.PRODUCTION, theme, themeOverrides, }) {
|
|
376
375
|
const [coinSelectorOpen, setCoinSelectorOpen] = reactExports.useState(false);
|
|
377
376
|
const coinSelectorOptions = reactExports.useMemo(() => options.map((option) => ({
|
|
378
377
|
...option,
|
|
@@ -394,14 +393,7 @@ function SelectForm({ testId, options, optionsLoading, subtext, onSelectChange,
|
|
|
394
393
|
const filteredOption = options.find((o) => o.id === selectedOption) ?? selectedOption;
|
|
395
394
|
const openCoinSelector = reactExports.useCallback(() => {
|
|
396
395
|
setCoinSelectorOpen(true);
|
|
397
|
-
|
|
398
|
-
userJourney,
|
|
399
|
-
screen,
|
|
400
|
-
control,
|
|
401
|
-
controlType: 'Select',
|
|
402
|
-
action: 'Opened',
|
|
403
|
-
});
|
|
404
|
-
}, [setCoinSelectorOpen, track]);
|
|
396
|
+
}, [setCoinSelectorOpen]);
|
|
405
397
|
return (jsxs(Box, { children: [jsx(CoinSelector, { heading: coinSelectorHeading, options: coinSelectorOptions, defaultTokenImage: defaultTokenImage, optionsLoading: optionsLoading ?? false, visible: coinSelectorOpen, onCloseDrawer: () => setCoinSelectorOpen(false), drawerBackground: themeOverrides.drawerBackground }), jsx(FormControlWrapper, { testId: `${testId}-select-control`, textAlign: textAlign ?? 'left', subtext: errorMessage ? undefined : subtext, isErrored: !!errorMessage, errorMessage: errorMessage, children: jsx(Select, { testId: `${testId}-select`, size: "large", defaultLabel: "Select token", targetClickOveride: openCoinSelector, selectedOption: getSelectedOption(), sx: { minw: '170px' }, children: filteredOption && (jsxs(Select.Option, { optionKey: filteredOption.id, testId: filteredOption.testId,
|
|
406
398
|
// select cannot currently be disabled so disabling at the option level for now
|
|
407
399
|
disabled: disabled, children: [!filteredOption.icon && (jsx(Select.Option.Icon, { icon: "Coins", variant: "bold" })), filteredOption.icon && (jsx(Select.Option.FramedImage, { use: (jsx(TokenImage, { environment: environment, theme: theme, src: filteredOption.icon, name: filteredOption.name })), circularFrame: true, sx: { background: 'base.color.translucent.standard.100' } })), jsx(Select.Option.Label, { children: filteredOption.symbol })] }, filteredOption.id)) }) })] }));
|