@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
|
@@ -12,12 +12,10 @@ import { MenuItemProps } from '@biom3/react';
|
|
|
12
12
|
import { UnableToConnectDrawer } from '../../../components/UnableToConnectDrawer/UnableToConnectDrawer';
|
|
13
13
|
import { WalletDrawer } from '../../../components/WalletDrawer/WalletDrawer';
|
|
14
14
|
import { WalletChangeEvent } from '../../../components/WalletDrawer/WalletDrawerEvents';
|
|
15
|
-
import { useAnalytics, UserJourney } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
16
15
|
import { useProvidersContext, ProvidersContextActions } from '../../../context/providers-context/ProvidersContext';
|
|
17
|
-
import { identifyUser } from '../../../lib/analytics/identifyUser';
|
|
18
16
|
import { ConnectEIP6963ProviderError, connectEIP6963Provider } from '../../../lib/connectEIP6963Provider';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
17
|
+
import { } from '../../../lib/provider';
|
|
18
|
+
import { } from '../../../lib/utils';
|
|
21
19
|
|
|
22
20
|
type PurchaseConnectWalletDrawerProps = {
|
|
23
21
|
heading: string;
|
|
@@ -28,7 +26,6 @@ type PurchaseConnectWalletDrawerProps = {
|
|
|
28
26
|
providerInfo: EIP6963ProviderInfo
|
|
29
27
|
) => void;
|
|
30
28
|
onError?: (errorType: ConnectEIP6963ProviderError) => void;
|
|
31
|
-
providerType: 'from' | 'to';
|
|
32
29
|
walletOptions: EIP6963ProviderDetail[];
|
|
33
30
|
bottomSlot?: ReactNode;
|
|
34
31
|
menuItemSize?: MenuItemProps['size'];
|
|
@@ -36,7 +33,6 @@ type PurchaseConnectWalletDrawerProps = {
|
|
|
36
33
|
label: string;
|
|
37
34
|
rdns: string;
|
|
38
35
|
}[];
|
|
39
|
-
shouldIdentifyUser?: boolean;
|
|
40
36
|
drawerBackground: string | undefined;
|
|
41
37
|
};
|
|
42
38
|
|
|
@@ -46,21 +42,16 @@ export function PurchaseConnectWalletDrawer({
|
|
|
46
42
|
onClose,
|
|
47
43
|
onConnect,
|
|
48
44
|
onError,
|
|
49
|
-
providerType,
|
|
50
45
|
walletOptions,
|
|
51
46
|
bottomSlot,
|
|
52
47
|
menuItemSize = 'small',
|
|
53
48
|
disabledOptions = [],
|
|
54
|
-
shouldIdentifyUser = true,
|
|
55
49
|
drawerBackground,
|
|
56
50
|
}: PurchaseConnectWalletDrawerProps) {
|
|
57
51
|
const {
|
|
58
52
|
providersState: { checkout },
|
|
59
53
|
providersDispatch,
|
|
60
54
|
} = useProvidersContext();
|
|
61
|
-
|
|
62
|
-
const { identify, track, user } = useAnalytics();
|
|
63
|
-
|
|
64
55
|
const prevWalletChangeEvent = useRef<WalletChangeEvent | undefined>();
|
|
65
56
|
|
|
66
57
|
const [showUnableToConnectDrawer, setShowUnableToConnectDrawer] = useState(false);
|
|
@@ -94,20 +85,6 @@ export function PurchaseConnectWalletDrawer({
|
|
|
94
85
|
const handleWalletConnection = async (event: WalletChangeEvent) => {
|
|
95
86
|
const { providerDetail } = event;
|
|
96
87
|
const { info } = providerDetail;
|
|
97
|
-
|
|
98
|
-
// Trigger analytics connect wallet, menu item, with wallet details
|
|
99
|
-
track({
|
|
100
|
-
userJourney: UserJourney.CONNECT,
|
|
101
|
-
screen: 'ConnectWallet',
|
|
102
|
-
control: removeSpace(info.name),
|
|
103
|
-
controlType: 'MenuItem',
|
|
104
|
-
extras: {
|
|
105
|
-
providerType,
|
|
106
|
-
wallet: getProviderSlugFromRdns(info.rdns),
|
|
107
|
-
walletRdns: info.rdns,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
88
|
if (info.rdns === WalletProviderRdns.PASSPORT) {
|
|
112
89
|
const { isConnected } = await checkout.checkIsWalletConnected({
|
|
113
90
|
provider: new WrappedBrowserProvider(providerDetail.provider!),
|
|
@@ -126,15 +103,6 @@ export function PurchaseConnectWalletDrawer({
|
|
|
126
103
|
checkout,
|
|
127
104
|
true,
|
|
128
105
|
);
|
|
129
|
-
|
|
130
|
-
// Identify connected wallet, retaining current anonymousId
|
|
131
|
-
if (shouldIdentifyUser) {
|
|
132
|
-
const userData = user ? await user() : undefined;
|
|
133
|
-
const anonymousId = userData?.anonymousId();
|
|
134
|
-
|
|
135
|
-
await identifyUser(identify, provider, { anonymousId });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
106
|
// Store selected provider as fromProvider in context
|
|
139
107
|
address = await setProviderInContext(provider, providerDetail.info);
|
|
140
108
|
|
|
@@ -38,7 +38,6 @@ export function PurchaseDeliverToWalletDrawer({
|
|
|
38
38
|
heading={t('drawers.wallet.deliverToHeading')}
|
|
39
39
|
visible={visible}
|
|
40
40
|
onClose={onClose}
|
|
41
|
-
providerType="to"
|
|
42
41
|
walletOptions={walletOptions}
|
|
43
42
|
onConnect={handleOnConnect}
|
|
44
43
|
drawerBackground={drawerBackground}
|
|
@@ -75,12 +75,10 @@ export function PurchasePayWithWalletDrawer({
|
|
|
75
75
|
}
|
|
76
76
|
visible={visible}
|
|
77
77
|
onClose={onClose}
|
|
78
|
-
providerType="from"
|
|
79
78
|
walletOptions={walletOptions}
|
|
80
79
|
disabledOptions={disabledOptions}
|
|
81
80
|
bottomSlot={payWithCardItem}
|
|
82
81
|
onConnect={handleOnConnect}
|
|
83
|
-
shouldIdentifyUser={false}
|
|
84
82
|
drawerBackground={drawerBackground}
|
|
85
83
|
/>
|
|
86
84
|
);
|
|
@@ -3,10 +3,9 @@ import {
|
|
|
3
3
|
} from '@biom3/react';
|
|
4
4
|
import { motion } from 'framer-motion';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
useRef, useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { Checkout } from '@imtbl/checkout-sdk';
|
|
9
|
-
import { useAnalytics, UserJourney } from '../../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
10
9
|
import { useProvidersContext } from '../../../../context/providers-context/ProvidersContext';
|
|
11
10
|
import { listVariants } from '../../../../lib/animation/listAnimation';
|
|
12
11
|
import { Chain, RouteData } from '../../../../lib/squid/types';
|
|
@@ -14,7 +13,6 @@ import {
|
|
|
14
13
|
DirectCryptoPayData, DirectCryptoPayOptionType, FiatOptionType, SquidRouteOptionType,
|
|
15
14
|
} from '../../types';
|
|
16
15
|
import { RouteOptions } from './RouteOptions';
|
|
17
|
-
import { PurchaseContext } from '../../context/PurchaseContext';
|
|
18
16
|
|
|
19
17
|
type OptionsDrawerProps = {
|
|
20
18
|
checkout: Checkout;
|
|
@@ -53,12 +51,6 @@ export function RouteOptionsDrawer({
|
|
|
53
51
|
insufficientBalance,
|
|
54
52
|
directCryptoPayRoutes,
|
|
55
53
|
}: OptionsDrawerProps) {
|
|
56
|
-
const { track } = useAnalytics();
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
purchaseState: { id },
|
|
60
|
-
} = useContext(PurchaseContext);
|
|
61
|
-
|
|
62
54
|
const {
|
|
63
55
|
providersState: { fromProviderInfo, fromAddress },
|
|
64
56
|
} = useProvidersContext();
|
|
@@ -84,27 +76,6 @@ export function RouteOptionsDrawer({
|
|
|
84
76
|
onChangeWalletClick();
|
|
85
77
|
};
|
|
86
78
|
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (!visible) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
track({
|
|
93
|
-
userJourney: UserJourney.PURCHASE,
|
|
94
|
-
screen: 'InputScreen',
|
|
95
|
-
control: 'RoutesMenu',
|
|
96
|
-
controlType: 'MenuItem',
|
|
97
|
-
action: 'Opened',
|
|
98
|
-
extras: {
|
|
99
|
-
contextId: id,
|
|
100
|
-
showOnrampOption: Boolean(showOnrampOption),
|
|
101
|
-
showSwapOption: Boolean(showSwapOption),
|
|
102
|
-
insufficientBalance: Boolean(insufficientBalance),
|
|
103
|
-
routesAvailable: routes?.length ?? 0,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}, [visible]);
|
|
107
|
-
|
|
108
79
|
return (
|
|
109
80
|
<Drawer
|
|
110
81
|
size="full"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useContext, useMemo } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { WalletProviderRdns } from '@imtbl/checkout-sdk';
|
|
4
3
|
import { PurchaseContext } from '../context/PurchaseContext';
|
|
5
4
|
import { TransakIframe } from '../../../components/Transak/TransakIframe';
|
|
6
5
|
import { TransakNFTData } from '../../../components/Transak/TransakTypes';
|
|
@@ -36,7 +35,6 @@ export function WithCard(props: WithCardProps) {
|
|
|
36
35
|
|
|
37
36
|
const {
|
|
38
37
|
providersState: {
|
|
39
|
-
toProviderInfo,
|
|
40
38
|
toAddress,
|
|
41
39
|
checkout,
|
|
42
40
|
},
|
|
@@ -44,7 +42,6 @@ export function WithCard(props: WithCardProps) {
|
|
|
44
42
|
|
|
45
43
|
const recipientEmail = '';
|
|
46
44
|
const recipientAddress = toAddress || '';
|
|
47
|
-
const isPassportWallet = toProviderInfo?.rdns === WalletProviderRdns.PASSPORT;
|
|
48
45
|
const excludeFiatCurrencies = [];
|
|
49
46
|
const { environment } = checkout.config;
|
|
50
47
|
const executeTxn = signResponse?.transactions.find((txn) => txn.methodCall.startsWith('execute'));
|
|
@@ -73,7 +70,6 @@ export function WithCard(props: WithCardProps) {
|
|
|
73
70
|
type="nft-checkout"
|
|
74
71
|
email={recipientEmail}
|
|
75
72
|
walletAddress={recipientAddress}
|
|
76
|
-
isPassportWallet={isPassportWallet}
|
|
77
73
|
exchangeScreenTitle={t('views.PAY_WITH_CARD.screenTitle')}
|
|
78
74
|
nftData={nftData}
|
|
79
75
|
calldata={executeTxn.rawData}
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from 'react';
|
|
15
15
|
import { TokenBalance } from '@0xsquid/sdk/dist/types';
|
|
16
16
|
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
17
|
-
import { UserJourney } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
18
17
|
import { CryptoFiatContext, CryptoFiatActions } from '../../../context/crypto-fiat-context/CryptoFiatContext';
|
|
19
18
|
import { EventTargetContext } from '../../../context/event-target-context/EventTargetContext';
|
|
20
19
|
import { useProvidersContext } from '../../../context/providers-context/ProvidersContext';
|
|
@@ -124,7 +123,7 @@ export function Purchase({
|
|
|
124
123
|
|
|
125
124
|
const {
|
|
126
125
|
getAllowance, approve, execute, getStatus,
|
|
127
|
-
} = useExecute(
|
|
126
|
+
} = useExecute('Purchase', (err) => {
|
|
128
127
|
// eslint-disable-next-line no-console
|
|
129
128
|
console.log('useExecute err', err);
|
|
130
129
|
});
|
|
@@ -33,7 +33,6 @@ import { PaymentMethods } from './views/PaymentMethods';
|
|
|
33
33
|
import { SaleErrorView } from './views/SaleErrorView';
|
|
34
34
|
import { CryptoFiatProvider } from '../../context/crypto-fiat-context/CryptoFiatProvider';
|
|
35
35
|
import { TopUpView } from '../../views/top-up/TopUpView';
|
|
36
|
-
import { UserJourney } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
37
36
|
import { sendSaleWidgetCloseEvent } from './SaleWidgetEvents';
|
|
38
37
|
import { EventTargetContext } from '../../context/event-target-context/EventTargetContext';
|
|
39
38
|
import { OrderSummary } from './views/OrderSummary';
|
|
@@ -171,7 +170,6 @@ export default function SaleWidget(props: SaleWidgetProps) {
|
|
|
171
170
|
)}
|
|
172
171
|
{viewState.view.type === SharedViews.TOP_UP_VIEW && (
|
|
173
172
|
<TopUpView
|
|
174
|
-
analytics={{ userJourney: UserJourney.SALE }}
|
|
175
173
|
widgetEvent={IMTBLWidgetEvents.IMTBL_SALE_WIDGET_EVENT}
|
|
176
174
|
checkout={checkout}
|
|
177
175
|
provider={provider}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '../../components/ConnectLoader/ConnectLoader';
|
|
18
18
|
import { isValidWalletProvider } from '../../lib/validations/widgetValidators';
|
|
19
19
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
20
|
-
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
21
20
|
import { LoadingView } from '../../views/loading/LoadingView';
|
|
22
21
|
import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
|
|
23
22
|
import { sendSaleWidgetCloseEvent } from './SaleWidgetEvents';
|
|
@@ -131,46 +130,46 @@ export class Sale extends Base<WidgetType.SALE> {
|
|
|
131
130
|
|
|
132
131
|
this.reactRoot.render(
|
|
133
132
|
<React.StrictMode>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
|
|
134
|
+
<ThemeProvider id="sale-container" config={config}>
|
|
135
|
+
<HandoverProvider>
|
|
136
|
+
<ConnectLoader
|
|
137
|
+
widgetConfig={config}
|
|
138
|
+
params={connectLoaderParams}
|
|
139
|
+
closeEvent={() => {
|
|
140
|
+
sendSaleWidgetCloseEvent(window);
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
<Suspense
|
|
144
|
+
fallback={
|
|
145
|
+
<LoadingView loadingText={t('views.LOADING_VIEW.text')} />
|
|
147
146
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
>
|
|
148
|
+
<SaleWidget
|
|
149
|
+
config={config}
|
|
150
|
+
items={this.parameters.items!}
|
|
151
|
+
language={this.parameters.language as WidgetLanguage}
|
|
152
|
+
environmentId={this.parameters.environmentId!}
|
|
153
|
+
collectionName={this.parameters.collectionName!}
|
|
154
|
+
excludePaymentTypes={this.parameters.excludePaymentTypes!}
|
|
155
|
+
excludeFiatCurrencies={
|
|
157
156
|
this.parameters.excludeFiatCurrencies!
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
preferredCurrency={this.parameters.preferredCurrency!}
|
|
159
|
+
customOrderData={this.parameters.customOrderData!}
|
|
160
|
+
hideExcludedPaymentTypes={
|
|
162
161
|
this.properties?.config?.hideExcludedPaymentTypes ?? false
|
|
163
162
|
}
|
|
164
|
-
|
|
163
|
+
waitFulfillmentSettlements={
|
|
165
164
|
this.properties?.config?.waitFulfillmentSettlements
|
|
166
165
|
?? true
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
/>
|
|
168
|
+
</Suspense>
|
|
169
|
+
</ConnectLoader>
|
|
170
|
+
</HandoverProvider>
|
|
171
|
+
</ThemeProvider>
|
|
172
|
+
|
|
174
173
|
</React.StrictMode>,
|
|
175
174
|
);
|
|
176
175
|
}
|
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
TransactionRequirement,
|
|
11
11
|
} from '@imtbl/checkout-sdk';
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
SaleWidgetViews,
|
|
13
|
+
|
|
15
14
|
} from '../../../context/view-context/SaleViewContextTypes';
|
|
16
15
|
import { calculateCryptoToFiat, tokenValueFormat } from '../../../lib/utils';
|
|
17
16
|
import { HeaderNavigation } from '../../../components/Header/HeaderNavigation';
|
|
@@ -29,8 +28,6 @@ import {
|
|
|
29
28
|
} from '../functions/fundingBalanceFees';
|
|
30
29
|
import { FeesDisplay, OrderFees } from './OrderFees';
|
|
31
30
|
import { useSaleContext } from '../context/SaleContextProvider';
|
|
32
|
-
import { getPaymentTokenDetails } from '../utils/analytics';
|
|
33
|
-
import { useMount } from '../../../hooks/useMount';
|
|
34
31
|
|
|
35
32
|
type OrderReviewProps = {
|
|
36
33
|
collectionName: string;
|
|
@@ -67,7 +64,7 @@ export function OrderReview({
|
|
|
67
64
|
selectedCurrency,
|
|
68
65
|
config: { theme, environment },
|
|
69
66
|
} = useSaleContext();
|
|
70
|
-
const { sendSelectedPaymentToken
|
|
67
|
+
const { sendSelectedPaymentToken } = useSaleEvent();
|
|
71
68
|
|
|
72
69
|
const [showCoinsDrawer, setShowCoinsDrawer] = useState(false);
|
|
73
70
|
const [selectedCurrencyIndex, setSelectedCurrencyIndex] = useState(0);
|
|
@@ -92,7 +89,6 @@ export function OrderReview({
|
|
|
92
89
|
setSelectedCurrencyIndex(selectedIndex);
|
|
93
90
|
|
|
94
91
|
sendSelectedPaymentToken(
|
|
95
|
-
OrderSummarySubViews.REVIEW_ORDER,
|
|
96
92
|
fundingBalances[selectedIndex],
|
|
97
93
|
conversions,
|
|
98
94
|
);
|
|
@@ -175,27 +171,6 @@ export function OrderReview({
|
|
|
175
171
|
});
|
|
176
172
|
}, [gasFees, fundingBalance, conversions]);
|
|
177
173
|
|
|
178
|
-
// Trigger page loaded event
|
|
179
|
-
useMount(
|
|
180
|
-
() => {
|
|
181
|
-
const tokens = fundingBalances.map((fb) => getPaymentTokenDetails(fb, conversions));
|
|
182
|
-
sendPageView(SaleWidgetViews.ORDER_SUMMARY, {
|
|
183
|
-
subView: OrderSummarySubViews.REVIEW_ORDER,
|
|
184
|
-
tokens,
|
|
185
|
-
items,
|
|
186
|
-
collectionName,
|
|
187
|
-
});
|
|
188
|
-
// checkoutPrimarySaleOrderSummaryViewed
|
|
189
|
-
},
|
|
190
|
-
() => Boolean(
|
|
191
|
-
items.length
|
|
192
|
-
&& fundingBalances.length
|
|
193
|
-
&& !loadingBalances
|
|
194
|
-
&& conversions.size,
|
|
195
|
-
),
|
|
196
|
-
[items, fundingBalances, loadingBalances, conversions],
|
|
197
|
-
);
|
|
198
|
-
|
|
199
174
|
const multiple = items.length > 1;
|
|
200
175
|
const withFees = transactionFees.formattedFees.length > 0;
|
|
201
176
|
|
|
@@ -257,7 +232,6 @@ export function OrderReview({
|
|
|
257
232
|
borderTopWidth: 'base.border.size.200',
|
|
258
233
|
borderTopColor: 'base.color.translucent.inverse.1000',
|
|
259
234
|
}}
|
|
260
|
-
onFeesClick={() => sendViewFeesEvent(SaleWidgetViews.ORDER_SUMMARY)}
|
|
261
235
|
/>
|
|
262
236
|
)}
|
|
263
237
|
</OrderItems>
|
|
@@ -274,7 +248,6 @@ export function OrderReview({
|
|
|
274
248
|
borderTopWidth: 'base.border.size.100',
|
|
275
249
|
borderTopColor: 'base.color.translucent.emphasis.400',
|
|
276
250
|
}}
|
|
277
|
-
onFeesClick={() => sendViewFeesEvent(SaleWidgetViews.ORDER_SUMMARY)}
|
|
278
251
|
/>
|
|
279
252
|
)}
|
|
280
253
|
<SelectCoinDropdown
|
|
@@ -27,7 +27,6 @@ export function WithCard(props: WithCardProps) {
|
|
|
27
27
|
const {
|
|
28
28
|
recipientEmail,
|
|
29
29
|
recipientAddress,
|
|
30
|
-
isPassportWallet,
|
|
31
30
|
signResponse,
|
|
32
31
|
goToErrorView,
|
|
33
32
|
environment,
|
|
@@ -64,7 +63,6 @@ export function WithCard(props: WithCardProps) {
|
|
|
64
63
|
type="nft-checkout"
|
|
65
64
|
email={recipientEmail}
|
|
66
65
|
walletAddress={recipientAddress}
|
|
67
|
-
isPassportWallet={isPassportWallet}
|
|
68
66
|
exchangeScreenTitle={t('views.PAY_WITH_CARD.screenTitle')}
|
|
69
67
|
nftData={nftData}
|
|
70
68
|
calldata={executeTxn.rawData}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import { StandardAnalyticsActions } from '@imtbl/react-analytics';
|
|
3
2
|
import { SalePaymentTypes } from '@imtbl/checkout-sdk';
|
|
4
|
-
import {
|
|
5
|
-
UserJourney,
|
|
6
|
-
useAnalytics,
|
|
7
|
-
AnalyticsControlTypes,
|
|
8
|
-
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
9
3
|
import { EventTargetContext } from '../../../context/event-target-context/EventTargetContext';
|
|
10
4
|
import {
|
|
11
5
|
sendSaleFailedEvent,
|
|
@@ -15,75 +9,25 @@ import {
|
|
|
15
9
|
sendSalePaymentMethodEvent,
|
|
16
10
|
sendSalePaymentTokenEvent,
|
|
17
11
|
} from '../SaleWidgetEvents';
|
|
18
|
-
import { SaleWidgetViews } from '../../../context/view-context/SaleViewContextTypes';
|
|
19
12
|
import { ExecutedTransaction, FundingBalance } from '../types';
|
|
20
13
|
import { useSaleContext } from '../context/SaleContextProvider';
|
|
21
|
-
import { toPascalCase, toStringifyTransactions } from '../functions/utils';
|
|
22
14
|
import { getPaymentTokenDetails } from '../utils/analytics';
|
|
23
15
|
|
|
24
16
|
export const useSaleEvent = () => {
|
|
25
|
-
const {
|
|
26
|
-
const {
|
|
27
|
-
recipientAddress: userId,
|
|
28
|
-
signResponse,
|
|
29
|
-
paymentMethod,
|
|
30
|
-
} = useSaleContext();
|
|
17
|
+
const { paymentMethod } = useSaleContext();
|
|
31
18
|
const {
|
|
32
19
|
eventTargetState: { eventTarget },
|
|
33
20
|
} = useContext(EventTargetContext);
|
|
34
|
-
const defaultView = SaleWidgetViews.PAYMENT_METHODS;
|
|
35
|
-
const commonProps = {
|
|
36
|
-
location: 'web',
|
|
37
|
-
userJourney: UserJourney.SALE,
|
|
38
|
-
};
|
|
39
|
-
const userProps = {
|
|
40
|
-
userId,
|
|
41
|
-
paymentMethod,
|
|
42
|
-
};
|
|
43
|
-
const orderProps = {
|
|
44
|
-
amount: signResponse?.order.totalAmount,
|
|
45
|
-
currency: signResponse?.order.currency.name,
|
|
46
|
-
};
|
|
47
21
|
|
|
48
|
-
const sendCloseEvent = (
|
|
49
|
-
screen: string = defaultView,
|
|
50
|
-
controlType: AnalyticsControlTypes = 'Button',
|
|
51
|
-
action: StandardAnalyticsActions = 'Pressed',
|
|
52
|
-
) => {
|
|
53
|
-
track({
|
|
54
|
-
...commonProps,
|
|
55
|
-
screen: toPascalCase(screen),
|
|
56
|
-
control: 'Close',
|
|
57
|
-
controlType,
|
|
58
|
-
action,
|
|
59
|
-
extras: {
|
|
60
|
-
...userProps,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
22
|
+
const sendCloseEvent = () => {
|
|
63
23
|
sendSaleWidgetCloseEvent(eventTarget);
|
|
64
24
|
};
|
|
65
25
|
|
|
66
26
|
const sendSuccessEvent = (
|
|
67
|
-
screen: string = defaultView,
|
|
68
27
|
transactions: ExecutedTransaction[] = [],
|
|
69
28
|
tokenIds: string[] = [],
|
|
70
29
|
details: Record<string, any> = {},
|
|
71
30
|
) => {
|
|
72
|
-
track({
|
|
73
|
-
...commonProps,
|
|
74
|
-
screen: toPascalCase(screen),
|
|
75
|
-
control: 'Success',
|
|
76
|
-
controlType: 'Event',
|
|
77
|
-
action: 'Succeeded',
|
|
78
|
-
extras: {
|
|
79
|
-
...details,
|
|
80
|
-
...userProps,
|
|
81
|
-
transactions: toStringifyTransactions(transactions),
|
|
82
|
-
...orderProps,
|
|
83
|
-
paymentMethod,
|
|
84
|
-
tokenIds,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
31
|
sendSaleSuccessEvent(
|
|
88
32
|
eventTarget,
|
|
89
33
|
paymentMethod,
|
|
@@ -97,25 +41,8 @@ export const useSaleEvent = () => {
|
|
|
97
41
|
reason: string,
|
|
98
42
|
error: Record<string, unknown>,
|
|
99
43
|
transactions: ExecutedTransaction[] = [],
|
|
100
|
-
screen: string = defaultView,
|
|
101
44
|
details: Record<string, any> = {},
|
|
102
45
|
) => {
|
|
103
|
-
track({
|
|
104
|
-
...commonProps,
|
|
105
|
-
screen: toPascalCase(screen || defaultView),
|
|
106
|
-
control: 'Fail',
|
|
107
|
-
controlType: 'Event',
|
|
108
|
-
action: 'Failed',
|
|
109
|
-
extras: {
|
|
110
|
-
...details,
|
|
111
|
-
transactions: toStringifyTransactions(transactions),
|
|
112
|
-
...error,
|
|
113
|
-
...orderProps,
|
|
114
|
-
...userProps,
|
|
115
|
-
paymentMethod,
|
|
116
|
-
reason,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
46
|
sendSaleFailedEvent(
|
|
120
47
|
eventTarget,
|
|
121
48
|
reason,
|
|
@@ -130,133 +57,24 @@ export const useSaleEvent = () => {
|
|
|
130
57
|
sendSaleTransactionSuccessEvent(eventTarget, paymentMethod, [transaction]);
|
|
131
58
|
};
|
|
132
59
|
|
|
133
|
-
const sendSelectedPaymentMethod = (
|
|
134
|
-
type: SalePaymentTypes,
|
|
135
|
-
screen: string,
|
|
136
|
-
) => {
|
|
137
|
-
track({
|
|
138
|
-
...commonProps,
|
|
139
|
-
screen: toPascalCase(screen),
|
|
140
|
-
control: 'Select',
|
|
141
|
-
controlType: 'MenuItem',
|
|
142
|
-
extras: {
|
|
143
|
-
paymentMethod: type,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
60
|
+
const sendSelectedPaymentMethod = (type: SalePaymentTypes) => {
|
|
146
61
|
sendSalePaymentMethodEvent(eventTarget, type);
|
|
147
62
|
};
|
|
148
63
|
|
|
149
64
|
const sendSelectedPaymentToken = (
|
|
150
|
-
screen: string,
|
|
151
65
|
fundingBalance: FundingBalance,
|
|
152
66
|
conversions: Map<string, number>,
|
|
153
67
|
) => {
|
|
154
68
|
const details = getPaymentTokenDetails(fundingBalance, conversions);
|
|
155
|
-
track({
|
|
156
|
-
...commonProps,
|
|
157
|
-
screen: toPascalCase(screen),
|
|
158
|
-
control: 'Select',
|
|
159
|
-
controlType: 'MenuItem',
|
|
160
|
-
extras: {
|
|
161
|
-
...details,
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
69
|
sendSalePaymentTokenEvent(eventTarget, details);
|
|
165
70
|
};
|
|
166
71
|
|
|
167
|
-
const sendPageView = (screen: string, data?: Record<string, unknown>) => {
|
|
168
|
-
page({
|
|
169
|
-
...commonProps,
|
|
170
|
-
screen: toPascalCase(screen),
|
|
171
|
-
action: 'Viewed',
|
|
172
|
-
extras: { ...data },
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const sendOrderCreated = (
|
|
177
|
-
screen: string,
|
|
178
|
-
details: Record<string, unknown>,
|
|
179
|
-
) => {
|
|
180
|
-
track({
|
|
181
|
-
...commonProps,
|
|
182
|
-
screen: toPascalCase(screen),
|
|
183
|
-
control: 'OrderCreated',
|
|
184
|
-
controlType: 'Event',
|
|
185
|
-
extras: {
|
|
186
|
-
...details,
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const sendProceedToPay = (
|
|
192
|
-
screen: string,
|
|
193
|
-
fundingBalance: FundingBalance,
|
|
194
|
-
conversions: Map<string, number>,
|
|
195
|
-
controlType: AnalyticsControlTypes = 'Button',
|
|
196
|
-
action: StandardAnalyticsActions = 'Pressed',
|
|
197
|
-
) => {
|
|
198
|
-
track({
|
|
199
|
-
...commonProps,
|
|
200
|
-
screen: toPascalCase(screen),
|
|
201
|
-
control: 'ProceedToPay',
|
|
202
|
-
controlType,
|
|
203
|
-
action,
|
|
204
|
-
extras: {
|
|
205
|
-
...userProps,
|
|
206
|
-
...getPaymentTokenDetails(fundingBalance, conversions),
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const sendInsufficientFunds = (
|
|
212
|
-
screen: string,
|
|
213
|
-
txRequirements: any,
|
|
214
|
-
controlType: AnalyticsControlTypes = 'Event',
|
|
215
|
-
action: StandardAnalyticsActions = 'Viewed',
|
|
216
|
-
) => {
|
|
217
|
-
track({
|
|
218
|
-
...commonProps,
|
|
219
|
-
screen: toPascalCase(screen),
|
|
220
|
-
control: 'InsufficientFunds',
|
|
221
|
-
controlType,
|
|
222
|
-
action,
|
|
223
|
-
extras: {
|
|
224
|
-
...userProps,
|
|
225
|
-
...txRequirements,
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const sendViewFeesEvent = (
|
|
231
|
-
screen: string,
|
|
232
|
-
controlType: AnalyticsControlTypes = 'Button',
|
|
233
|
-
action: StandardAnalyticsActions = 'Pressed',
|
|
234
|
-
) => {
|
|
235
|
-
track({
|
|
236
|
-
...commonProps,
|
|
237
|
-
screen: toPascalCase(screen),
|
|
238
|
-
control: 'ViewFees',
|
|
239
|
-
controlType,
|
|
240
|
-
action,
|
|
241
|
-
extras: {
|
|
242
|
-
...userProps,
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
|
|
247
72
|
return {
|
|
248
|
-
track,
|
|
249
|
-
page,
|
|
250
|
-
sendPageView,
|
|
251
73
|
sendCloseEvent,
|
|
252
74
|
sendSuccessEvent,
|
|
253
75
|
sendFailedEvent,
|
|
254
76
|
sendTransactionSuccessEvent,
|
|
255
|
-
sendOrderCreated,
|
|
256
77
|
sendSelectedPaymentMethod,
|
|
257
78
|
sendSelectedPaymentToken,
|
|
258
|
-
sendProceedToPay,
|
|
259
|
-
sendViewFeesEvent,
|
|
260
|
-
sendInsufficientFunds,
|
|
261
79
|
};
|
|
262
80
|
};
|