@imtbl/checkout-widgets 2.24.7 → 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-aAZMavtt.js → AddTokensWidget-CIR8BF_I.js} +24 -297
- package/dist/browser/{BridgeWidget-CWWCr015.js → BridgeWidget-C5Uljhhx.js} +13 -294
- package/dist/browser/{CommerceWidget-B36D9SAt.js → CommerceWidget-CeBBYCbK.js} +17 -47
- package/dist/browser/{FeesBreakdown-WeqZxAT6.js → FeesBreakdown-BU4haotD.js} +1 -1
- package/dist/browser/{OnRampWidget-DpxysET8.js → OnRampWidget-Ccvb3QkT.js} +5 -80
- package/dist/browser/{SaleWidget-CMkn5eAJ.js → SaleWidget-CPARFlzv.js} +61 -219
- package/dist/browser/{SpendingCapHero-BuWrv_Rb.js → SpendingCapHero-B-0YYZho.js} +1 -1
- package/dist/browser/{SwapWidget-CEnCMtGs.js → SwapWidget-ujE6uX-N.js} +12 -206
- package/dist/browser/{TokenImage-EqfdG328.js → TokenImage-BeUf_Ulv.js} +1 -1
- package/dist/browser/{TopUpView-D3BxE8R3.js → TopUpView-GMv3360Q.js} +3 -54
- package/dist/browser/{WalletApproveHero-C_8es7r9.js → WalletApproveHero-BJi7ufqM.js} +4 -12
- package/dist/browser/{WalletWidget-Czye7zS5.js → WalletWidget-BABrqsfd.js} +4 -96
- package/dist/browser/{index-WfurfROg.js → index-CcxHW36j.js} +1275 -9717
- package/dist/browser/{index-CcLq9am4.js → index-Cp1w6map.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{useInterval-CrmneADn.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-BcwQjFJ1.js +0 -105
- package/dist/browser/index-BSnE_6oQ.js +0 -27
- package/dist/browser/index-CKGatDzP.js +0 -60
- package/dist/browser/index-Cnt0i-EY.js +0 -65
- package/dist/browser/index-DLXeqRzN.js +0 -65
- package/dist/browser/index-MANbU_qG.js +0 -5634
- package/dist/browser/index-lHICKwNF.js +0 -446
- package/dist/browser/index.umd-Cn1Q502t.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,16 +1,16 @@
|
|
|
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, A as AddTokensEventType, B as BridgeEventType, O as OnRampEventType, f as SaleEventType, g as PurchaseEventType, T as TransferEventType, h as OrchestrationEventType, r as reactExports, V as ViewActions, p as parseUnits, i as formatZeroAmount, j as calculateCryptoToFiat, k as Contract, l as TokenFilterTypes, u as useTranslation, m as dist, n as getRemoteRive, o as BlockExplorerService, q as jsx, s as jsxs, t as Box, H as Heading, L as Link, v as Button, w as Stack, x as SimpleLayout, y as Body,
|
|
2
|
-
import { S as SelectInput, a as SwapWidget } from './SwapWidget-
|
|
3
|
-
import { B as BridgeWidget } from './BridgeWidget-
|
|
4
|
-
import OnRampWidget from './OnRampWidget-
|
|
5
|
-
import WalletWidget from './WalletWidget-
|
|
6
|
-
import SaleWidget from './SaleWidget-
|
|
7
|
-
import AddTokensWidget from './AddTokensWidget-
|
|
8
|
-
import { g as getAllowedBalances, T as TextInputForm } from './WalletApproveHero-
|
|
9
|
-
import './useInterval-
|
|
10
|
-
import './TopUpView-
|
|
11
|
-
import './FeesBreakdown-
|
|
12
|
-
import './SpendingCapHero-
|
|
13
|
-
import './TokenImage-
|
|
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, A as AddTokensEventType, B as BridgeEventType, O as OnRampEventType, f as SaleEventType, g as PurchaseEventType, T as TransferEventType, h as OrchestrationEventType, r as reactExports, V as ViewActions, p as parseUnits, i as formatZeroAmount, j as calculateCryptoToFiat, k as Contract, l as TokenFilterTypes, u as useTranslation, m as dist, n as getRemoteRive, o as BlockExplorerService, q as jsx, s as jsxs, t as Box, H as Heading, L as Link, v as Button, w as Stack, x as SimpleLayout, y as Body, E as EventTargetContext, z as CryptoFiatContext, D as tokenValueFormat, F as getDefaultTokenImage, G as HeaderNavigation, J as sendCloseWidgetEvent, K as orchestrationEvents$1, M as amountInputValidation, N as useTheme, Q as CloudImage, R as getRemoteImage, U as CryptoFiatProvider, X as ConnectLoaderContext, Y as isAddress, Z as isError, _ as LoadingView, $ as CryptoFiatActions, a0 as useViewState, a1 as useEventTargetState, a2 as commerceFlows, a3 as SharedViews, a4 as ErrorView, a5 as ConnectWidget, a6 as ProvidersContextProvider, a7 as PurchaseWidget, a8 as ConnectLoader, a9 as ViewContextProvider } from './index-CcxHW36j.js';
|
|
2
|
+
import { S as SelectInput, a as SwapWidget } from './SwapWidget-ujE6uX-N.js';
|
|
3
|
+
import { B as BridgeWidget } from './BridgeWidget-C5Uljhhx.js';
|
|
4
|
+
import OnRampWidget from './OnRampWidget-Ccvb3QkT.js';
|
|
5
|
+
import WalletWidget from './WalletWidget-BABrqsfd.js';
|
|
6
|
+
import SaleWidget from './SaleWidget-CPARFlzv.js';
|
|
7
|
+
import AddTokensWidget from './AddTokensWidget-CIR8BF_I.js';
|
|
8
|
+
import { g as getAllowedBalances, T as TextInputForm } from './WalletApproveHero-BJi7ufqM.js';
|
|
9
|
+
import './useInterval-DbCsm_gG.js';
|
|
10
|
+
import './TopUpView-GMv3360Q.js';
|
|
11
|
+
import './FeesBreakdown-BU4haotD.js';
|
|
12
|
+
import './SpendingCapHero-B-0YYZho.js';
|
|
13
|
+
import './TokenImage-BeUf_Ulv.js';
|
|
14
14
|
|
|
15
15
|
const sendCheckoutEvent = (eventTarget, detail) => {
|
|
16
16
|
const event = new CustomEvent(IMTBLWidgetEvents.IMTBL_COMMERCE_WIDGET_EVENT, { detail });
|
|
@@ -720,7 +720,6 @@ function AwaitingApproval({ config }) {
|
|
|
720
720
|
|
|
721
721
|
function TransferForm({ config, viewState, setViewState, onSend, showBackButton, showHeader, title, coinAmountTitle, }) {
|
|
722
722
|
const { t } = useTranslation();
|
|
723
|
-
const { track } = useAnalytics();
|
|
724
723
|
const { eventTargetState: { eventTarget } } = reactExports.useContext(EventTargetContext);
|
|
725
724
|
const { cryptoFiatState } = reactExports.useContext(CryptoFiatContext);
|
|
726
725
|
const tokenOptions = reactExports.useMemo(() => viewState.allowedBalances.map((tokenBalance) => ({
|
|
@@ -738,35 +737,21 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
738
737
|
const defaultTokenImage = reactExports.useMemo(() => getDefaultTokenImage(viewState.checkout.config.environment, config.theme), [viewState.checkout.config.environment, config.theme]);
|
|
739
738
|
const fromFiatValue = reactExports.useMemo(() => calculateCryptoToFiat(viewState.amount, token?.symbol || '', cryptoFiatState.conversions), [viewState.amount, token, cryptoFiatState.conversions]);
|
|
740
739
|
const handleTokenChange = reactExports.useCallback((optionKey) => {
|
|
741
|
-
track({
|
|
742
|
-
screen: 'TransferToken',
|
|
743
|
-
userJourney: UserJourney.TRANSFER,
|
|
744
|
-
control: 'SelectToken',
|
|
745
|
-
controlType: 'Select',
|
|
746
|
-
extras: { token: optionKey },
|
|
747
|
-
});
|
|
748
740
|
if (typeof optionKey !== 'string')
|
|
749
741
|
throw new Error('Invalid token address');
|
|
750
742
|
setViewState((s) => ({ ...s, tokenAddress: optionKey, amountError: '' }));
|
|
751
|
-
}, [setViewState
|
|
743
|
+
}, [setViewState]);
|
|
752
744
|
const handleMaxButtonClick = reactExports.useCallback(() => {
|
|
753
745
|
if (!token)
|
|
754
746
|
throw new Error('Token not found');
|
|
755
747
|
if (!token.balance)
|
|
756
748
|
throw new Error('Token balance not found');
|
|
757
|
-
track({
|
|
758
|
-
screen: 'TransferToken',
|
|
759
|
-
userJourney: UserJourney.TRANSFER,
|
|
760
|
-
control: 'Max',
|
|
761
|
-
controlType: 'Button',
|
|
762
|
-
extras: { token: token.id, amount: token.balance.fullBalance },
|
|
763
|
-
});
|
|
764
749
|
setViewState((s) => {
|
|
765
750
|
if (!token.balance)
|
|
766
751
|
throw new Error('Token balance not found');
|
|
767
752
|
return { ...s, amount: token.balance.fullBalance };
|
|
768
753
|
});
|
|
769
|
-
}, [token, setViewState
|
|
754
|
+
}, [token, setViewState]);
|
|
770
755
|
const handleRecipientAddressChange = reactExports.useCallback((value) => {
|
|
771
756
|
setViewState((s) => ({ ...s, toAddress: value, toAddressError: '' }));
|
|
772
757
|
}, [setViewState]);
|
|
@@ -786,7 +771,7 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
786
771
|
mt: 'base.spacing.x6',
|
|
787
772
|
mx: 'base.spacing.x4',
|
|
788
773
|
mb: 'base.spacing.x10',
|
|
789
|
-
}, children: [jsxs(Stack, { gap: "base.spacing.x9", children: [jsxs(Stack, { gap: "base.spacing.x1", children: [jsx(Heading, { size: "xSmall", children: coinAmountTitle }), jsx(SelectInput, { testId: "transfer-token-select", options: tokenOptions, textInputValue: viewState.amount, textInputPlaceholder: "0", textInputTextAlign: "right", coinSelectorHeading: t('views.TRANSFER.form.coinSelectorHeading'), textInputMaxButtonClick: token ? handleMaxButtonClick : undefined, textInputValidator: amountInputValidation, textInputErrorMessage: viewState.amountError, selectSubtext: selectSubtext, textInputSubtext: `${t('views.TRANSFER.content.fiatPricePrefix')} $${formatZeroAmount(fromFiatValue, true)}`, onTextInputChange: handleAmountChange, onSelectChange: handleTokenChange, selectedOption: token?.id, defaultTokenImage: defaultTokenImage,
|
|
774
|
+
}, children: [jsxs(Stack, { gap: "base.spacing.x9", children: [jsxs(Stack, { gap: "base.spacing.x1", children: [jsx(Heading, { size: "xSmall", children: coinAmountTitle }), jsx(SelectInput, { testId: "transfer-token-select", options: tokenOptions, textInputValue: viewState.amount, textInputPlaceholder: "0", textInputTextAlign: "right", coinSelectorHeading: t('views.TRANSFER.form.coinSelectorHeading'), textInputMaxButtonClick: token ? handleMaxButtonClick : undefined, textInputValidator: amountInputValidation, textInputErrorMessage: viewState.amountError, selectSubtext: selectSubtext, textInputSubtext: `${t('views.TRANSFER.content.fiatPricePrefix')} $${formatZeroAmount(fromFiatValue, true)}`, onTextInputChange: handleAmountChange, onSelectChange: handleTokenChange, selectedOption: token?.id, defaultTokenImage: defaultTokenImage, theme: config.theme, themeOverrides: config.themeOverrides })] }), jsxs(Stack, { gap: "base.spacing.x1", children: [jsx(Heading, { size: "xSmall", children: t('views.TRANSFER.form.toAddressHeading') }), jsx(TextInputForm, { testId: "transfer-to-address-input", value: viewState.toAddress, placeholder: "0x", validator: validatePartialAddress, onTextInputChange: handleRecipientAddressChange, errorMessage: viewState.toAddressError })] })] }), jsxs(Box, { children: [jsx(Body, { rc: jsx("div", {}), size: "xSmall", weight: "bold", sx: { color: 'base.color.text.status.fatal.primary' }, children: t('views.TRANSFER.content.notAllExchangesSupportImmutableZkEVM') }), jsx(Body, { rc: jsx("div", {}), size: "xxSmall", weight: "regular", sx: { mb: 'base.spacing.x4' }, children: t('views.TRANSFER.content.notAllExchangesSupportImmutableZkEVMDescription') }), jsx(Button, { sx: { width: '100%' }, variant: "primary", size: "large", disabled: isButtonDisabled, onClick: onSend, children: t('views.TRANSFER.form.buttonText') })] })] }) }));
|
|
790
775
|
}
|
|
791
776
|
|
|
792
777
|
const sendSuccessEvent = (eventTarget, transactionHash) => {
|
|
@@ -839,7 +824,6 @@ function TransferWidgetInner(props) {
|
|
|
839
824
|
const { t } = useTranslation();
|
|
840
825
|
const { cryptoFiatDispatch } = reactExports.useContext(CryptoFiatContext);
|
|
841
826
|
const { eventTargetState: { eventTarget } } = reactExports.useContext(EventTargetContext);
|
|
842
|
-
const { track } = useAnalytics();
|
|
843
827
|
const { connectLoaderState: { checkout, provider }, } = reactExports.useContext(ConnectLoaderContext);
|
|
844
828
|
const [viewState, setViewState] = reactExports.useState({
|
|
845
829
|
type: 'INITIALISING',
|
|
@@ -877,13 +861,6 @@ function TransferWidgetInner(props) {
|
|
|
877
861
|
const onSend = reactExports.useCallback(async () => {
|
|
878
862
|
if (viewState.type !== 'FORM')
|
|
879
863
|
throw new Error('Unexpected state');
|
|
880
|
-
track({
|
|
881
|
-
screen: 'TransferToken',
|
|
882
|
-
userJourney: UserJourney.TRANSFER,
|
|
883
|
-
control: 'Send',
|
|
884
|
-
controlType: 'Button',
|
|
885
|
-
extras: { token: viewState.tokenAddress, amount: viewState.amount },
|
|
886
|
-
});
|
|
887
864
|
if (!isAddress(viewState.toAddress)) {
|
|
888
865
|
setViewState((s) => ({ ...s, toAddressError: 'Invalid wallet address' }));
|
|
889
866
|
return;
|
|
@@ -945,13 +922,6 @@ function TransferWidgetInner(props) {
|
|
|
945
922
|
&& e.error
|
|
946
923
|
&& 'code' in e.error
|
|
947
924
|
&& e.error.code === TRANSACTION_CANCELLED_ERROR_CODE) {
|
|
948
|
-
track({
|
|
949
|
-
screen: 'TransferToken',
|
|
950
|
-
userJourney: UserJourney.TRANSFER,
|
|
951
|
-
control: 'TranactionCancel',
|
|
952
|
-
controlType: 'Event',
|
|
953
|
-
extras: { token: viewState.tokenAddress, amount: viewState.amount },
|
|
954
|
-
});
|
|
955
925
|
sendRejectedEvent(eventTarget, 'Transaction cancelled');
|
|
956
926
|
}
|
|
957
927
|
else {
|
|
@@ -961,7 +931,7 @@ function TransferWidgetInner(props) {
|
|
|
961
931
|
setViewState({ ...viewState, type: 'FORM' }); // TODO: We should be showing a failed view here
|
|
962
932
|
}
|
|
963
933
|
}
|
|
964
|
-
}, [viewState, eventTarget
|
|
934
|
+
}, [viewState, eventTarget]);
|
|
965
935
|
switch (viewState.type) {
|
|
966
936
|
case 'INITIALISING':
|
|
967
937
|
return jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cn as axios, dz as IMMUTABLE_API_BASE_URL, s as jsxs, q as jsx, y as Body, bz as PriceDisplay, t as Box, u as useTranslation, ay as Drawer, aK as MenuItem, aD as Fragment, az as Divider, D as tokenValueFormat, i as formatZeroAmount, bZ as FooterLogo } from './index-CcxHW36j.js';
|
|
2
2
|
|
|
3
3
|
const fetchRiskAssessmentV2 = async (assessmentData, config) => {
|
|
4
4
|
const result = Object.fromEntries(assessmentData.map((data) => [data.address.toLowerCase(), { sanctioned: false }]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as reactExports,
|
|
2
|
-
import { O as OnRampWidgetViews, T as TopUpView } from './TopUpView-
|
|
3
|
-
import { S as SpendingCapHero } from './SpendingCapHero-
|
|
1
|
+
import { r as reactExports, X as ConnectLoaderContext, E as EventTargetContext, u as useTranslation, aP as ViewContext, a3 as SharedViews, V as ViewActions, q as jsx, x as SimpleLayout, G as HeaderNavigation, d0 as sendOnRampWidgetCloseEvent, K as orchestrationEvents, I as IMTBLWidgetEvents, t as Box, d1 as url, d2 as TRANSAK_ORIGIN, d3 as ExchangeType, bZ as FooterLogo, s as jsxs, cV as SimpleTextBody, bC as viewReducer, bD as initialViewState, cI as NATIVE, _ as LoadingView, d4 as sendOnRampSuccessEvent, b_ as StatusType, c$ as StatusView, d5 as sendOnRampFailedEvent, bK as ServiceUnavailableErrorView } from './index-CcxHW36j.js';
|
|
2
|
+
import { O as OnRampWidgetViews, T as TopUpView } from './TopUpView-GMv3360Q.js';
|
|
3
|
+
import { S as SpendingCapHero } from './SpendingCapHero-B-0YYZho.js';
|
|
4
4
|
|
|
5
5
|
const containerStyle = (showIframe) => ({
|
|
6
6
|
position: 'relative',
|
|
@@ -50,15 +50,6 @@ function useWidgetUrl(checkout, provider, tokenAddress, tokenAmount, passport, s
|
|
|
50
50
|
}, [checkout, provider, tokenAddress, tokenAmount, passport, showMenu, customSubTitle]);
|
|
51
51
|
return widgetUrl;
|
|
52
52
|
}
|
|
53
|
-
function useWalletAddress(provider) {
|
|
54
|
-
const [userWalletAddress, setUserWalletAddress] = reactExports.useState(undefined);
|
|
55
|
-
reactExports.useEffect(() => {
|
|
56
|
-
if (!provider)
|
|
57
|
-
return;
|
|
58
|
-
provider.getSigner().then((signer) => signer.getAddress()).then(setUserWalletAddress);
|
|
59
|
-
}, [provider]);
|
|
60
|
-
return userWalletAddress;
|
|
61
|
-
}
|
|
62
53
|
function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, showBackButton, showMenu, customTitle, customSubTitle, showHeader = true, }) {
|
|
63
54
|
const { connectLoaderState } = reactExports.useContext(ConnectLoaderContext);
|
|
64
55
|
const { checkout, provider } = connectLoaderState;
|
|
@@ -66,76 +57,11 @@ function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, showBackB
|
|
|
66
57
|
const { t } = useTranslation();
|
|
67
58
|
const { viewState, viewDispatch } = reactExports.useContext(ViewContext);
|
|
68
59
|
const widgetUrl = useWidgetUrl(checkout, provider, tokenAddress, tokenAmount, passport, showMenu, customSubTitle);
|
|
69
|
-
const userWalletAddress = useWalletAddress(provider);
|
|
70
60
|
const eventTimer = reactExports.useRef();
|
|
71
|
-
const isPassport = !!passport && isPassportProvider(provider);
|
|
72
61
|
const openedFromTopUpView = reactExports.useMemo(() => viewState.history.length > 2
|
|
73
62
|
&& viewState.history[viewState.history.length - 2].type
|
|
74
63
|
=== SharedViews.TOP_UP_VIEW, [viewState.history]);
|
|
75
64
|
const showBack = showBackButton || openedFromTopUpView;
|
|
76
|
-
const { track } = useAnalytics();
|
|
77
|
-
const trackSegmentEvents = reactExports.useCallback(async (event, walletAddress) => {
|
|
78
|
-
const miscProps = {
|
|
79
|
-
userId: walletAddress.toLowerCase(),
|
|
80
|
-
isPassportWallet: isPassport,
|
|
81
|
-
};
|
|
82
|
-
switch (event.event_id) {
|
|
83
|
-
case TransakEvents.TRANSAK_WIDGET_OPEN:
|
|
84
|
-
track({
|
|
85
|
-
userJourney: UserJourney.ON_RAMP,
|
|
86
|
-
screen: 'InputScreen',
|
|
87
|
-
control: 'TransakWidgetOpen',
|
|
88
|
-
controlType: 'IframeEvent',
|
|
89
|
-
extras: { ...miscProps },
|
|
90
|
-
}); // checkoutOnRampInputScreen_TransakWidgetOpenIframeEvent
|
|
91
|
-
break;
|
|
92
|
-
case TransakEvents.TRANSAK_ORDER_CREATED:
|
|
93
|
-
track({
|
|
94
|
-
userJourney: UserJourney.ON_RAMP,
|
|
95
|
-
screen: 'InputScreen',
|
|
96
|
-
control: 'OrderCreated',
|
|
97
|
-
controlType: 'IframeEvent',
|
|
98
|
-
extras: { ...miscProps },
|
|
99
|
-
}); // checkoutOnRampInputScreen_OrderCreatedIframeEvent
|
|
100
|
-
break;
|
|
101
|
-
case TransakEvents.TRANSAK_ORDER_SUCCESSFUL:
|
|
102
|
-
if (event.data.status === TransakStatuses.PROCESSING) {
|
|
103
|
-
// user paid
|
|
104
|
-
track({
|
|
105
|
-
userJourney: UserJourney.ON_RAMP,
|
|
106
|
-
screen: 'OrderInProgress',
|
|
107
|
-
control: 'PaymentProcessing',
|
|
108
|
-
controlType: 'IframeEvent',
|
|
109
|
-
extras: {
|
|
110
|
-
...miscProps,
|
|
111
|
-
transactionHash: event.data.transactionHash,
|
|
112
|
-
},
|
|
113
|
-
}); // checkoutOnRampOrderInProgress_PaymentProcessingIframeEvent
|
|
114
|
-
}
|
|
115
|
-
if (event.data.status === TransakStatuses.COMPLETED) {
|
|
116
|
-
track({
|
|
117
|
-
userJourney: UserJourney.ON_RAMP,
|
|
118
|
-
screen: 'Success',
|
|
119
|
-
control: 'PaymentCompleted',
|
|
120
|
-
controlType: 'IframeEvent',
|
|
121
|
-
extras: {
|
|
122
|
-
...miscProps,
|
|
123
|
-
transactionHash: event.data.transactionHash,
|
|
124
|
-
},
|
|
125
|
-
}); // checkoutOnRampSuccess_PaymentCompletedIframeEvent
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case TransakEvents.TRANSAK_ORDER_FAILED: // payment failed
|
|
129
|
-
track({
|
|
130
|
-
userJourney: UserJourney.ON_RAMP,
|
|
131
|
-
screen: 'Failure',
|
|
132
|
-
control: 'PaymentFailed',
|
|
133
|
-
controlType: 'IframeEvent',
|
|
134
|
-
extras: { ...miscProps },
|
|
135
|
-
}); // checkoutOnRampFailure_PaymentFailedIframeEvent
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}, [isPassport, track]);
|
|
139
65
|
const transakEventHandler = reactExports.useCallback((event) => {
|
|
140
66
|
if (eventTimer.current)
|
|
141
67
|
clearTimeout(eventTimer.current);
|
|
@@ -219,7 +145,6 @@ function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, showBackB
|
|
|
219
145
|
if (event.source === domIframe.contentWindow
|
|
220
146
|
&& host
|
|
221
147
|
&& TRANSAK_ORIGIN.includes(host)) {
|
|
222
|
-
trackSegmentEvents(event.data, userWalletAddress ?? '');
|
|
223
148
|
transakEventHandler(event.data);
|
|
224
149
|
}
|
|
225
150
|
};
|
|
@@ -228,7 +153,7 @@ function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, showBackB
|
|
|
228
153
|
return () => {
|
|
229
154
|
window.removeEventListener('message', handleTransakEvents);
|
|
230
155
|
};
|
|
231
|
-
}, [
|
|
156
|
+
}, [transakEventHandler]);
|
|
232
157
|
return (jsx(Box, { sx: boxMainStyle(showIframe), children: jsx(SimpleLayout, { header: showHeader ? (jsx(HeaderNavigation, { title: customTitle ?? t('views.ONRAMP.header.title'), onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget), showBack: showBack, onBackButtonClick: () => {
|
|
233
158
|
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT, {});
|
|
234
159
|
} })) : undefined, footerBackgroundColor: "base.color.translucent.emphasis.200", children: jsx(Box, { sx: containerStyle(showIframe), children: jsx("iframe", { title: "Transak", id: transakIframeId, src: widgetUrl, allow: "camera;microphone;fullscreen;payment", referrerPolicy: "strict-origin-when-cross-origin", style: {
|
|
@@ -288,7 +213,7 @@ function OnRampWidget({ amount, tokenAddress, config, showBackButton, onrampConf
|
|
|
288
213
|
},
|
|
289
214
|
});
|
|
290
215
|
}, statusType: StatusType.FAILURE, onCloseClick: () => sendOnRampWidgetCloseEvent(eventTarget), testId: "fail-view" })), (viewState.view.type !== OnRampWidgetViews.SUCCESS
|
|
291
|
-
&& viewState.view.type !== OnRampWidgetViews.FAIL) && (jsx(OnRampMain, { passport: checkout?.passport, showIframe: showIframe, tokenAmount: amount ?? viewState.view.data?.amount, tokenAddress: tknAddr ?? viewState.view.data?.tokenAddress, showBackButton: showBackButton, showMenu: onrampConfig?.showMenu, customTitle: onrampConfig?.customTitle, customSubTitle: onrampConfig?.customSubTitle, showHeader: onrampConfig?.showHeader })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx(TopUpView, {
|
|
216
|
+
&& viewState.view.type !== OnRampWidgetViews.FAIL) && (jsx(OnRampMain, { passport: checkout?.passport, showIframe: showIframe, tokenAmount: amount ?? viewState.view.data?.amount, tokenAddress: tknAddr ?? viewState.view.data?.tokenAddress, showBackButton: showBackButton, showMenu: onrampConfig?.showMenu, customTitle: onrampConfig?.customTitle, customSubTitle: onrampConfig?.customSubTitle, showHeader: onrampConfig?.showHeader })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx(TopUpView, { widgetEvent: IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT, checkout: checkout, provider: provider, showOnrampOption: isOnRampEnabled, showSwapOption: isSwapEnabled, showBridgeOption: isBridgeEnabled, onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget) })), viewState.view.type
|
|
292
217
|
=== SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ServiceUnavailableErrorView, { onCloseClick: () => sendOnRampWidgetCloseEvent(eventTarget) }))] }));
|
|
293
218
|
}
|
|
294
219
|
|