@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
|
@@ -44,7 +44,7 @@ type OrderSummaryProps = {
|
|
|
44
44
|
|
|
45
45
|
export function OrderSummary({ subView }: OrderSummaryProps) {
|
|
46
46
|
const { t } = useTranslation();
|
|
47
|
-
const { sendFailedEvent
|
|
47
|
+
const { sendFailedEvent } = useSaleEvent();
|
|
48
48
|
const {
|
|
49
49
|
fromTokenAddress,
|
|
50
50
|
collectionName,
|
|
@@ -138,7 +138,7 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
|
|
|
138
138
|
|
|
139
139
|
if (riskAssessment && isSingleAddressSanctioned(riskAssessment, address)) {
|
|
140
140
|
const error = new Error('Sanctioned address');
|
|
141
|
-
sendFailedEvent(error.message, {}, [],
|
|
141
|
+
sendFailedEvent(error.message, {}, [], { riskAssessment, paymentMethod });
|
|
142
142
|
|
|
143
143
|
viewDispatch({
|
|
144
144
|
payload: {
|
|
@@ -153,13 +153,6 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
sendProceedToPay(
|
|
157
|
-
SaleWidgetViews.ORDER_SUMMARY,
|
|
158
|
-
fundingBalance,
|
|
159
|
-
cryptoFiatState.conversions,
|
|
160
|
-
);
|
|
161
|
-
// checkoutPrimarySaleProceedToPay
|
|
162
|
-
|
|
163
156
|
if (type === FundingBalanceType.SUFFICIENT) {
|
|
164
157
|
signAndProceed(fundingItem.token.address);
|
|
165
158
|
return;
|
|
@@ -237,12 +230,6 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
|
|
|
237
230
|
);
|
|
238
231
|
setPaymentMethod(undefined);
|
|
239
232
|
|
|
240
|
-
// Send analytics event to track insufficient funds
|
|
241
|
-
sendInsufficientFunds(
|
|
242
|
-
SaleWidgetViews.ORDER_SUMMARY,
|
|
243
|
-
data,
|
|
244
|
-
);
|
|
245
|
-
|
|
246
233
|
closeHandover();
|
|
247
234
|
viewDispatch({
|
|
248
235
|
payload: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import { Box, LoadingOverlay } from '@biom3/react';
|
|
3
3
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
@@ -6,12 +6,10 @@ import { HeaderNavigation } from '../../../components/Header/HeaderNavigation';
|
|
|
6
6
|
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
7
7
|
import { WithCard } from '../components/WithCard';
|
|
8
8
|
import { useSaleContext } from '../context/SaleContextProvider';
|
|
9
|
-
import { SaleWidgetViews } from '../../../context/view-context/SaleViewContextTypes';
|
|
10
9
|
import { useSaleEvent } from '../hooks/useSaleEvents';
|
|
11
10
|
import { SaleErrorTypes } from '../types';
|
|
12
11
|
|
|
13
12
|
export function PayWithCard() {
|
|
14
|
-
const { sendPageView } = useSaleEvent();
|
|
15
13
|
const [initialised, setInitialised] = useState(false);
|
|
16
14
|
const {
|
|
17
15
|
goBackToPaymentMethods,
|
|
@@ -19,7 +17,7 @@ export function PayWithCard() {
|
|
|
19
17
|
signResponse: signData,
|
|
20
18
|
signTokenIds,
|
|
21
19
|
} = useSaleContext();
|
|
22
|
-
const {
|
|
20
|
+
const { sendCloseEvent, sendSuccessEvent } = useSaleEvent();
|
|
23
21
|
const { t } = useTranslation();
|
|
24
22
|
|
|
25
23
|
const onInit = () => setInitialised(true);
|
|
@@ -64,49 +62,10 @@ export function PayWithCard() {
|
|
|
64
62
|
transactionId: signData?.transactionId,
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
sendSuccessEvent(
|
|
68
|
-
sendCloseEvent(
|
|
65
|
+
sendSuccessEvent([], signTokenIds, details);
|
|
66
|
+
sendCloseEvent();
|
|
69
67
|
};
|
|
70
68
|
|
|
71
|
-
const onOrderCreated = (data: Record<string, unknown> = {}) => {
|
|
72
|
-
const {
|
|
73
|
-
id: orderId,
|
|
74
|
-
status: orderStatus,
|
|
75
|
-
cryptoAmount,
|
|
76
|
-
cryptoCurrency,
|
|
77
|
-
fiatAmount,
|
|
78
|
-
fiatAmountInUsd,
|
|
79
|
-
amountPaid,
|
|
80
|
-
totalFeeInFiat,
|
|
81
|
-
paymentOptionId: paymentOption,
|
|
82
|
-
userId,
|
|
83
|
-
userKycType,
|
|
84
|
-
walletAddress,
|
|
85
|
-
nftAssetInfo,
|
|
86
|
-
} = data;
|
|
87
|
-
const { nftDataBase64, quantity } = nftAssetInfo || ({} as any);
|
|
88
|
-
sendOrderCreated(SaleWidgetViews.PAY_WITH_CARD, {
|
|
89
|
-
orderId,
|
|
90
|
-
orderStatus,
|
|
91
|
-
cryptoAmount,
|
|
92
|
-
cryptoCurrency,
|
|
93
|
-
fiatAmount,
|
|
94
|
-
fiatAmountInUsd,
|
|
95
|
-
amountPaid,
|
|
96
|
-
totalFeeInFiat,
|
|
97
|
-
paymentOption,
|
|
98
|
-
userId,
|
|
99
|
-
userKycType,
|
|
100
|
-
walletAddress,
|
|
101
|
-
nftDataBase64,
|
|
102
|
-
quantity,
|
|
103
|
-
signData,
|
|
104
|
-
transactionId: signData?.transactionId,
|
|
105
|
-
}); // checkoutPrimarySalePayWithCard_OrderCreatedEvent
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
useEffect(() => sendPageView(SaleWidgetViews.PAY_WITH_CARD), []); // checkoutPrimarySalePayWithCardViewed
|
|
109
|
-
|
|
110
69
|
return (
|
|
111
70
|
<SimpleLayout
|
|
112
71
|
header={
|
|
@@ -141,7 +100,6 @@ export function PayWithCard() {
|
|
|
141
100
|
onInit={onInit}
|
|
142
101
|
onOrderFailed={onOrderFailed}
|
|
143
102
|
onOrderCompleted={onOrderProcessing}
|
|
144
|
-
onOrderCreated={onOrderCreated}
|
|
145
103
|
onOrderProcessing={onOrderProcessing}
|
|
146
104
|
/>
|
|
147
105
|
</Box>
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
import { useHandover } from '../../../lib/hooks/useHandover';
|
|
15
15
|
import { HandoverTarget } from '../../../context/handover-context/HandoverContext';
|
|
16
16
|
import { HandoverContent } from '../../../components/Handover/HandoverContent';
|
|
17
|
-
import { SaleWidgetViews } from '../../../context/view-context/SaleViewContextTypes';
|
|
18
17
|
import { isPassportProvider } from '../../../lib/provider';
|
|
19
18
|
import { errorToString, getRemoteRive } from '../../../lib/utils';
|
|
20
19
|
import { HandoverDuration } from '../../../context/handover-context/HandoverProvider';
|
|
@@ -55,7 +54,6 @@ export function PayWithCoins() {
|
|
|
55
54
|
|
|
56
55
|
const { t } = useTranslation();
|
|
57
56
|
const {
|
|
58
|
-
sendPageView,
|
|
59
57
|
sendTransactionSuccessEvent,
|
|
60
58
|
sendFailedEvent,
|
|
61
59
|
sendCloseEvent,
|
|
@@ -89,7 +87,7 @@ export function PayWithCoins() {
|
|
|
89
87
|
},
|
|
90
88
|
(error, txns) => {
|
|
91
89
|
const details = { transactionId: signResponse?.transactionId };
|
|
92
|
-
sendFailedEvent(error.toString(), error, txns,
|
|
90
|
+
sendFailedEvent(error.toString(), error, txns, details);
|
|
93
91
|
goToErrorView(error.type, error.data);
|
|
94
92
|
},
|
|
95
93
|
onTxnStepExecuteAll,
|
|
@@ -114,7 +112,7 @@ export function PayWithCoins() {
|
|
|
114
112
|
const details = {
|
|
115
113
|
transactionId: signResponse?.transactionId,
|
|
116
114
|
};
|
|
117
|
-
sendFailedEvent(err.toString(), err, txns,
|
|
115
|
+
sendFailedEvent(err.toString(), err, txns, details);
|
|
118
116
|
goToErrorView(err.type, err.data);
|
|
119
117
|
},
|
|
120
118
|
onTxnStepExecuteNextTransaction,
|
|
@@ -142,8 +140,6 @@ export function PayWithCoins() {
|
|
|
142
140
|
environment,
|
|
143
141
|
]);
|
|
144
142
|
|
|
145
|
-
useEffect(() => sendPageView(SaleWidgetViews.PAY_WITH_COINS), []); // checkoutPrimarySalePayWithCoinsViewed
|
|
146
|
-
|
|
147
143
|
useEffect(() => {
|
|
148
144
|
if (!provider || filteredTransactions.length === 0) return;
|
|
149
145
|
|
|
@@ -183,12 +179,11 @@ export function PayWithCoins() {
|
|
|
183
179
|
),
|
|
184
180
|
onClose: () => {
|
|
185
181
|
sendSuccessEvent(
|
|
186
|
-
SaleWidgetViews.SALE_SUCCESS,
|
|
187
182
|
executeResponse?.transactions,
|
|
188
183
|
signTokenIds,
|
|
189
184
|
details,
|
|
190
|
-
);
|
|
191
|
-
sendCloseEvent(
|
|
185
|
+
);
|
|
186
|
+
sendCloseEvent();
|
|
192
187
|
},
|
|
193
188
|
});
|
|
194
189
|
}
|
|
@@ -33,9 +33,7 @@ export function PaymentMethods() {
|
|
|
33
33
|
disabledPaymentTypes,
|
|
34
34
|
hideExcludedPaymentTypes,
|
|
35
35
|
} = useSaleContext();
|
|
36
|
-
const {
|
|
37
|
-
sendPageView, sendCloseEvent, sendSelectedPaymentMethod,
|
|
38
|
-
} = useSaleEvent();
|
|
36
|
+
const { sendCloseEvent, sendSelectedPaymentMethod } = useSaleEvent();
|
|
39
37
|
|
|
40
38
|
const handleOptionClick = (type: SalePaymentTypes) => {
|
|
41
39
|
setPaymentMethod(type);
|
|
@@ -43,7 +41,7 @@ export function PaymentMethods() {
|
|
|
43
41
|
|
|
44
42
|
useEffect(() => {
|
|
45
43
|
if (paymentMethod) {
|
|
46
|
-
sendSelectedPaymentMethod(paymentMethod
|
|
44
|
+
sendSelectedPaymentMethod(paymentMethod);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
if (
|
|
@@ -85,7 +83,6 @@ export function PaymentMethods() {
|
|
|
85
83
|
}
|
|
86
84
|
}, [paymentMethod]);
|
|
87
85
|
|
|
88
|
-
useEffect(() => sendPageView(SaleWidgetViews.PAYMENT_METHODS), []); // checkoutPrimarySalePaymentMethodsViewed
|
|
89
86
|
useEffect(() => {
|
|
90
87
|
if (!invalidParameters) return;
|
|
91
88
|
goToErrorView(SaleErrorTypes.INVALID_PARAMETERS);
|
|
@@ -96,7 +93,7 @@ export function PaymentMethods() {
|
|
|
96
93
|
testId="payment-methods"
|
|
97
94
|
header={(
|
|
98
95
|
<HeaderNavigation
|
|
99
|
-
onCloseButtonClick={
|
|
96
|
+
onCloseButtonClick={sendCloseEvent}
|
|
100
97
|
/>
|
|
101
98
|
)}
|
|
102
99
|
footer={<FooterLogo />}
|
|
@@ -90,7 +90,7 @@ export function SaleErrorView({
|
|
|
90
90
|
const details = {
|
|
91
91
|
transactionId: signResponse?.transactionId,
|
|
92
92
|
};
|
|
93
|
-
sendFailedEvent(err.toString(), err, txns,
|
|
93
|
+
sendFailedEvent(err.toString(), err, txns, details);
|
|
94
94
|
setCurrentErrorType(SaleErrorTypes.TRANSACTION_FAILED);
|
|
95
95
|
},
|
|
96
96
|
onTxnStepExecuteNextTransaction,
|
|
@@ -50,7 +50,6 @@ import { TopUpView } from '../../views/top-up/TopUpView';
|
|
|
50
50
|
import { ConnectLoaderContext } from '../../context/connect-loader-context/ConnectLoaderContext';
|
|
51
51
|
import { EventTargetContext } from '../../context/event-target-context/EventTargetContext';
|
|
52
52
|
import { getAllowedBalances } from '../../lib/balance';
|
|
53
|
-
import { UserJourney, useAnalytics } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
54
53
|
import { ServiceUnavailableErrorView } from '../../views/error/ServiceUnavailableErrorView';
|
|
55
54
|
import { ServiceUnavailableToRegionErrorView } from '../../views/error/ServiceUnavailableToRegionErrorView';
|
|
56
55
|
import { ServiceType } from '../../views/error/serviceTypes';
|
|
@@ -95,9 +94,6 @@ export default function SwapWidget({
|
|
|
95
94
|
history: [],
|
|
96
95
|
});
|
|
97
96
|
const [swapState, swapDispatch] = useReducer(swapReducer, initialSwapState);
|
|
98
|
-
|
|
99
|
-
const { page } = useAnalytics();
|
|
100
|
-
|
|
101
97
|
const [errorViewLoading, setErrorViewLoading] = useState(false);
|
|
102
98
|
|
|
103
99
|
const swapReducerValues = useMemo(
|
|
@@ -281,16 +277,6 @@ export default function SwapWidget({
|
|
|
281
277
|
statusText={t('views.SWAP.success.text')}
|
|
282
278
|
actionText={t('views.SWAP.success.actionText')}
|
|
283
279
|
onRenderEvent={() => {
|
|
284
|
-
page({
|
|
285
|
-
userJourney: UserJourney.SWAP,
|
|
286
|
-
screen: 'SwapSuccess',
|
|
287
|
-
extras: {
|
|
288
|
-
fromTokenAddress: viewState.view.data?.fromTokenAddress,
|
|
289
|
-
fromAmount: viewState.view.data?.fromAmount,
|
|
290
|
-
toTokenAddress: viewState.view.data?.toTokenAddress,
|
|
291
|
-
toAmount: viewState.view.data?.toAmount,
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
280
|
sendSwapSuccessEvent(
|
|
295
281
|
eventTarget,
|
|
296
282
|
(viewState.view as SwapSuccessView).data.transactionHash,
|
|
@@ -306,10 +292,6 @@ export default function SwapWidget({
|
|
|
306
292
|
statusText={t('views.SWAP.failed.text')}
|
|
307
293
|
actionText={t('views.SWAP.failed.actionText')}
|
|
308
294
|
onRenderEvent={() => {
|
|
309
|
-
page({
|
|
310
|
-
userJourney: UserJourney.SWAP,
|
|
311
|
-
screen: 'SwapFailed',
|
|
312
|
-
});
|
|
313
295
|
sendSwapFailedEvent(eventTarget, 'Transaction failed');
|
|
314
296
|
}}
|
|
315
297
|
onActionClick={() => {
|
|
@@ -335,11 +317,6 @@ export default function SwapWidget({
|
|
|
335
317
|
statusText={t('views.SWAP.rejected.text')}
|
|
336
318
|
actionText={t('views.SWAP.rejected.actionText')}
|
|
337
319
|
onRenderEvent={() => {
|
|
338
|
-
page({
|
|
339
|
-
userJourney: UserJourney.SWAP,
|
|
340
|
-
screen: 'PriceSurge',
|
|
341
|
-
extras: viewState.view.data,
|
|
342
|
-
});
|
|
343
320
|
sendSwapRejectedEvent(eventTarget, 'Price surge');
|
|
344
321
|
}}
|
|
345
322
|
onActionClick={() => {
|
|
@@ -392,7 +369,6 @@ export default function SwapWidget({
|
|
|
392
369
|
)}
|
|
393
370
|
{viewState.view.type === SharedViews.TOP_UP_VIEW && (
|
|
394
371
|
<TopUpView
|
|
395
|
-
analytics={{ userJourney: UserJourney.SWAP }}
|
|
396
372
|
checkout={checkout}
|
|
397
373
|
provider={provider}
|
|
398
374
|
widgetEvent={IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT}
|
|
@@ -13,7 +13,6 @@ import { Base } from '../BaseWidgetRoot';
|
|
|
13
13
|
import { ConnectLoader, ConnectLoaderParams } from '../../components/ConnectLoader/ConnectLoader';
|
|
14
14
|
import { isValidAddress, isValidAmount, isValidWalletProvider } from '../../lib/validations/widgetValidators';
|
|
15
15
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
16
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
17
16
|
import { LoadingView } from '../../views/loading/LoadingView';
|
|
18
17
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
19
18
|
import { sendSwapWidgetCloseEvent } from './SwapWidgetEvents';
|
|
@@ -89,35 +88,35 @@ export class Swap extends Base<WidgetType.SWAP> {
|
|
|
89
88
|
|
|
90
89
|
this.reactRoot!.render(
|
|
91
90
|
<React.StrictMode>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
91
|
+
|
|
92
|
+
<ThemeProvider id="swap-container" config={this.strongConfig()}>
|
|
93
|
+
<HandoverProvider>
|
|
94
|
+
<ConnectLoader
|
|
95
|
+
params={connectLoaderParams}
|
|
96
|
+
widgetConfig={this.strongConfig()}
|
|
97
|
+
closeEvent={() => sendSwapWidgetCloseEvent(window)}
|
|
98
|
+
>
|
|
99
|
+
<Suspense fallback={<LoadingView loadingText={t('views.LOADING_VIEW.text')} />}>
|
|
100
|
+
<SwapWidget
|
|
101
|
+
fromTokenAddress={this.parameters.fromTokenAddress}
|
|
102
|
+
toTokenAddress={this.parameters.toTokenAddress}
|
|
103
|
+
amount={this.parameters.amount}
|
|
104
|
+
config={this.strongConfig()}
|
|
105
|
+
autoProceed={this.parameters.autoProceed}
|
|
106
|
+
direction={this.parameters.direction ?? SwapDirection.FROM}
|
|
107
|
+
showBackButton={this.parameters.showBackButton}
|
|
108
|
+
walletProviderName={this.parameters.walletProviderName}
|
|
109
|
+
swapConfig={{
|
|
110
|
+
customTitle: this.properties.config?.customTitle,
|
|
111
|
+
customSubTitle: this.properties.config?.customSubTitle,
|
|
112
|
+
showHeader: this.properties.config?.showHeader,
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</Suspense>
|
|
116
|
+
</ConnectLoader>
|
|
117
|
+
</HandoverProvider>
|
|
118
|
+
</ThemeProvider>
|
|
119
|
+
|
|
121
120
|
</React.StrictMode>,
|
|
122
121
|
);
|
|
123
122
|
}
|
|
@@ -15,7 +15,6 @@ import { useTranslation } from 'react-i18next';
|
|
|
15
15
|
import { Environment } from '@imtbl/config';
|
|
16
16
|
import { formatUnits, parseEther, parseUnits } from 'ethers';
|
|
17
17
|
import { motion } from 'framer-motion';
|
|
18
|
-
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
19
18
|
import { NetworkSwitchDrawer } from '../../../components/NetworkSwitchDrawer/NetworkSwitchDrawer';
|
|
20
19
|
import { amountInputValidation as textInputValidator } from '../../../lib/validations/amountInputValidations';
|
|
21
20
|
import { SwapContext } from '../context/SwapContext';
|
|
@@ -117,8 +116,6 @@ export function SwapForm({
|
|
|
117
116
|
|
|
118
117
|
const [direction, setDirection] = useState<SwapDirection>(SwapDirection.FROM);
|
|
119
118
|
const [loading, setLoading] = useState(false);
|
|
120
|
-
const { track } = useAnalytics();
|
|
121
|
-
|
|
122
119
|
// Form State
|
|
123
120
|
const [fromAmount, setFromAmount] = useState<string>(data?.fromAmount || '');
|
|
124
121
|
const [fromAmountError, setFromAmountError] = useState<string>('');
|
|
@@ -240,20 +237,7 @@ export function SwapForm({
|
|
|
240
237
|
|
|
241
238
|
const onQuoteError = useCallback((error: any) => {
|
|
242
239
|
setQuoteError(error);
|
|
243
|
-
|
|
244
|
-
userJourney: UserJourney.SWAP,
|
|
245
|
-
screen: 'SwapCoins',
|
|
246
|
-
control: 'UnableToSwapDrawer',
|
|
247
|
-
controlType: 'Button',
|
|
248
|
-
extras: {
|
|
249
|
-
fromToken,
|
|
250
|
-
toToken,
|
|
251
|
-
fromAmount,
|
|
252
|
-
toAmount,
|
|
253
|
-
error: 'message' in error ? error.message : error,
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
}, [track, fromToken, toToken, fromAmount, toAmount]);
|
|
240
|
+
}, [fromToken, toToken, fromAmount, toAmount]);
|
|
257
241
|
|
|
258
242
|
const tokensOptionsTo = useMemo(() => allowedTokens
|
|
259
243
|
.map(
|
|
@@ -570,18 +554,6 @@ export function SwapForm({
|
|
|
570
554
|
setFromToken(selected.token);
|
|
571
555
|
setFromBalance(selected.formattedBalance);
|
|
572
556
|
setFromTokenError('');
|
|
573
|
-
|
|
574
|
-
track({
|
|
575
|
-
userJourney: UserJourney.SWAP,
|
|
576
|
-
screen: 'SwapCoins',
|
|
577
|
-
control: 'SelectFrom',
|
|
578
|
-
controlType: 'Select',
|
|
579
|
-
extras: {
|
|
580
|
-
fromBalance: selected.formattedBalance,
|
|
581
|
-
fromToken: selected.token,
|
|
582
|
-
fromAmount,
|
|
583
|
-
},
|
|
584
|
-
});
|
|
585
557
|
}, [toToken]);
|
|
586
558
|
|
|
587
559
|
const onFromTextInputFocus = () => {
|
|
@@ -599,18 +571,6 @@ export function SwapForm({
|
|
|
599
571
|
setLoading(true);
|
|
600
572
|
}
|
|
601
573
|
setFromAmount(value);
|
|
602
|
-
|
|
603
|
-
track({
|
|
604
|
-
userJourney: UserJourney.SWAP,
|
|
605
|
-
screen: 'SwapCoins',
|
|
606
|
-
control: 'InputFrom',
|
|
607
|
-
controlType: 'TextInput',
|
|
608
|
-
extras: {
|
|
609
|
-
fromBalance,
|
|
610
|
-
fromToken,
|
|
611
|
-
fromAmount: value,
|
|
612
|
-
},
|
|
613
|
-
});
|
|
614
574
|
};
|
|
615
575
|
|
|
616
576
|
const textInputMaxButtonClick = () => {
|
|
@@ -629,16 +589,6 @@ export function SwapForm({
|
|
|
629
589
|
} else {
|
|
630
590
|
setFromAmount(fromBalanceTruncated);
|
|
631
591
|
}
|
|
632
|
-
track({
|
|
633
|
-
userJourney: UserJourney.SWAP,
|
|
634
|
-
screen: 'SwapCoins',
|
|
635
|
-
control: 'MaxFrom',
|
|
636
|
-
controlType: 'Button',
|
|
637
|
-
extras: {
|
|
638
|
-
fromBalance,
|
|
639
|
-
fromBalanceTruncated,
|
|
640
|
-
},
|
|
641
|
-
});
|
|
642
592
|
};
|
|
643
593
|
|
|
644
594
|
// ------------//
|
|
@@ -654,17 +604,6 @@ export function SwapForm({
|
|
|
654
604
|
|
|
655
605
|
setToToken(selected);
|
|
656
606
|
setToTokenError('');
|
|
657
|
-
|
|
658
|
-
track({
|
|
659
|
-
userJourney: UserJourney.SWAP,
|
|
660
|
-
screen: 'SwapCoins',
|
|
661
|
-
control: 'SelectTo',
|
|
662
|
-
controlType: 'Select',
|
|
663
|
-
extras: {
|
|
664
|
-
toToken: selected,
|
|
665
|
-
toAmount,
|
|
666
|
-
},
|
|
667
|
-
});
|
|
668
607
|
}, [fromToken]);
|
|
669
608
|
|
|
670
609
|
const onToTextInputFocus = () => {
|
|
@@ -683,23 +622,11 @@ export function SwapForm({
|
|
|
683
622
|
setLoading(true);
|
|
684
623
|
}
|
|
685
624
|
setToAmount(value);
|
|
686
|
-
|
|
687
|
-
track({
|
|
688
|
-
userJourney: UserJourney.SWAP,
|
|
689
|
-
screen: 'SwapCoins',
|
|
690
|
-
control: 'InputTo',
|
|
691
|
-
controlType: 'TextInput',
|
|
692
|
-
extras: {
|
|
693
|
-
toToken,
|
|
694
|
-
toAmount: value,
|
|
695
|
-
},
|
|
696
|
-
});
|
|
697
625
|
};
|
|
698
626
|
|
|
699
627
|
const reverseTokens = () => {
|
|
700
628
|
const currentFromToken = fromToken;
|
|
701
629
|
const currentToToken = toToken;
|
|
702
|
-
const currentFromAmount = fromAmount;
|
|
703
630
|
const currentToAmount = toAmount;
|
|
704
631
|
|
|
705
632
|
setReverseRotation((prev) => (prev === 0 ? 180 : 0));
|
|
@@ -732,20 +659,6 @@ export function SwapForm({
|
|
|
732
659
|
setToToken(currentFromToken);
|
|
733
660
|
setToAmount(fromAmount);
|
|
734
661
|
}
|
|
735
|
-
|
|
736
|
-
track({
|
|
737
|
-
userJourney: UserJourney.SWAP,
|
|
738
|
-
screen: 'SwapCoins',
|
|
739
|
-
control: 'Flip',
|
|
740
|
-
controlType: 'Button',
|
|
741
|
-
extras: {
|
|
742
|
-
fromToken: currentFromToken,
|
|
743
|
-
fromAmount: currentFromAmount,
|
|
744
|
-
toToken: currentToToken,
|
|
745
|
-
toAmount: currentToAmount,
|
|
746
|
-
isCurrentToTokenInSellList,
|
|
747
|
-
},
|
|
748
|
-
});
|
|
749
662
|
};
|
|
750
663
|
|
|
751
664
|
const openNotEnoughImxDrawer = () => {
|
|
@@ -778,24 +691,6 @@ export function SwapForm({
|
|
|
778
691
|
|| validateToTokenError
|
|
779
692
|
|| (validateFromAmountError && direction === SwapDirection.FROM)
|
|
780
693
|
|| (validateToAmountError && direction === SwapDirection.TO)) isSwapFormValid = false;
|
|
781
|
-
|
|
782
|
-
track({
|
|
783
|
-
userJourney: UserJourney.SWAP,
|
|
784
|
-
screen: 'SwapCoins',
|
|
785
|
-
control: 'FormValid',
|
|
786
|
-
controlType: 'Button',
|
|
787
|
-
extras: {
|
|
788
|
-
isSwapFormValid,
|
|
789
|
-
swapFromAddress: fromToken?.address,
|
|
790
|
-
swapFromAmount: fromAmount,
|
|
791
|
-
swapFromTokenSymbol: fromToken?.symbol,
|
|
792
|
-
swapToAddress: toToken?.address,
|
|
793
|
-
swapToAmount: toAmount,
|
|
794
|
-
swapToTokenSymbol: toToken?.symbol,
|
|
795
|
-
autoProceed,
|
|
796
|
-
},
|
|
797
|
-
});
|
|
798
|
-
|
|
799
694
|
return isSwapFormValid;
|
|
800
695
|
};
|
|
801
696
|
|
|
@@ -824,26 +719,7 @@ export function SwapForm({
|
|
|
824
719
|
if (!quote) return;
|
|
825
720
|
|
|
826
721
|
const transaction = quote;
|
|
827
|
-
const isValid = SwapFormValidator();
|
|
828
|
-
// Tracking swap from data here and is valid or not to understand behaviour
|
|
829
|
-
track({
|
|
830
|
-
userJourney: UserJourney.SWAP,
|
|
831
|
-
screen: 'SwapCoins',
|
|
832
|
-
control: 'Swap',
|
|
833
|
-
controlType: 'Button',
|
|
834
|
-
extras: {
|
|
835
|
-
swapFromAddress: fromToken?.address,
|
|
836
|
-
swapFromAmount: fromAmount,
|
|
837
|
-
swapFromTokenSymbol: fromToken?.symbol,
|
|
838
|
-
swapToAddress: toToken?.address,
|
|
839
|
-
swapToAmount: toAmount,
|
|
840
|
-
swapToTokenSymbol: toToken?.symbol,
|
|
841
|
-
isSwapFormValid: isValid,
|
|
842
|
-
hasFundsForGas: !insufficientFundsForGas,
|
|
843
|
-
autoProceed,
|
|
844
|
-
},
|
|
845
|
-
});
|
|
846
|
-
if (!isValid) return;
|
|
722
|
+
const isValid = SwapFormValidator(); if (!isValid) return;
|
|
847
723
|
if (!checkout || !provider || !transaction) return;
|
|
848
724
|
if (insufficientFundsForGas) {
|
|
849
725
|
cancelAutoProceed();
|
|
@@ -1006,9 +882,6 @@ export function SwapForm({
|
|
|
1006
882
|
: undefined}
|
|
1007
883
|
coinSelectorHeading={t('views.SWAP.swapForm.from.selectorTitle')}
|
|
1008
884
|
defaultTokenImage={defaultTokenImage}
|
|
1009
|
-
control="FromToken"
|
|
1010
|
-
userJourney={UserJourney.SWAP}
|
|
1011
|
-
screen="SwapCoins"
|
|
1012
885
|
environment={checkout?.config.environment}
|
|
1013
886
|
theme={theme}
|
|
1014
887
|
themeOverrides={themeOverrides}
|
|
@@ -1085,9 +958,6 @@ export function SwapForm({
|
|
|
1085
958
|
: undefined}
|
|
1086
959
|
coinSelectorHeading={t('views.SWAP.swapForm.to.selectorTitle')}
|
|
1087
960
|
defaultTokenImage={defaultTokenImage}
|
|
1088
|
-
control="ToToken"
|
|
1089
|
-
userJourney={UserJourney.SWAP}
|
|
1090
|
-
screen="SwapCoins"
|
|
1091
961
|
environment={checkout?.config.environment}
|
|
1092
962
|
theme={theme}
|
|
1093
963
|
themeOverrides={themeOverrides}
|
|
@@ -1098,14 +968,6 @@ export function SwapForm({
|
|
|
1098
968
|
feeFiatValue={feeFiatValue}
|
|
1099
969
|
gasFeeToken={gasFeeToken}
|
|
1100
970
|
fees={formattedFees}
|
|
1101
|
-
onFeesClick={() => {
|
|
1102
|
-
track({
|
|
1103
|
-
userJourney: UserJourney.SWAP,
|
|
1104
|
-
screen: 'SwapCoins',
|
|
1105
|
-
control: 'ViewFees',
|
|
1106
|
-
controlType: 'Button',
|
|
1107
|
-
});
|
|
1108
|
-
}}
|
|
1109
971
|
sx={{
|
|
1110
972
|
paddingBottom: '0',
|
|
1111
973
|
}}
|