@imtbl/checkout-widgets 2.24.8 → 2.24.9-1
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-CAnsz6Ds.js} +24 -297
- package/dist/browser/{BridgeWidget-6KlgTXwZ.js → BridgeWidget-BPonD-21.js} +13 -294
- package/dist/browser/{CommerceWidget-CcCuv661.js → CommerceWidget-BPFWRX2R.js} +17 -47
- package/dist/browser/{FeesBreakdown-DvoQJlP-.js → FeesBreakdown-7fI38j9m.js} +1 -1
- package/dist/browser/{OnRampWidget-DaL34PiA.js → OnRampWidget-BahAHZlJ.js} +5 -80
- package/dist/browser/{SaleWidget-D-IBBRTL.js → SaleWidget-CaNtBz3t.js} +61 -219
- package/dist/browser/{SpendingCapHero-Z5NIcrWw.js → SpendingCapHero-SdeBfZ_3.js} +1 -1
- package/dist/browser/{SwapWidget-C4B2Answ.js → SwapWidget-r9E9O8w8.js} +12 -206
- package/dist/browser/{TokenImage-DucOedrZ.js → TokenImage-Cc4dAr3U.js} +1 -1
- package/dist/browser/{TopUpView-BIvdNYib.js → TopUpView-CKIcuXnF.js} +3 -54
- package/dist/browser/{WalletApproveHero-ge2JSOYk.js → WalletApproveHero-ZZhVhTT2.js} +4 -12
- package/dist/browser/{WalletWidget-hiUotMuQ.js → WalletWidget-Bf6bDJdr.js} +4 -96
- package/dist/browser/{index-2esq4Cem.js → index-Bs2uHEgi.js} +1275 -9717
- package/dist/browser/{index-DWNAmu0n.js → index-Bs7IKKJt.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{useInterval-1gu4cbu3.js → useInterval-C6NhVtCa.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
|
@@ -11,10 +11,6 @@ import {
|
|
|
11
11
|
ViewContext,
|
|
12
12
|
} from '../../../context/view-context/ViewContext';
|
|
13
13
|
import { AddTokensWidgetViews } from '../../../context/view-context/AddTokensViewContextTypes';
|
|
14
|
-
import {
|
|
15
|
-
useAnalytics,
|
|
16
|
-
UserJourney,
|
|
17
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
18
14
|
import { RiveStateMachineInput } from '../../../types/HandoverTypes';
|
|
19
15
|
import { useHandover } from '../../../lib/hooks/useHandover';
|
|
20
16
|
import { APPROVE_TXN_ANIMATION } from '../../../lib/squid/config';
|
|
@@ -30,10 +26,7 @@ interface ErrorConfig {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
export const useError = (environment: Environment) => {
|
|
33
|
-
const { viewDispatch } = useContext(ViewContext);
|
|
34
|
-
|
|
35
|
-
const { page } = useAnalytics();
|
|
36
|
-
const { t } = useTranslation();
|
|
29
|
+
const { viewDispatch } = useContext(ViewContext); const { t } = useTranslation();
|
|
37
30
|
const { addHandover, closeHandover } = useHandover({
|
|
38
31
|
id: HandoverTarget.GLOBAL,
|
|
39
32
|
});
|
|
@@ -151,17 +144,7 @@ export const useError = (environment: Environment) => {
|
|
|
151
144
|
|
|
152
145
|
const showErrorHandover = (
|
|
153
146
|
errorType: AddTokensErrorTypes,
|
|
154
|
-
data?: Record<string, unknown>,
|
|
155
147
|
) => {
|
|
156
|
-
page({
|
|
157
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
158
|
-
screen: 'Error',
|
|
159
|
-
extras: {
|
|
160
|
-
errorType,
|
|
161
|
-
...data,
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
148
|
addHandover({
|
|
166
149
|
animationUrl: getRemoteRive(environment, APPROVE_TXN_ANIMATION),
|
|
167
150
|
inputValue: RiveStateMachineInput.ERROR,
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AddTokensErrorTypes } from '../types';
|
|
3
3
|
import { EventTargetContext } from '../../../context/event-target-context/EventTargetContext';
|
|
4
4
|
import { sendAddTokensFailedEvent } from '../AddTokensWidgetEvents';
|
|
5
5
|
import { useError } from './useError';
|
|
6
|
-
import { AddTokensContext } from '../context/AddTokensContext';
|
|
7
6
|
import { useProvidersContext } from '../../../context/providers-context/ProvidersContext';
|
|
8
7
|
|
|
9
8
|
export const useErrorHandler = () => {
|
|
10
|
-
const {
|
|
11
|
-
addTokensState: { id: contextId },
|
|
12
|
-
} = useContext(AddTokensContext);
|
|
13
|
-
|
|
14
9
|
const {
|
|
15
10
|
providersState: {
|
|
16
11
|
checkout,
|
|
@@ -56,12 +51,7 @@ export const useErrorHandler = () => {
|
|
|
56
51
|
errorType = AddTokensErrorTypes.UNRECOGNISED_CHAIN;
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
type: errorType,
|
|
61
|
-
data: { error: err },
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
showErrorHandover(errorType, { contextId, error });
|
|
54
|
+
showErrorHandover(errorType);
|
|
65
55
|
};
|
|
66
56
|
|
|
67
57
|
return { onTransactionError };
|
|
@@ -28,9 +28,9 @@ import {
|
|
|
28
28
|
useState,
|
|
29
29
|
} from 'react';
|
|
30
30
|
import { useTranslation } from 'react-i18next';
|
|
31
|
-
import { ActionType } from '@0xsquid/squid-types';
|
|
32
31
|
import { trackFlow } from '@imtbl/metrics';
|
|
33
32
|
import { parseUnits } from 'ethers/utils';
|
|
33
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
34
34
|
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
35
35
|
import { EventTargetContext } from '../../../context/event-target-context/EventTargetContext';
|
|
36
36
|
import {
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
import type { StrongCheckoutWidgetsConfig } from '../../../lib/withDefaultWidgetConfig';
|
|
47
47
|
import { useRoutes } from '../../../lib/squid/hooks/useRoutes';
|
|
48
48
|
import { AddTokensWidgetViews } from '../../../context/view-context/AddTokensViewContextTypes';
|
|
49
|
-
import { AddTokensErrorTypes
|
|
49
|
+
import { AddTokensErrorTypes } from '../types';
|
|
50
50
|
import { DeliverToWalletDrawer } from '../../../components/WalletDrawer/DeliverToWalletDrawer';
|
|
51
51
|
import { PayWithWalletDrawer } from '../../../components/WalletDrawer/PayWithWalletDrawer';
|
|
52
52
|
import { useInjectedProviders } from '../../../lib/hooks/useInjectedProviders';
|
|
@@ -54,10 +54,6 @@ import { getProviderSlugFromRdns } from '../../../lib/provider';
|
|
|
54
54
|
import { useProvidersContext } from '../../../context/providers-context/ProvidersContext';
|
|
55
55
|
import { sendConnectProviderSuccessEvent } from '../AddTokensWidgetEvents';
|
|
56
56
|
import { convertToUsd } from '../../../lib/squid/functions/convertToUsd';
|
|
57
|
-
import {
|
|
58
|
-
useAnalytics,
|
|
59
|
-
UserJourney,
|
|
60
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
61
57
|
import { validateToAmount } from '../functions/amountValidation';
|
|
62
58
|
import { OnboardingDrawer } from '../components/OnboardingDrawer';
|
|
63
59
|
import { useError } from '../hooks/useError';
|
|
@@ -66,14 +62,12 @@ import { TokenDrawerMenu } from '../components/TokenDrawerMenu';
|
|
|
66
62
|
import { PULSE_SHADOW } from '../utils/animation';
|
|
67
63
|
import { RouteData } from '../../../lib/squid/types';
|
|
68
64
|
import { SQUID_NATIVE_TOKEN, TOOLKIT_SQUID_URL } from '../../../lib/squid/config';
|
|
69
|
-
import { identifyUser } from '../../../lib/analytics/identifyUser';
|
|
70
65
|
import { NotEnoughGasDrawer } from '../../../components/NotEnoughGasDrawer/NotEnoughGasDrawer';
|
|
71
66
|
import { SelectedWallet } from '../../../components/SelectedWallet/SelectedWallet';
|
|
72
67
|
import { RouteOptionsDrawer } from '../../../components/RouteOptionsDrawer/RouteOptionsDrawer';
|
|
73
68
|
import { SelectedRouteOption } from '../../../components/SelectedRouteOption/SelectedRouteOption';
|
|
74
69
|
import { getFormattedAmounts } from '../../../functions/getFormattedNumber';
|
|
75
70
|
import { checkSanctionedAddresses } from '../../../functions/checkSanctionedAddresses';
|
|
76
|
-
import { RouteError } from '../../../lib/squid/RouteError';
|
|
77
71
|
|
|
78
72
|
interface AddTokensProps {
|
|
79
73
|
checkout: Checkout;
|
|
@@ -120,15 +114,7 @@ export function AddTokens({
|
|
|
120
114
|
selectedRouteData,
|
|
121
115
|
selectedToken,
|
|
122
116
|
isSwapAvailable,
|
|
123
|
-
experiments,
|
|
124
117
|
} = addTokensState;
|
|
125
|
-
|
|
126
|
-
const {
|
|
127
|
-
track,
|
|
128
|
-
page,
|
|
129
|
-
identify,
|
|
130
|
-
user,
|
|
131
|
-
} = useAnalytics();
|
|
132
118
|
const { viewDispatch } = useContext(ViewContext);
|
|
133
119
|
const { t } = useTranslation();
|
|
134
120
|
|
|
@@ -188,31 +174,6 @@ export function AddTokens({
|
|
|
188
174
|
}, [selectedAmount, inputValue]);
|
|
189
175
|
|
|
190
176
|
const setSelectedRouteData = (route: RouteData | undefined) => {
|
|
191
|
-
if (route) {
|
|
192
|
-
track({
|
|
193
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
194
|
-
screen: 'InputScreen',
|
|
195
|
-
control: 'RoutesMenu',
|
|
196
|
-
controlType: 'MenuItem',
|
|
197
|
-
extras: {
|
|
198
|
-
contextId: id,
|
|
199
|
-
toTokenAddress: route.amountData.toToken.address,
|
|
200
|
-
toTokenChainId: route.amountData.toToken.chainId,
|
|
201
|
-
toTokenSymbol: route.amountData.toToken.symbol,
|
|
202
|
-
fromTokenAddress: route.amountData.fromToken.address,
|
|
203
|
-
fromTokenChainId: route.amountData.fromToken.chainId,
|
|
204
|
-
fromTokenSymbol: route.amountData.fromToken.symbol,
|
|
205
|
-
toAmount: route.amountData.toAmount,
|
|
206
|
-
fromAmount: route.amountData.fromAmount,
|
|
207
|
-
isBridge: route.amountData.toToken.chainId !== route.amountData.fromToken.chainId,
|
|
208
|
-
isSwap: route.amountData.toToken.chainId === route.amountData.fromToken.chainId,
|
|
209
|
-
hasEmbeddedSwap: !!route.route.route.estimate.actions.find(
|
|
210
|
-
(action) => action.type === ActionType.SWAP,
|
|
211
|
-
),
|
|
212
|
-
isInsufficientGas: route.isInsufficientGas,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
177
|
addTokensDispatch({
|
|
217
178
|
payload: {
|
|
218
179
|
type: AddTokensActions.SET_SELECTED_ROUTE_DATA,
|
|
@@ -229,17 +190,6 @@ export function AddTokens({
|
|
|
229
190
|
|
|
230
191
|
if (amount > 0) {
|
|
231
192
|
setSelectedAmount(value);
|
|
232
|
-
|
|
233
|
-
track({
|
|
234
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
235
|
-
screen: 'InputScreen',
|
|
236
|
-
control: 'AmountInput',
|
|
237
|
-
controlType: 'TextInput',
|
|
238
|
-
extras: {
|
|
239
|
-
contextId: id,
|
|
240
|
-
toAmount: value,
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
193
|
} else {
|
|
244
194
|
setSelectedAmount('');
|
|
245
195
|
}
|
|
@@ -282,12 +232,7 @@ export function AddTokens({
|
|
|
282
232
|
useEffect(() => {
|
|
283
233
|
if (!lockedToProvider) { return; }
|
|
284
234
|
|
|
285
|
-
(async () => {
|
|
286
|
-
const userData = user ? await user() : undefined;
|
|
287
|
-
const anonymousId = userData?.anonymousId();
|
|
288
|
-
|
|
289
|
-
await identifyUser(identify, toProvider!, { anonymousId });
|
|
290
|
-
})();
|
|
235
|
+
(async () => { })();
|
|
291
236
|
}, [toProvider, lockedToProvider]);
|
|
292
237
|
|
|
293
238
|
const toChain = useMemo(
|
|
@@ -296,20 +241,8 @@ export function AddTokens({
|
|
|
296
241
|
);
|
|
297
242
|
|
|
298
243
|
useEffect(() => {
|
|
299
|
-
if (!id || isSwapAvailable === undefined)
|
|
300
|
-
|
|
301
|
-
page({
|
|
302
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
303
|
-
screen: 'InputScreen',
|
|
304
|
-
extras: {
|
|
305
|
-
contextId: id,
|
|
306
|
-
toAmount,
|
|
307
|
-
toTokenAddress,
|
|
308
|
-
geoBlocked: !isSwapAvailable,
|
|
309
|
-
},
|
|
310
|
-
}).then((ctx) => {
|
|
311
|
-
trackFlow('commerce', `addTokensLoaded_${ctx.event.messageId}`);
|
|
312
|
-
});
|
|
244
|
+
if (!id || isSwapAvailable === undefined) return;
|
|
245
|
+
trackFlow('commerce', `addTokensLoaded_${uuidv4()}`);
|
|
313
246
|
}, [id, isSwapAvailable]);
|
|
314
247
|
|
|
315
248
|
useEffect(() => {
|
|
@@ -364,32 +297,8 @@ export function AddTokens({
|
|
|
364
297
|
if (availableRoutes.length === 0) {
|
|
365
298
|
setInsufficientBalance(true);
|
|
366
299
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
370
|
-
screen: 'InputScreen',
|
|
371
|
-
control: 'RoutesMenu',
|
|
372
|
-
controlType: 'MenuItem',
|
|
373
|
-
action: 'Request',
|
|
374
|
-
extras: {
|
|
375
|
-
contextId: id,
|
|
376
|
-
routesAvailable: availableRoutes.length,
|
|
377
|
-
geoBlocked: !isSwapAvailable,
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
} catch (error) {
|
|
381
|
-
if (error instanceof RouteError && error.data) {
|
|
382
|
-
track({
|
|
383
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
384
|
-
screen: 'Routes',
|
|
385
|
-
action: 'Failed',
|
|
386
|
-
extras: {
|
|
387
|
-
contextId: id,
|
|
388
|
-
message: error.message,
|
|
389
|
-
...error.data,
|
|
390
|
-
},
|
|
391
|
-
});
|
|
392
|
-
}
|
|
300
|
+
} catch {
|
|
301
|
+
// Route errors are reflected by the empty routes state.
|
|
393
302
|
}
|
|
394
303
|
|
|
395
304
|
setFetchingRoutes(false);
|
|
@@ -417,24 +326,13 @@ export function AddTokens({
|
|
|
417
326
|
setOnRampAllowedTokens(tokenResponse.tokens);
|
|
418
327
|
}
|
|
419
328
|
} catch (error) {
|
|
420
|
-
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN
|
|
329
|
+
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN);
|
|
421
330
|
}
|
|
422
331
|
};
|
|
423
332
|
fetchOnRampTokens();
|
|
424
333
|
}, [checkout, id]);
|
|
425
334
|
|
|
426
335
|
const sendRequestOnRampEvent = async () => {
|
|
427
|
-
track({
|
|
428
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
429
|
-
screen: 'InputScreen',
|
|
430
|
-
control: 'PayWithCardMenu',
|
|
431
|
-
controlType: 'MenuItem',
|
|
432
|
-
extras: {
|
|
433
|
-
contextId: id,
|
|
434
|
-
tokenAddress: selectedToken?.address ?? '',
|
|
435
|
-
amount: selectedAmount ?? '',
|
|
436
|
-
},
|
|
437
|
-
});
|
|
438
336
|
const data = {
|
|
439
337
|
tokenAddress: selectedToken?.address ?? '',
|
|
440
338
|
amount: selectedAmount ?? '',
|
|
@@ -501,23 +399,6 @@ export function AddTokens({
|
|
|
501
399
|
|
|
502
400
|
return;
|
|
503
401
|
}
|
|
504
|
-
|
|
505
|
-
track({
|
|
506
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
507
|
-
screen: 'InputScreen',
|
|
508
|
-
control: 'Review',
|
|
509
|
-
controlType: 'Button',
|
|
510
|
-
extras: {
|
|
511
|
-
contextId: id,
|
|
512
|
-
toTokenAddress: selectedRouteData.amountData.toToken.address,
|
|
513
|
-
toTokenChainId: selectedRouteData.amountData.toToken.chainId,
|
|
514
|
-
fromTokenAddress: selectedRouteData.amountData.fromToken.address,
|
|
515
|
-
fromTokenChainId: selectedRouteData.amountData.fromToken.chainId,
|
|
516
|
-
toAmount: selectedRouteData.amountData.toAmount,
|
|
517
|
-
fromAmount: selectedRouteData.amountData.fromAmount,
|
|
518
|
-
},
|
|
519
|
-
});
|
|
520
|
-
|
|
521
402
|
viewDispatch({
|
|
522
403
|
payload: {
|
|
523
404
|
type: ViewActions.UPDATE_VIEW,
|
|
@@ -575,19 +456,6 @@ export function AddTokens({
|
|
|
575
456
|
provider: WrappedBrowserProvider,
|
|
576
457
|
providerInfo: EIP6963ProviderInfo,
|
|
577
458
|
) => {
|
|
578
|
-
track({
|
|
579
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
580
|
-
screen: 'InputScreen',
|
|
581
|
-
control: 'WalletsMenu',
|
|
582
|
-
controlType: 'MenuItem',
|
|
583
|
-
extras: {
|
|
584
|
-
contextId: id,
|
|
585
|
-
providerType,
|
|
586
|
-
providerName: providerInfo.name,
|
|
587
|
-
providerRdns: providerInfo.rdns,
|
|
588
|
-
providerUuid: providerInfo.uuid,
|
|
589
|
-
},
|
|
590
|
-
});
|
|
591
459
|
sendConnectProviderSuccessEvent(
|
|
592
460
|
eventTarget,
|
|
593
461
|
providerType,
|
|
@@ -606,20 +474,6 @@ export function AddTokens({
|
|
|
606
474
|
return undefined;
|
|
607
475
|
};
|
|
608
476
|
|
|
609
|
-
useEffect(() => {
|
|
610
|
-
if (!id || !experiments) return;
|
|
611
|
-
|
|
612
|
-
track({
|
|
613
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
614
|
-
screen: 'Experiments',
|
|
615
|
-
action: 'Started',
|
|
616
|
-
extras: {
|
|
617
|
-
contextId: id,
|
|
618
|
-
preselectedToken: experiments[AddTokensExperiments.PRESELECTED_TOKEN] || 'none',
|
|
619
|
-
},
|
|
620
|
-
});
|
|
621
|
-
}, [id, experiments]);
|
|
622
|
-
|
|
623
477
|
useEffect(() => {
|
|
624
478
|
if (selectedRouteData?.isInsufficientGas) {
|
|
625
479
|
setShowNotEnoughGasDrawer(true);
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
Sticker,
|
|
15
15
|
useInterval,
|
|
16
16
|
} from '@biom3/react';
|
|
17
|
-
import { ChainId } from '@imtbl/checkout-sdk';
|
|
18
17
|
import { trackFlow } from '@imtbl/metrics';
|
|
19
18
|
import { t } from 'i18next';
|
|
19
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
20
20
|
import {
|
|
21
21
|
useCallback,
|
|
22
22
|
useContext,
|
|
@@ -38,11 +38,6 @@ import { useExecute } from '../../../lib/squid/hooks/useExecute';
|
|
|
38
38
|
import { useRoutes } from '../../../lib/squid/hooks/useRoutes';
|
|
39
39
|
import { AddTokensContext } from '../context/AddTokensContext';
|
|
40
40
|
import { AddTokensErrorTypes } from '../types';
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
useAnalytics,
|
|
44
|
-
UserJourney,
|
|
45
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
46
41
|
import { useProvidersContext } from '../../../context/providers-context/ProvidersContext';
|
|
47
42
|
import { getRouteChains } from '../../../lib/squid/functions/getRouteChains';
|
|
48
43
|
import { getTotalRouteFees } from '../../../lib/squid/functions/getTotalRouteFees';
|
|
@@ -60,7 +55,6 @@ import {
|
|
|
60
55
|
} from '../../../lib/squid/config';
|
|
61
56
|
import { verifyAndSwitchChain } from '../../../lib/squid/functions/verifyAndSwitchChain';
|
|
62
57
|
import { useError } from '../hooks/useError';
|
|
63
|
-
import { FromAmountData } from '../../../lib/squid/types';
|
|
64
58
|
import {
|
|
65
59
|
sendAddTokensSuccessEvent,
|
|
66
60
|
} from '../AddTokensWidgetEvents';
|
|
@@ -90,12 +84,9 @@ export function Review({
|
|
|
90
84
|
onCloseButtonClick,
|
|
91
85
|
}: ReviewProps) {
|
|
92
86
|
const { viewDispatch } = useContext(ViewContext);
|
|
93
|
-
|
|
94
|
-
const { track, page } = useAnalytics();
|
|
95
|
-
|
|
96
87
|
const {
|
|
97
88
|
addTokensState: {
|
|
98
|
-
|
|
89
|
+
squid, chains, tokens,
|
|
99
90
|
},
|
|
100
91
|
} = useContext(AddTokensContext);
|
|
101
92
|
|
|
@@ -112,7 +103,6 @@ export function Review({
|
|
|
112
103
|
} = useContext(EventTargetContext);
|
|
113
104
|
|
|
114
105
|
const [route, setRoute] = useState<RouteResponse | undefined>();
|
|
115
|
-
const [amountData, setAmountData] = useState<FromAmountData | undefined>();
|
|
116
106
|
const [proceedDisabled, setProceedDisabled] = useState(true);
|
|
117
107
|
const [showFeeBreakdown, setShowFeeBreakdown] = useState(false);
|
|
118
108
|
const [showSecuringQuote, setShowSecuringQuote] = useState(false);
|
|
@@ -124,21 +114,7 @@ export function Review({
|
|
|
124
114
|
|
|
125
115
|
const {
|
|
126
116
|
getAllowance, approve, execute, getStatus,
|
|
127
|
-
} = useExecute(
|
|
128
|
-
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
page({
|
|
131
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
132
|
-
screen: 'Review',
|
|
133
|
-
extras: {
|
|
134
|
-
contextId: id,
|
|
135
|
-
toAmount: data.toAmount,
|
|
136
|
-
toChainId: data.toChainId,
|
|
137
|
-
toTokenAddress: data.toTokenAddress,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
}, [id]);
|
|
141
|
-
|
|
117
|
+
} = useExecute('AddTokens', onTransactionError);
|
|
142
118
|
const getFromAmountAndRoute = async () => {
|
|
143
119
|
if (!squid || !tokens) return;
|
|
144
120
|
|
|
@@ -170,14 +146,10 @@ export function Review({
|
|
|
170
146
|
false,
|
|
171
147
|
);
|
|
172
148
|
setRoute(routeResponse.route);
|
|
173
|
-
setAmountData(updatedAmountData);
|
|
174
149
|
setProceedDisabled(false);
|
|
175
150
|
setShowSecuringQuote(false);
|
|
176
151
|
if (routeResponse?.route === undefined) {
|
|
177
|
-
showErrorHandover(AddTokensErrorTypes.ROUTE_ERROR
|
|
178
|
-
contextId: id,
|
|
179
|
-
error: 'Failed to obtain final route',
|
|
180
|
-
});
|
|
152
|
+
showErrorHandover(AddTokensErrorTypes.ROUTE_ERROR);
|
|
181
153
|
}
|
|
182
154
|
};
|
|
183
155
|
|
|
@@ -197,20 +169,6 @@ export function Review({
|
|
|
197
169
|
);
|
|
198
170
|
|
|
199
171
|
const openFeeBreakdown = () => {
|
|
200
|
-
const feesToken = route?.route.estimate.feeCosts?.[0]?.token;
|
|
201
|
-
track({
|
|
202
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
203
|
-
screen: 'Review',
|
|
204
|
-
control: 'FeeBreakdown',
|
|
205
|
-
controlType: 'Button',
|
|
206
|
-
extras: {
|
|
207
|
-
contextId: id,
|
|
208
|
-
feesToken: feesToken?.symbol,
|
|
209
|
-
totalAmount: feesToken ? getFormattedNumber(totalFees, feesToken.decimals) : null,
|
|
210
|
-
totalFiatAmount: getFormattedAmounts(totalFeesUsd),
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
|
|
214
172
|
setShowFeeBreakdown(true);
|
|
215
173
|
};
|
|
216
174
|
|
|
@@ -268,32 +226,10 @@ export function Review({
|
|
|
268
226
|
}
|
|
269
227
|
|
|
270
228
|
let currentFromAddress = '';
|
|
271
|
-
track({
|
|
272
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
273
|
-
screen: 'Review',
|
|
274
|
-
control: 'Proceed',
|
|
275
|
-
controlType: 'Button',
|
|
276
|
-
extras: {
|
|
277
|
-
contextId: id,
|
|
278
|
-
toTokenAddress: route.route.params.toToken,
|
|
279
|
-
toTokenChainId: route.route.params.toChain,
|
|
280
|
-
fromTokenAddress: route.route.params.fromToken,
|
|
281
|
-
fromTokenChainId: route.route.params.fromChain,
|
|
282
|
-
fromAddress: route.route.params.fromAddress,
|
|
283
|
-
toAddress: route.route.params.toAddress,
|
|
284
|
-
estimatedRouteDuration: route.route.estimate.estimatedRouteDuration,
|
|
285
|
-
fromAmount: amountData?.fromAmount,
|
|
286
|
-
toAmount: amountData?.toAmount,
|
|
287
|
-
},
|
|
288
|
-
});
|
|
289
|
-
|
|
290
229
|
try {
|
|
291
230
|
currentFromAddress = await (await fromProvider.getSigner()).getAddress();
|
|
292
231
|
} catch (error) {
|
|
293
|
-
showErrorHandover(AddTokensErrorTypes.PROVIDER_ERROR
|
|
294
|
-
contextId: id,
|
|
295
|
-
error,
|
|
296
|
-
});
|
|
232
|
+
showErrorHandover(AddTokensErrorTypes.PROVIDER_ERROR);
|
|
297
233
|
return;
|
|
298
234
|
}
|
|
299
235
|
|
|
@@ -338,31 +274,7 @@ export function Review({
|
|
|
338
274
|
const executeTxnReceipt = await execute(squid, fromProviderInfo, changeableProvider, route);
|
|
339
275
|
|
|
340
276
|
if (executeTxnReceipt) {
|
|
341
|
-
|
|
342
|
-
userJourney: UserJourney.ADD_TOKENS,
|
|
343
|
-
screen: 'FundsAdded',
|
|
344
|
-
action: 'Succeeded',
|
|
345
|
-
extras: {
|
|
346
|
-
contextId: id,
|
|
347
|
-
...(route.route.params.fromChain !== ChainId.IMTBL_ZKEVM_MAINNET.toString()
|
|
348
|
-
&& { txHash: executeTxnReceipt.hash }),
|
|
349
|
-
...(route.route.params.fromChain === ChainId.IMTBL_ZKEVM_MAINNET.toString()
|
|
350
|
-
&& { immutableZkEVMTxHash: executeTxnReceipt.hash }),
|
|
351
|
-
toTokenAddress: route.route.params.toToken,
|
|
352
|
-
toTokenChainId: route.route.params.toChain,
|
|
353
|
-
fromTokenAddress: route.route.params.fromToken,
|
|
354
|
-
fromTokenChainId: route.route.params.fromChain,
|
|
355
|
-
fromAmount: amountData?.fromAmount,
|
|
356
|
-
fromAddress: route.route.params.fromAddress,
|
|
357
|
-
toAddress: route.route.params.toAddress,
|
|
358
|
-
toAmount: amountData?.toAmount,
|
|
359
|
-
fromTokenSymbol: amountData?.fromToken.symbol,
|
|
360
|
-
toTokenSymbol: amountData?.toToken.symbol,
|
|
361
|
-
},
|
|
362
|
-
}).then((ctx) => {
|
|
363
|
-
trackFlow('commerce', `addTokensFundsAdded_${ctx.event.messageId}`);
|
|
364
|
-
});
|
|
365
|
-
|
|
277
|
+
trackFlow('commerce', `addTokensFundsAdded_${uuidv4()}`);
|
|
366
278
|
sendAddTokensSuccessEvent(eventTarget, executeTxnReceipt.hash);
|
|
367
279
|
|
|
368
280
|
if (toChain === fromChain) {
|
|
@@ -26,7 +26,6 @@ import { CryptoFiatProvider } from '../../context/crypto-fiat-context/CryptoFiat
|
|
|
26
26
|
import { StatusView } from '../../components/Status/StatusView';
|
|
27
27
|
import { StatusType } from '../../components/Status/StatusType';
|
|
28
28
|
import { Transactions } from '../../components/Transactions/Transactions';
|
|
29
|
-
import { UserJourney, useAnalytics } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
30
29
|
import { TopUpView } from '../../views/top-up/TopUpView';
|
|
31
30
|
import { ClaimWithdrawalInProgress } from '../../components/Transactions/ClaimWithdrawalInProgress';
|
|
32
31
|
import { getDefaultTokenImage } from '../../lib/utils';
|
|
@@ -89,9 +88,6 @@ export default function BridgeWidget({
|
|
|
89
88
|
} = config;
|
|
90
89
|
const defaultTokenImage = getDefaultTokenImage(checkout.config.environment, theme);
|
|
91
90
|
const { eventTargetState: { eventTarget } } = useContext(EventTargetContext);
|
|
92
|
-
|
|
93
|
-
const { page } = useAnalytics();
|
|
94
|
-
|
|
95
91
|
const [viewState, viewDispatch] = useReducer(
|
|
96
92
|
viewReducer,
|
|
97
93
|
{
|
|
@@ -237,15 +233,6 @@ export default function BridgeWidget({
|
|
|
237
233
|
if (viewState.view.type === BridgeWidgetViews.BRIDGE_FAILURE) {
|
|
238
234
|
reason = viewState.view.reason;
|
|
239
235
|
}
|
|
240
|
-
|
|
241
|
-
page({
|
|
242
|
-
userJourney: UserJourney.BRIDGE,
|
|
243
|
-
screen: 'Failed',
|
|
244
|
-
extras: {
|
|
245
|
-
reason,
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
|
|
249
236
|
sendBridgeFailedEvent(eventTarget, reason);
|
|
250
237
|
}}
|
|
251
238
|
/>
|
|
@@ -273,17 +260,10 @@ export default function BridgeWidget({
|
|
|
273
260
|
actionText={t('views.ERROR_VIEW.actionText')}
|
|
274
261
|
onActionClick={goBackToWalletNetworkSelectorClearState}
|
|
275
262
|
onCloseClick={() => sendBridgeWidgetCloseEvent(eventTarget)}
|
|
276
|
-
errorEventAction={() => {
|
|
277
|
-
page({
|
|
278
|
-
userJourney: UserJourney.BRIDGE,
|
|
279
|
-
screen: 'Error',
|
|
280
|
-
});
|
|
281
|
-
}}
|
|
282
263
|
/>
|
|
283
264
|
)}
|
|
284
265
|
{viewState.view.type === SharedViews.TOP_UP_VIEW && (
|
|
285
266
|
<TopUpView
|
|
286
|
-
analytics={{ userJourney: UserJourney.BRIDGE }}
|
|
287
267
|
widgetEvent={IMTBLWidgetEvents.IMTBL_BRIDGE_WIDGET_EVENT}
|
|
288
268
|
checkout={checkout}
|
|
289
269
|
provider={browserProvider}
|
|
@@ -303,10 +283,6 @@ export default function BridgeWidget({
|
|
|
303
283
|
statusText={t('views.CLAIM_WITHDRAWAL.IN_PROGRESS.success.text')}
|
|
304
284
|
actionText={t('views.CLAIM_WITHDRAWAL.IN_PROGRESS.success.actionText')}
|
|
305
285
|
onRenderEvent={() => {
|
|
306
|
-
page({
|
|
307
|
-
userJourney: UserJourney.BRIDGE,
|
|
308
|
-
screen: 'ClaimWithdrawalSuccess',
|
|
309
|
-
});
|
|
310
286
|
sendBridgeClaimWithdrawalSuccessEvent(
|
|
311
287
|
eventTarget,
|
|
312
288
|
(viewState.view as BridgeClaimWithdrawalSuccess).transactionHash,
|
|
@@ -322,17 +298,6 @@ export default function BridgeWidget({
|
|
|
322
298
|
statusText={t('views.CLAIM_WITHDRAWAL.IN_PROGRESS.failure.text')}
|
|
323
299
|
actionText={t('views.CLAIM_WITHDRAWAL.IN_PROGRESS.failure.actionText')}
|
|
324
300
|
onRenderEvent={() => {
|
|
325
|
-
let reason = '';
|
|
326
|
-
if (viewState.view.type === BridgeWidgetViews.CLAIM_WITHDRAWAL_FAILURE) {
|
|
327
|
-
reason = viewState.view.reason;
|
|
328
|
-
}
|
|
329
|
-
page({
|
|
330
|
-
userJourney: UserJourney.BRIDGE,
|
|
331
|
-
screen: 'ClaimWithdrawalFailure',
|
|
332
|
-
extras: {
|
|
333
|
-
reason,
|
|
334
|
-
},
|
|
335
|
-
});
|
|
336
301
|
sendBridgeClaimWithdrawalFailedEvent(
|
|
337
302
|
eventTarget,
|
|
338
303
|
(viewState.view as BridgeClaimWithdrawalFailure).transactionHash,
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
import { Base } from '../BaseWidgetRoot';
|
|
11
11
|
import { isValidWalletProvider, isValidAmount, isValidAddress } from '../../lib/validations/widgetValidators';
|
|
12
12
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
13
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
14
13
|
import { LoadingView } from '../../views/loading/LoadingView';
|
|
15
14
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
16
15
|
import i18n from '../../i18n';
|
|
@@ -65,23 +64,23 @@ export class Bridge extends Base<WidgetType.BRIDGE> {
|
|
|
65
64
|
|
|
66
65
|
this.reactRoot.render(
|
|
67
66
|
<React.StrictMode>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
|
|
68
|
+
<ThemeProvider id="bridge-container" config={this.strongConfig()}>
|
|
69
|
+
<HandoverProvider>
|
|
70
|
+
<Suspense fallback={<LoadingView loadingText={t('views.LOADING_VIEW.text')} />}>
|
|
71
|
+
<BridgeWidget
|
|
72
|
+
checkout={this.checkout}
|
|
73
|
+
config={this.strongConfig()}
|
|
74
|
+
browserProvider={this.browserProvider}
|
|
75
|
+
tokenAddress={this.parameters.tokenAddress}
|
|
76
|
+
amount={this.parameters.amount}
|
|
77
|
+
walletProviderName={this.parameters.walletProviderName}
|
|
78
|
+
showBackButton={!!this.parameters.showBackButton}
|
|
79
|
+
/>
|
|
80
|
+
</Suspense>
|
|
81
|
+
</HandoverProvider>
|
|
82
|
+
</ThemeProvider>
|
|
83
|
+
|
|
85
84
|
</React.StrictMode>,
|
|
86
85
|
);
|
|
87
86
|
}
|