@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
|
@@ -28,10 +28,6 @@ import {
|
|
|
28
28
|
ViewActions,
|
|
29
29
|
ViewContext,
|
|
30
30
|
} from '../../../context/view-context/ViewContext';
|
|
31
|
-
import {
|
|
32
|
-
useAnalytics,
|
|
33
|
-
UserJourney,
|
|
34
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
35
31
|
import { useWalletConnect } from '../../../lib/hooks/useWalletConnect';
|
|
36
32
|
import { useInjectedProviders } from '../../../lib/hooks/useInjectedProviders';
|
|
37
33
|
import { walletListStyle } from './WalletListStyles';
|
|
@@ -48,7 +44,6 @@ import { WalletDrawer } from '../../../components/WalletDrawer/WalletDrawer';
|
|
|
48
44
|
import { WalletChangeEvent } from '../../../components/WalletDrawer/WalletDrawerEvents';
|
|
49
45
|
import { WalletConnectItem } from './WalletConnectItem';
|
|
50
46
|
import { BrowserWalletItem } from './BrowserWalletItem';
|
|
51
|
-
import { identifyUser } from '../../../lib/analytics/identifyUser';
|
|
52
47
|
import { NonPassportWarningDrawer } from './NonPassportWarningDrawer';
|
|
53
48
|
import { removeSpace } from '../../../lib/utils';
|
|
54
49
|
import { parseChainId } from '../../../lib/chains';
|
|
@@ -84,9 +79,7 @@ export function WalletList(props: WalletListProps) {
|
|
|
84
79
|
connectDispatch,
|
|
85
80
|
connectState: { checkout },
|
|
86
81
|
} = useContext(ConnectContext);
|
|
87
|
-
const { viewDispatch } = useContext(ViewContext);
|
|
88
|
-
const { track, identify, user } = useAnalytics();
|
|
89
|
-
const { providers } = useInjectedProviders({ checkout });
|
|
82
|
+
const { viewDispatch } = useContext(ViewContext); const { providers } = useInjectedProviders({ checkout });
|
|
90
83
|
const [showWalletDrawer, setShowWalletDrawer] = useState(false);
|
|
91
84
|
const { isWalletConnectEnabled, openWalletConnectModal } = useWalletConnect();
|
|
92
85
|
const walletConnectItemRef = useRef(null);
|
|
@@ -191,13 +184,7 @@ export function WalletList(props: WalletListProps) {
|
|
|
191
184
|
});
|
|
192
185
|
|
|
193
186
|
// Set up EIP-1193 provider event listeners for widget root instances
|
|
194
|
-
addProviderListenersForWidgetRoot(connectResult.provider);
|
|
195
|
-
|
|
196
|
-
const userData = user ? await user() : undefined;
|
|
197
|
-
const anonymousId = userData?.anonymousId();
|
|
198
|
-
await identifyUser(identify, connectResult.provider, { anonymousId });
|
|
199
|
-
|
|
200
|
-
selectBrowserProvider(
|
|
187
|
+
addProviderListenersForWidgetRoot(connectResult.provider); selectBrowserProvider(
|
|
201
188
|
browserProvider,
|
|
202
189
|
getProviderSlugFromRdns(providerDetail.info.rdns),
|
|
203
190
|
);
|
|
@@ -258,12 +245,6 @@ export function WalletList(props: WalletListProps) {
|
|
|
258
245
|
};
|
|
259
246
|
|
|
260
247
|
const handleWalletConnectConnection = async () => {
|
|
261
|
-
track({
|
|
262
|
-
userJourney: UserJourney.CONNECT,
|
|
263
|
-
screen: 'ConnectWallet',
|
|
264
|
-
control: 'WalletConnect',
|
|
265
|
-
controlType: 'MenuItem',
|
|
266
|
-
});
|
|
267
248
|
await openWalletConnectModal({
|
|
268
249
|
connectCallback,
|
|
269
250
|
restoreSession: false,
|
|
@@ -272,19 +253,7 @@ export function WalletList(props: WalletListProps) {
|
|
|
272
253
|
|
|
273
254
|
const handleWalletChange = async (event: WalletChangeEvent) => {
|
|
274
255
|
const { providerDetail } = event;
|
|
275
|
-
setChosenProviderDetail(providerDetail);
|
|
276
|
-
track({
|
|
277
|
-
userJourney: UserJourney.CONNECT,
|
|
278
|
-
screen: 'ConnectWallet',
|
|
279
|
-
control: removeSpace(providerDetail.info.name),
|
|
280
|
-
controlType: 'MenuItem',
|
|
281
|
-
extras: {
|
|
282
|
-
wallet: getProviderSlugFromRdns(providerDetail.info.rdns),
|
|
283
|
-
walletRdns: providerDetail.info.rdns,
|
|
284
|
-
walletUuid: providerDetail.info.uuid,
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
await selectProviderDetail(providerDetail);
|
|
256
|
+
setChosenProviderDetail(providerDetail); await selectProviderDetail(providerDetail);
|
|
288
257
|
setShowWalletDrawer(false);
|
|
289
258
|
};
|
|
290
259
|
|
|
@@ -303,21 +272,9 @@ export function WalletList(props: WalletListProps) {
|
|
|
303
272
|
|
|
304
273
|
setShowChangedYourMindDrawer(false);
|
|
305
274
|
setShowUnableToConnectDrawer(false);
|
|
306
|
-
setChosenProviderDetail(providerDetail);
|
|
307
|
-
track({
|
|
308
|
-
userJourney: UserJourney.CONNECT,
|
|
309
|
-
screen: 'ConnectWallet',
|
|
310
|
-
control: removeSpace(providerDetail.info.name),
|
|
311
|
-
controlType: 'MenuItem',
|
|
312
|
-
extras: {
|
|
313
|
-
wallet: getProviderSlugFromRdns(providerDetail.info.rdns),
|
|
314
|
-
walletRdns: providerDetail.info.rdns,
|
|
315
|
-
walletUuid: providerDetail.info.uuid,
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
await selectProviderDetail(providerDetail);
|
|
275
|
+
setChosenProviderDetail(providerDetail); await selectProviderDetail(providerDetail);
|
|
319
276
|
},
|
|
320
|
-
[
|
|
277
|
+
[checkout],
|
|
321
278
|
);
|
|
322
279
|
|
|
323
280
|
const onChosenProviderDetailChange = useCallback(() => {
|
|
@@ -326,14 +283,8 @@ export function WalletList(props: WalletListProps) {
|
|
|
326
283
|
}, [chosenProviderDetail]);
|
|
327
284
|
|
|
328
285
|
const onBrowserWalletsClick = useCallback(() => {
|
|
329
|
-
track({
|
|
330
|
-
userJourney: UserJourney.CONNECT,
|
|
331
|
-
screen: 'ConnectWallet',
|
|
332
|
-
control: 'BrowserWallets',
|
|
333
|
-
controlType: 'MenuItem',
|
|
334
|
-
});
|
|
335
286
|
setShowWalletDrawer(true);
|
|
336
|
-
}, [
|
|
287
|
+
}, []);
|
|
337
288
|
|
|
338
289
|
useEffect(() => {
|
|
339
290
|
// Auto-trigger wallet connection via rdns
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext
|
|
1
|
+
import { useContext } from 'react';
|
|
2
2
|
import { Body, Box, Heading } from '@biom3/react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { ChainId, ThemeOverrides } from '@imtbl/checkout-sdk';
|
|
@@ -7,7 +7,6 @@ import { HeaderNavigation } from '../../../components/Header/HeaderNavigation';
|
|
|
7
7
|
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
8
8
|
import { WalletList } from '../components/WalletList';
|
|
9
9
|
import { ConnectContext } from '../context/ConnectContext';
|
|
10
|
-
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
11
10
|
|
|
12
11
|
export interface ConnectWalletProps {
|
|
13
12
|
targetWalletRdns?: string,
|
|
@@ -36,16 +35,6 @@ export function ConnectWallet({
|
|
|
36
35
|
const {
|
|
37
36
|
connectState: { sendCloseEvent },
|
|
38
37
|
} = useContext(ConnectContext);
|
|
39
|
-
|
|
40
|
-
const { page } = useAnalytics();
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
page({
|
|
44
|
-
userJourney: UserJourney.CONNECT,
|
|
45
|
-
screen: 'ConnectWallet',
|
|
46
|
-
});
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
38
|
return (
|
|
50
39
|
<SimpleLayout
|
|
51
40
|
testId="connect-wallet"
|
|
@@ -18,8 +18,6 @@ import { ConnectWidgetViews } from '../../../context/view-context/ConnectViewCon
|
|
|
18
18
|
import { ConnectContext, ConnectActions } from '../context/ConnectContext';
|
|
19
19
|
import { ViewContext, ViewActions } from '../../../context/view-context/ViewContext';
|
|
20
20
|
import { isMetaMaskProvider, isPassportProvider } from '../../../lib/provider';
|
|
21
|
-
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
22
|
-
import { identifyUser } from '../../../lib/analytics/identifyUser';
|
|
23
21
|
import { parseChainId } from '../../../lib/chains';
|
|
24
22
|
|
|
25
23
|
export interface ReadyToConnectProps {
|
|
@@ -36,18 +34,6 @@ export function ReadyToConnect({ targetChainId, allowedChains }: ReadyToConnectP
|
|
|
36
34
|
|
|
37
35
|
const isPassport = isPassportProvider(provider);
|
|
38
36
|
const isMetaMask = isMetaMaskProvider(provider);
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
page, identify, track, user,
|
|
42
|
-
} = useAnalytics();
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
page({
|
|
46
|
-
userJourney: UserJourney.CONNECT,
|
|
47
|
-
screen: 'ReadyToConnect',
|
|
48
|
-
});
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
37
|
// make sure wallet provider name is set if coming directly to this screen
|
|
52
38
|
// and not through the wallet list
|
|
53
39
|
useEffect(() => {
|
|
@@ -127,13 +113,6 @@ export function ReadyToConnect({ targetChainId, allowedChains }: ReadyToConnectP
|
|
|
127
113
|
setLoading(true);
|
|
128
114
|
|
|
129
115
|
try {
|
|
130
|
-
track({
|
|
131
|
-
userJourney: UserJourney.CONNECT,
|
|
132
|
-
screen: 'ReadyToConnect',
|
|
133
|
-
control: 'Connect',
|
|
134
|
-
controlType: 'Button',
|
|
135
|
-
});
|
|
136
|
-
|
|
137
116
|
let changeAccount = false;
|
|
138
117
|
if (isMetaMaskProvider(provider)) {
|
|
139
118
|
changeAccount = true;
|
|
@@ -145,13 +124,7 @@ export function ReadyToConnect({ targetChainId, allowedChains }: ReadyToConnectP
|
|
|
145
124
|
});
|
|
146
125
|
|
|
147
126
|
// Set up EIP-1193 provider event listeners for widget root instances
|
|
148
|
-
addProviderListenersForWidgetRoot(connectResult.provider);
|
|
149
|
-
|
|
150
|
-
const userData = user ? await user() : undefined;
|
|
151
|
-
const anonymousId = userData?.anonymousId();
|
|
152
|
-
await identifyUser(identify, connectResult.provider, { anonymousId });
|
|
153
|
-
|
|
154
|
-
connectDispatch({
|
|
127
|
+
addProviderListenersForWidgetRoot(connectResult.provider); connectDispatch({
|
|
155
128
|
payload: {
|
|
156
129
|
type: ConnectActions.SET_PROVIDER,
|
|
157
130
|
provider: connectResult.provider,
|
|
@@ -164,7 +137,7 @@ export function ReadyToConnect({ targetChainId, allowedChains }: ReadyToConnectP
|
|
|
164
137
|
setLoading(false);
|
|
165
138
|
setFooterButtonTextKey(`${textView()}.footer.buttonText2`);
|
|
166
139
|
}
|
|
167
|
-
}, [checkout, provider, connectDispatch, viewDispatch
|
|
140
|
+
}, [checkout, provider, connectDispatch, viewDispatch]);
|
|
168
141
|
|
|
169
142
|
return (
|
|
170
143
|
<SimpleLayout
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useCallback, useContext,
|
|
2
|
+
useCallback, useContext, useState,
|
|
3
3
|
} from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { getChainNameById } from '../../../lib/chains';
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
ViewContext,
|
|
15
15
|
ViewActions,
|
|
16
16
|
} from '../../../context/view-context/ViewContext';
|
|
17
|
-
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
18
17
|
|
|
19
18
|
export function SwitchNetworkEth() {
|
|
20
19
|
const { t } = useTranslation();
|
|
@@ -22,26 +21,8 @@ export function SwitchNetworkEth() {
|
|
|
22
21
|
const { connectDispatch, connectState } = useContext(ConnectContext);
|
|
23
22
|
const { checkout, provider, sendCloseEvent } = connectState;
|
|
24
23
|
const [buttonTextKey, setButtonTextKey] = useState(t('views.SWITCH_NETWORK.eth.button.text'));
|
|
25
|
-
|
|
26
|
-
const { page, track } = useAnalytics();
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
page({
|
|
30
|
-
userJourney: UserJourney.CONNECT,
|
|
31
|
-
screen: 'SwitchNetworkEth',
|
|
32
|
-
});
|
|
33
|
-
}, []);
|
|
34
|
-
|
|
35
24
|
const switchNetwork = useCallback(async () => {
|
|
36
|
-
if (!provider || !checkout) return;
|
|
37
|
-
|
|
38
|
-
track({
|
|
39
|
-
userJourney: UserJourney.CONNECT,
|
|
40
|
-
screen: 'SwitchNetworkEth',
|
|
41
|
-
control: 'Switch',
|
|
42
|
-
controlType: 'Button',
|
|
43
|
-
});
|
|
44
|
-
try {
|
|
25
|
+
if (!provider || !checkout) return; try {
|
|
45
26
|
const switchRes = await checkout.switchNetwork({
|
|
46
27
|
provider,
|
|
47
28
|
chainId: checkout.config.l1ChainId,
|
|
@@ -65,7 +46,7 @@ export function SwitchNetworkEth() {
|
|
|
65
46
|
} catch (err: any) {
|
|
66
47
|
setButtonTextKey(t('views.SWITCH_NETWORK.eth.button.retryText'));
|
|
67
48
|
}
|
|
68
|
-
}, [provider, checkout
|
|
49
|
+
}, [provider, checkout]);
|
|
69
50
|
|
|
70
51
|
return (
|
|
71
52
|
<SimpleLayout
|
|
@@ -13,7 +13,6 @@ import { ConnectActions, ConnectContext } from '../context/ConnectContext';
|
|
|
13
13
|
import { ViewContext, ViewActions } from '../../../context/view-context/ViewContext';
|
|
14
14
|
import { addChainChangedListener, removeChainChangedListener } from '../../../lib';
|
|
15
15
|
import { ImmutablePlanetHero } from '../../../components/Hero/ImmutablePlanetHero';
|
|
16
|
-
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
17
16
|
|
|
18
17
|
export function SwitchNetworkZkEVM() {
|
|
19
18
|
const { t } = useTranslation();
|
|
@@ -21,15 +20,6 @@ export function SwitchNetworkZkEVM() {
|
|
|
21
20
|
const { connectDispatch, connectState } = useContext(ConnectContext);
|
|
22
21
|
const { checkout, provider, sendCloseEvent } = connectState;
|
|
23
22
|
const [buttonTextKey, setButtonTextKey] = useState(t('views.SWITCH_NETWORK.zkEVM.button.text'));
|
|
24
|
-
const { page, track } = useAnalytics();
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
page({
|
|
28
|
-
userJourney: UserJourney.CONNECT,
|
|
29
|
-
screen: 'SwitchNetworkZkEVM',
|
|
30
|
-
});
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
23
|
useEffect(() => {
|
|
34
24
|
if (!provider || !checkout) return;
|
|
35
25
|
|
|
@@ -65,14 +55,6 @@ export function SwitchNetworkZkEVM() {
|
|
|
65
55
|
|
|
66
56
|
const switchNetwork = useCallback(async () => {
|
|
67
57
|
if (!provider || !checkout) return;
|
|
68
|
-
|
|
69
|
-
track({
|
|
70
|
-
userJourney: UserJourney.CONNECT,
|
|
71
|
-
screen: 'SwitchNetworkZkEVM',
|
|
72
|
-
control: 'Switch',
|
|
73
|
-
controlType: 'Button',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
58
|
if (!provider.send) return;
|
|
77
59
|
|
|
78
60
|
const currentChainId = await provider.send('eth_chainId', []) as `0x${string}`;
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
import React, { Suspense } from 'react';
|
|
20
20
|
import { isAddress } from 'ethers';
|
|
21
21
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
22
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
23
22
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
24
23
|
import { LoadingView } from '../../views/loading/LoadingView';
|
|
25
24
|
import { Base } from '../BaseWidgetRoot';
|
|
@@ -305,25 +304,24 @@ export class CommerceWidgetRoot extends Base<WidgetType.IMMUTABLE_COMMERCE> {
|
|
|
305
304
|
const { t } = i18n;
|
|
306
305
|
|
|
307
306
|
this.reactRoot.render(
|
|
308
|
-
<
|
|
309
|
-
<
|
|
310
|
-
<
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
<LoadingView loadingText={t('views.LOADING_VIEW.text')} />
|
|
307
|
+
<ThemeProvider id="checkout-container" config={this.strongConfig()}>
|
|
308
|
+
<HandoverProvider>
|
|
309
|
+
<Suspense
|
|
310
|
+
fallback={
|
|
311
|
+
<LoadingView loadingText={t('views.LOADING_VIEW.text')} />
|
|
314
312
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
313
|
+
>
|
|
314
|
+
<CommerceWidget
|
|
315
|
+
checkout={this.checkout}
|
|
316
|
+
browserProvider={this.browserProvider}
|
|
317
|
+
flowParams={this.parameters}
|
|
318
|
+
flowConfig={this.properties.config || {}}
|
|
319
|
+
widgetsConfig={this.strongConfig()}
|
|
320
|
+
/>
|
|
321
|
+
</Suspense>
|
|
322
|
+
</HandoverProvider>
|
|
323
|
+
</ThemeProvider>
|
|
324
|
+
,
|
|
327
325
|
);
|
|
328
326
|
}
|
|
329
327
|
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
} from 'react';
|
|
4
4
|
import { IMTBLWidgetEvents, OnRampWidgetParams, OnrampWidgetConfiguration } from '@imtbl/checkout-sdk';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { UserJourney } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
7
6
|
import { NATIVE } from '../../lib';
|
|
8
7
|
import { StrongCheckoutWidgetsConfig } from '../../lib/withDefaultWidgetConfig';
|
|
9
8
|
import {
|
|
@@ -149,7 +148,6 @@ export default function OnRampWidget({
|
|
|
149
148
|
|
|
150
149
|
{viewState.view.type === SharedViews.TOP_UP_VIEW && (
|
|
151
150
|
<TopUpView
|
|
152
|
-
analytics={{ userJourney: UserJourney.ON_RAMP }}
|
|
153
151
|
widgetEvent={IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT}
|
|
154
152
|
checkout={checkout}
|
|
155
153
|
provider={provider}
|
|
@@ -12,7 +12,6 @@ import { Base } from '../BaseWidgetRoot';
|
|
|
12
12
|
import { ConnectLoader, ConnectLoaderParams } from '../../components/ConnectLoader/ConnectLoader';
|
|
13
13
|
import { isValidAddress, isValidAmount } from '../../lib/validations/widgetValidators';
|
|
14
14
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
15
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
16
15
|
import { LoadingView } from '../../views/loading/LoadingView';
|
|
17
16
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
18
17
|
import { sendOnRampWidgetCloseEvent } from './OnRampWidgetEvents';
|
|
@@ -87,29 +86,29 @@ export class OnRamp extends Base<WidgetType.ONRAMP> {
|
|
|
87
86
|
|
|
88
87
|
this.reactRoot.render(
|
|
89
88
|
<React.StrictMode>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
89
|
+
|
|
90
|
+
<ThemeProvider id="onramp-container" config={this.strongConfig()}>
|
|
91
|
+
<HandoverProvider>
|
|
92
|
+
<ConnectLoader
|
|
93
|
+
widgetConfig={this.strongConfig()}
|
|
94
|
+
params={connectLoaderParams}
|
|
95
|
+
closeEvent={() => sendOnRampWidgetCloseEvent(window)}
|
|
96
|
+
goBackEvent={() => this.goBackEvent(window)}
|
|
97
|
+
showBackButton={this.parameters.showBackButton}
|
|
98
|
+
>
|
|
99
|
+
<Suspense fallback={<LoadingView loadingText={t('views.ONRAMP.initialLoadingText')} />}>
|
|
100
|
+
<OnRampWidget
|
|
101
|
+
tokenAddress={this.parameters.tokenAddress}
|
|
102
|
+
amount={this.parameters.amount}
|
|
103
|
+
config={this.strongConfig()}
|
|
104
|
+
showBackButton={this.parameters.showBackButton}
|
|
105
|
+
onrampConfig={this.properties.config}
|
|
106
|
+
/>
|
|
107
|
+
</Suspense>
|
|
108
|
+
</ConnectLoader>
|
|
109
|
+
</HandoverProvider>
|
|
110
|
+
</ThemeProvider>
|
|
111
|
+
|
|
113
112
|
</React.StrictMode>,
|
|
114
113
|
);
|
|
115
114
|
}
|
|
@@ -21,10 +21,6 @@ import {
|
|
|
21
21
|
} from '../../../context/view-context/ViewContext';
|
|
22
22
|
import { OnRampWidgetViews } from '../../../context/view-context/OnRampViewContextTypes';
|
|
23
23
|
import { boxMainStyle, containerStyle } from './onRampStyles';
|
|
24
|
-
import {
|
|
25
|
-
useAnalytics,
|
|
26
|
-
UserJourney,
|
|
27
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
28
24
|
import {
|
|
29
25
|
TransakEventData,
|
|
30
26
|
TransakEvents,
|
|
@@ -34,7 +30,6 @@ import { ConnectLoaderContext } from '../../../context/connect-loader-context/Co
|
|
|
34
30
|
import { EventTargetContext } from '../../../context/event-target-context/EventTargetContext';
|
|
35
31
|
import { TRANSAK_ORIGIN } from '../../../components/Transak/useTransakEvents';
|
|
36
32
|
import { orchestrationEvents } from '../../../lib/orchestrationEvents';
|
|
37
|
-
import { isPassportProvider } from '../../../lib/provider';
|
|
38
33
|
|
|
39
34
|
const transakIframeId = 'transak-iframe';
|
|
40
35
|
const IN_PROGRESS_VIEW_DELAY_MS = 6000; // 6 second
|
|
@@ -80,17 +75,6 @@ function useWidgetUrl(
|
|
|
80
75
|
return widgetUrl;
|
|
81
76
|
}
|
|
82
77
|
|
|
83
|
-
function useWalletAddress(provider: WrappedBrowserProvider | undefined) {
|
|
84
|
-
const [userWalletAddress, setUserWalletAddress] = useState<string | undefined>(undefined);
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
if (!provider) return;
|
|
88
|
-
provider.getSigner().then((signer) => signer.getAddress()).then(setUserWalletAddress);
|
|
89
|
-
}, [provider]);
|
|
90
|
-
|
|
91
|
-
return userWalletAddress;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
78
|
export function OnRampMain({
|
|
95
79
|
passport,
|
|
96
80
|
showIframe,
|
|
@@ -111,12 +95,9 @@ export function OnRampMain({
|
|
|
111
95
|
const { t } = useTranslation();
|
|
112
96
|
const { viewState, viewDispatch } = useContext(ViewContext);
|
|
113
97
|
const widgetUrl = useWidgetUrl(checkout, provider, tokenAddress, tokenAmount, passport, showMenu, customSubTitle);
|
|
114
|
-
const userWalletAddress = useWalletAddress(provider);
|
|
115
98
|
|
|
116
99
|
const eventTimer = useRef<number | undefined>();
|
|
117
100
|
|
|
118
|
-
const isPassport = !!passport && isPassportProvider(provider);
|
|
119
|
-
|
|
120
101
|
const openedFromTopUpView = useMemo(
|
|
121
102
|
() => viewState.history.length > 2
|
|
122
103
|
&& viewState.history[viewState.history.length - 2].type
|
|
@@ -125,76 +106,6 @@ export function OnRampMain({
|
|
|
125
106
|
);
|
|
126
107
|
|
|
127
108
|
const showBack = showBackButton || openedFromTopUpView;
|
|
128
|
-
|
|
129
|
-
const { track } = useAnalytics();
|
|
130
|
-
|
|
131
|
-
const trackSegmentEvents = useCallback(async (
|
|
132
|
-
event: TransakEventData,
|
|
133
|
-
walletAddress: string,
|
|
134
|
-
) => {
|
|
135
|
-
const miscProps = {
|
|
136
|
-
userId: walletAddress.toLowerCase(),
|
|
137
|
-
isPassportWallet: isPassport,
|
|
138
|
-
};
|
|
139
|
-
switch (event.event_id) {
|
|
140
|
-
case TransakEvents.TRANSAK_WIDGET_OPEN:
|
|
141
|
-
track({
|
|
142
|
-
userJourney: UserJourney.ON_RAMP,
|
|
143
|
-
screen: 'InputScreen',
|
|
144
|
-
control: 'TransakWidgetOpen',
|
|
145
|
-
controlType: 'IframeEvent',
|
|
146
|
-
extras: { ...miscProps },
|
|
147
|
-
}); // checkoutOnRampInputScreen_TransakWidgetOpenIframeEvent
|
|
148
|
-
break;
|
|
149
|
-
case TransakEvents.TRANSAK_ORDER_CREATED:
|
|
150
|
-
track({
|
|
151
|
-
userJourney: UserJourney.ON_RAMP,
|
|
152
|
-
screen: 'InputScreen',
|
|
153
|
-
control: 'OrderCreated',
|
|
154
|
-
controlType: 'IframeEvent',
|
|
155
|
-
extras: { ...miscProps },
|
|
156
|
-
}); // checkoutOnRampInputScreen_OrderCreatedIframeEvent
|
|
157
|
-
break;
|
|
158
|
-
case TransakEvents.TRANSAK_ORDER_SUCCESSFUL:
|
|
159
|
-
if (event.data.status === TransakStatuses.PROCESSING) {
|
|
160
|
-
// user paid
|
|
161
|
-
track({
|
|
162
|
-
userJourney: UserJourney.ON_RAMP,
|
|
163
|
-
screen: 'OrderInProgress',
|
|
164
|
-
control: 'PaymentProcessing',
|
|
165
|
-
controlType: 'IframeEvent',
|
|
166
|
-
extras: {
|
|
167
|
-
...miscProps,
|
|
168
|
-
transactionHash: event.data.transactionHash,
|
|
169
|
-
},
|
|
170
|
-
}); // checkoutOnRampOrderInProgress_PaymentProcessingIframeEvent
|
|
171
|
-
}
|
|
172
|
-
if (event.data.status === TransakStatuses.COMPLETED) {
|
|
173
|
-
track({
|
|
174
|
-
userJourney: UserJourney.ON_RAMP,
|
|
175
|
-
screen: 'Success',
|
|
176
|
-
control: 'PaymentCompleted',
|
|
177
|
-
controlType: 'IframeEvent',
|
|
178
|
-
extras: {
|
|
179
|
-
...miscProps,
|
|
180
|
-
transactionHash: event.data.transactionHash,
|
|
181
|
-
},
|
|
182
|
-
}); // checkoutOnRampSuccess_PaymentCompletedIframeEvent
|
|
183
|
-
}
|
|
184
|
-
break;
|
|
185
|
-
case TransakEvents.TRANSAK_ORDER_FAILED: // payment failed
|
|
186
|
-
track({
|
|
187
|
-
userJourney: UserJourney.ON_RAMP,
|
|
188
|
-
screen: 'Failure',
|
|
189
|
-
control: 'PaymentFailed',
|
|
190
|
-
controlType: 'IframeEvent',
|
|
191
|
-
extras: { ...miscProps },
|
|
192
|
-
}); // checkoutOnRampFailure_PaymentFailedIframeEvent
|
|
193
|
-
break;
|
|
194
|
-
default:
|
|
195
|
-
}
|
|
196
|
-
}, [isPassport, track]);
|
|
197
|
-
|
|
198
109
|
const transakEventHandler = useCallback((event: TransakEventData) => {
|
|
199
110
|
if (eventTimer.current) clearTimeout(eventTimer.current);
|
|
200
111
|
|
|
@@ -291,7 +202,6 @@ export function OnRampMain({
|
|
|
291
202
|
&& host
|
|
292
203
|
&& TRANSAK_ORIGIN.includes(host)
|
|
293
204
|
) {
|
|
294
|
-
trackSegmentEvents(event.data, userWalletAddress ?? '');
|
|
295
205
|
transakEventHandler(event.data);
|
|
296
206
|
}
|
|
297
207
|
};
|
|
@@ -302,7 +212,7 @@ export function OnRampMain({
|
|
|
302
212
|
return () => {
|
|
303
213
|
window.removeEventListener('message', handleTransakEvents);
|
|
304
214
|
};
|
|
305
|
-
}, [
|
|
215
|
+
}, [transakEventHandler]);
|
|
306
216
|
|
|
307
217
|
return (
|
|
308
218
|
<Box sx={boxMainStyle(showIframe)}>
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import React, { Suspense } from 'react';
|
|
10
10
|
import { Base } from '../BaseWidgetRoot';
|
|
11
11
|
import i18n from '../../i18n';
|
|
12
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
13
12
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
14
13
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
15
14
|
import { ProvidersContextProvider } from '../../context/providers-context/ProvidersContext';
|
|
@@ -70,29 +69,29 @@ export class Purchase extends Base<WidgetType.PURCHASE> {
|
|
|
70
69
|
|
|
71
70
|
this.reactRoot.render(
|
|
72
71
|
<React.StrictMode>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
|
|
73
|
+
<ThemeProvider id="purchase-container" config={this.strongConfig()}>
|
|
74
|
+
<HandoverProvider>
|
|
75
|
+
<ProvidersContextProvider
|
|
76
|
+
initialState={{
|
|
77
|
+
checkout: this.checkout,
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<Suspense
|
|
81
|
+
fallback={
|
|
82
|
+
<LoadingView loadingText={t('views.LOADING_VIEW.text')} />
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
>
|
|
85
|
+
<PurchaseWidget
|
|
86
|
+
config={this.strongConfig()}
|
|
87
|
+
environmentId={this.parameters.environmentId!}
|
|
88
|
+
items={this.parameters.items!}
|
|
89
|
+
/>
|
|
90
|
+
</Suspense>
|
|
91
|
+
</ProvidersContextProvider>
|
|
92
|
+
</HandoverProvider>
|
|
93
|
+
</ThemeProvider>
|
|
94
|
+
|
|
96
95
|
</React.StrictMode>,
|
|
97
96
|
);
|
|
98
97
|
}
|