@imtbl/sdk 1.53.0-alpha.6 → 1.53.0-alpha.7
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/{blockchain_data-w7eGZtId.js → blockchain_data-DyRQVX7o.js} +2 -2
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddFundsWidget-C6ASYdqF.js → AddFundsWidget-ElcJ_L46.js} +2 -2
- package/dist/browser/checkout/{BridgeWidget-1GH2Y2Gl.js → BridgeWidget-DagFbcal.js} +5 -5
- package/dist/browser/checkout/CheckoutWidget-BF_Ofszq.js +572 -0
- package/dist/browser/checkout/{OnRampWidget-MPFsrkh0.js → OnRampWidget-9xY2PrDk.js} +3 -3
- package/dist/browser/checkout/{SaleWidget-CrWruhMs.js → SaleWidget-E0v88XfM.js} +9 -9
- package/dist/browser/checkout/{SpendingCapHero-Cg4WWClJ.js → SpendingCapHero-B1bghRag.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-G1-gLvyX.js → SwapWidget-hn-faHAD.js} +6 -6
- package/dist/browser/checkout/{TextInputForm-DBjNTE6z.js → TextInputForm-4POGFRcV.js} +1 -1
- package/dist/browser/checkout/{TopUpView-CIYLtGDm.js → TopUpView-DrTM31Ek.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-qmZQrfmu.js → WalletWidget-DVoiXUbf.js} +3 -3
- package/dist/browser/checkout/{auto-track-DdiuplwC.js → auto-track-Cw1XS-c-.js} +1 -1
- package/dist/browser/checkout/{balance-CQ6fP7av.js → balance-Bj7GdprK.js} +2 -2
- package/dist/browser/checkout/{index-B0SLMzFD.js → index-B05c7t-P.js} +1 -1
- package/dist/browser/checkout/{index-CwmxMsoB.js → index-BquKGO7p.js} +1 -1
- package/dist/browser/checkout/{index-lfpKQnKo.js → index-ByNAok7N.js} +2 -2
- package/dist/browser/checkout/{index-DnzYLaf5.js → index-CmeUfKtu.js} +1 -1
- package/dist/browser/checkout/{index-CZhlFgfu.js → index-DFH1n4OP.js} +1 -1
- package/dist/browser/checkout/{index-BCU32pT8.js → index-_4pTEm9m.js} +50 -137
- package/dist/browser/checkout/{index-CxtFhfUN.js → index-foAjchT_.js} +1 -1
- package/dist/browser/checkout/{index-RA3Gu405.js → index-tlELt2aY.js} +1 -1
- package/dist/browser/checkout/{index.umd-BS53V8xY.js → index.umd-CC9QTEfd.js} +1 -1
- package/dist/browser/checkout/{retry-B3DoYkeU.js → retry-BpGE5FcR.js} +1 -1
- package/dist/browser/checkout/sdk.js +5 -5
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +564 -690
- package/dist/{checkout-C1zIEZPs.js → checkout-DvSQ_MbR.js} +12 -11
- package/dist/checkout.d.ts +25 -21
- package/dist/checkout.js +5 -5
- package/dist/{config-DeNfayBE.js → config-Ctb3WDc7.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-CwDvabKl.js → index-B7tbNRz3.js} +1 -1
- package/dist/{index-DLVtjrbG.js → index-BEM1LC_r.js} +1 -1
- package/dist/{index-CfjfP8sn.js → index-BPNLUTc8.js} +3 -3
- package/dist/{index-lG2LHAoD.js → index-BU2HrLRD.js} +4 -4
- package/dist/{index-DV0aIGc2.js → index-CAD31bOV.js} +1 -1
- package/dist/{index-K71Oiwci.js → index-DH89LU1z.js} +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -13
- package/dist/index.d.ts +27 -21
- package/dist/index.js +14 -14
- package/dist/{minting_backend-BKEnGwLD.js → minting_backend-Dp_n3cSM.js} +3 -3
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-CGAnYAHp.js → orderbook-mFNs950s.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-B6Lz7hKP.js → passport-Cf_z8B8S.js} +3 -3
- package/dist/passport.js +4 -4
- package/dist/{webhook-m3MlDT-v.js → webhook-UWyBNJsw.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-DwBvp11B.js → x-Ddg9N_Uj.js} +3 -3
- package/dist/x.js +4 -4
- package/package.json +1 -1
- package/dist/browser/checkout/CheckoutWidget-bKTdGSys.js +0 -600
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as APIError, B as BlockchainData } from './index-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { A as APIError, B as BlockchainData } from './index-BPNLUTc8.js';
|
|
2
|
+
import { i as index } from './index-CAD31bOV.js';
|
|
3
3
|
|
|
4
4
|
var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
5
5
|
__proto__: null,
|
package/dist/blockchain_data.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as APIError, B as BlockchainData } from './index-
|
|
2
|
-
export { i as Types } from './index-
|
|
3
|
-
import './index-
|
|
1
|
+
export { A as APIError, B as BlockchainData } from './index-BPNLUTc8.js';
|
|
2
|
+
export { i as Types } from './index-CAD31bOV.js';
|
|
3
|
+
import './index-B7tbNRz3.js';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'lru-memorise';
|
|
6
6
|
import 'global-const';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as reactExports, l as useTranslation,
|
|
2
|
-
import { T as TextInputForm } from './TextInputForm-
|
|
1
|
+
import { r as reactExports, l as useTranslation, o as jsxs, j as jsx, a4 as MenuItem, a_ as motion, a$ as listVariants, b0 as listItemVariants, G as Box, at as Drawer, X as ViewContext, a1 as EventTargetContext, V as ViewActions, p as SharedViews, ak as HeaderNavigation, a7 as orchestrationEvents, I as IMTBLWidgetEvents, bv as amountInputValidation, Y as Body, cR as OverflowPopoverMenu, ao as SimpleLayout, U as TokenFilterTypes, h as getL2ChainId, cS as commonjsGlobal, cT as requireSecp256k1$1, cU as requireLib_commonjs, cV as require$$0$3, cW as requireDist$1, cX as bech32$2, cY as bnExports$1, cZ as require$$0$4, c_ as getAugmentedNamespace, c$ as require$$0$5, d0 as minimalisticAssert, d1 as require$$2, d2 as hash$6, aD as viewReducer, aE as initialViewState, $ as useAnalytics, d3 as sendAddFundsCloseEvent, E as ErrorView, a6 as UserJourney } from './index-_4pTEm9m.js';
|
|
2
|
+
import { T as TextInputForm } from './TextInputForm-4POGFRcV.js';
|
|
3
3
|
|
|
4
4
|
const initialAddFundsState = {
|
|
5
5
|
checkout: null,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BridgeWidgetViews, C as CryptoFiatContext, f as formatUnits, a as CryptoFiatActions, p as parseUnits, T as TopUpView, b as CryptoFiatProvider } from './TopUpView-
|
|
3
|
-
import { T as TokenImage, r as retry, u as useInterval } from './retry-
|
|
4
|
-
import { A as Accordion, S as SelectForm, T as TransactionRejected, g as getAllowedBalances, F as Fees, N as NetworkSwitchDrawer, W as WalletApproveHero } from './balance-
|
|
5
|
-
import { T as TextInputForm } from './TextInputForm-
|
|
1
|
+
import { bN as axios, bO as defineReadOnly, bP as getStatic, bQ as Signer, bR as Provider, bS as getAddress, bT as Logger, bU as getContractAddress, bV as Interface, bW as shallowCopy, bX as VoidSigner, bY as Indexed, bZ as deepCopy, b_ as isHexString, b$ as checkResultErrors, c0 as resolveProperties, aL as BigNumber, c1 as accessListify, c2 as arrayify, j as jsx, _ as _objectWithoutProperties, aJ as cloneElementWithCssProp, Y as Body, T as _defineProperty, ab as CheckoutErrorType, c3 as IMMUTABLE_API_BASE_URL, r as reactExports, I as IMTBLWidgetEvents, B as BridgeEventType, o as jsxs, c4 as ShimmerBox, a4 as MenuItem, b3 as Stack, l as useTranslation, N as Button, G as Box, c5 as PASSPORT_URL, aC as Link, c6 as getChainIdBySlug, af as getChainImage, c7 as networkName, ae as FramedImage, br as Icon, $ as useAnalytics, a6 as UserJourney, b5 as Divider, X as ViewContext, aV as Fragment, V as ViewActions, au as useWalletConnect, aw as isWalletConnectProvider, bq as Logo, c8 as RawImage, c9 as AXELAR_SCAN_URL, a9 as isNativeToken, ai as getTokenImageByAddress, ca as getNativeSymbolByChainSlug, aj as calculateCryptoToFiat, a1 as EventTargetContext, a2 as isPassportProvider, i as getL1ChainId, U as TokenFilterTypes, h as getL2ChainId, cb as WalletProviderRdns, cc as Web3Provider, cd as useInjectedProviders, ak as HeaderNavigation, an as FooterLogo, ce as WalletDrawer, ao as SimpleLayout, cf as getChainSlugById, cg as JsonRpcProvider, ch as DEFAULT_TRANSACTIONS_RETRY_POLICY, L as LoadingView, k as ChainId, ci as getChainNameById, w as useTheme, as as Heading, aq as getWalletProviderNameByProvider, cj as isAddressSanctioned, p as SharedViews, ck as isMetaMaskProvider, ap as WalletProviderName, at as Drawer, v as ButtCon, al as ButtonNavigationStyles, a7 as orchestrationEvents, a5 as tokenValueFormat, a0 as formatZeroAmount, bt as NATIVE, bv as amountInputValidation, bk as getRemoteImage, bp as CloudImage, cl as ETH_TOKEN_SYMBOL, a3 as Environment, cm as GasEstimateType, bz as DEFAULT_TOKEN_DECIMALS, bu as DEFAULT_QUOTE_REFRESH_INTERVAL, cn as addChainChangedListener, co as removeChainChangedListener, bB as IMX_TOKEN_SYMBOL, cp as dist, cq as CHECKOUT_CDN_BASE_URL, ax as heroBackGroundStyles, ay as heroImageStyles, cr as Badge, aA as SimpleTextBody, bC as FooterButton, cs as getEthTokenImage, ct as WITHDRAWAL_CLAIM_GAS_LIMIT, bs as getDefaultTokenImage, aD as viewReducer, aE as initialViewState, cu as BridgeConfiguration, cv as ImmutableConfiguration, cw as TokenBridge, bE as StatusView, b1 as StatusType, E as ErrorView, cx as ServiceUnavailableErrorView, cy as ServiceType, cz as ETH_SEPOLIA_TO_ZKEVM_TESTNET, cA as ETH_SEPOLIA_TO_ZKEVM_DEVNET, cB as ETH_MAINNET_TO_ZKEVM_MAINNET } from './index-_4pTEm9m.js';
|
|
2
|
+
import { B as BridgeWidgetViews, C as CryptoFiatContext, f as formatUnits, a as CryptoFiatActions, p as parseUnits, T as TopUpView, b as CryptoFiatProvider } from './TopUpView-DrTM31Ek.js';
|
|
3
|
+
import { T as TokenImage, r as retry, u as useInterval } from './retry-BpGE5FcR.js';
|
|
4
|
+
import { A as Accordion, S as SelectForm, T as TransactionRejected, g as getAllowedBalances, F as Fees, N as NetworkSwitchDrawer, W as WalletApproveHero } from './balance-Bj7GdprK.js';
|
|
5
|
+
import { T as TextInputForm } from './TextInputForm-4POGFRcV.js';
|
|
6
6
|
|
|
7
7
|
// This module is intended to unwrap Axios default export as named.
|
|
8
8
|
// Keep top-level export same with static properties
|
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { r as reactExports, u as useConnectLoaderState, j as jsx, I as IMTBLWidgetEvents, C as CheckoutFlowType, P as ProviderEventType, a as CheckoutEventType, b as ConnectEventType, c as CheckoutFailureEventType, d as CheckoutSuccessEventType, W as WalletEventType, e as CheckoutUserActionEventType, S as SwapEventType, B as BridgeEventType, O as OnRampEventType, f as SaleEventType, g as OrchestrationEventType, V as ViewActions, h as getL2ChainId, i as getL1ChainId, k as ChainId, l as useTranslation, m as useViewState, n as useEventTargetState, o as jsxs, p as SharedViews, L as LoadingView, E as ErrorView, q as ConnectWidget, s as ConnectLoader, t as ViewContextProvider } from './index-_4pTEm9m.js';
|
|
2
|
+
import SwapWidget from './SwapWidget-hn-faHAD.js';
|
|
3
|
+
import { B as BridgeWidget } from './BridgeWidget-DagFbcal.js';
|
|
4
|
+
import { O as OnRampWidget } from './OnRampWidget-9xY2PrDk.js';
|
|
5
|
+
import WalletWidget from './WalletWidget-DVoiXUbf.js';
|
|
6
|
+
import SaleWidget from './SaleWidget-E0v88XfM.js';
|
|
7
|
+
import AddFundsWidget from './AddFundsWidget-ElcJ_L46.js';
|
|
8
|
+
import './balance-Bj7GdprK.js';
|
|
9
|
+
import './retry-BpGE5FcR.js';
|
|
10
|
+
import './TopUpView-DrTM31Ek.js';
|
|
11
|
+
import './TextInputForm-4POGFRcV.js';
|
|
12
|
+
import './SpendingCapHero-B1bghRag.js';
|
|
13
|
+
|
|
14
|
+
const initialCheckoutState = {
|
|
15
|
+
checkout: undefined,
|
|
16
|
+
provider: undefined,
|
|
17
|
+
passport: undefined,
|
|
18
|
+
};
|
|
19
|
+
var CheckoutActions;
|
|
20
|
+
(function (CheckoutActions) {
|
|
21
|
+
CheckoutActions["SET_CHECKOUT"] = "SET_CHECKOUT";
|
|
22
|
+
CheckoutActions["SET_PROVIDER"] = "SET_PROVIDER";
|
|
23
|
+
CheckoutActions["SET_PASSPORT"] = "SET_PASSPORT";
|
|
24
|
+
})(CheckoutActions || (CheckoutActions = {}));
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
|
+
const CheckoutContext = reactExports.createContext({
|
|
27
|
+
checkoutState: initialCheckoutState,
|
|
28
|
+
checkoutDispatch: () => { },
|
|
29
|
+
});
|
|
30
|
+
CheckoutContext.displayName = 'CheckoutContext'; // help with debugging Context in browser
|
|
31
|
+
const checkoutReducer = (state, action) => {
|
|
32
|
+
switch (action.payload.type) {
|
|
33
|
+
case CheckoutActions.SET_CHECKOUT:
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
checkout: action.payload.checkout,
|
|
37
|
+
};
|
|
38
|
+
case CheckoutActions.SET_PROVIDER:
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
provider: action.payload.provider,
|
|
42
|
+
};
|
|
43
|
+
case CheckoutActions.SET_PASSPORT:
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
passport: action.payload.passport,
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const useCheckoutWidgetState = () => {
|
|
54
|
+
const [viewState, viewDispatch] = reactExports.useReducer(checkoutReducer, initialCheckoutState);
|
|
55
|
+
return [viewState, viewDispatch];
|
|
56
|
+
};
|
|
57
|
+
function CheckoutWidgetContextProvicer({ children, }) {
|
|
58
|
+
const [{ checkout, provider }] = useConnectLoaderState();
|
|
59
|
+
const [checkoutState, checkoutDispatch] = useCheckoutWidgetState();
|
|
60
|
+
const values = reactExports.useMemo(() => ({
|
|
61
|
+
checkoutState: { ...checkoutState, checkout, provider },
|
|
62
|
+
checkoutDispatch,
|
|
63
|
+
}), [checkoutState, checkoutDispatch, checkout, provider]);
|
|
64
|
+
return (jsx(CheckoutContext.Provider, { value: values, children: children }));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const sendCheckoutEvent = (eventTarget, detail) => {
|
|
68
|
+
const event = new CustomEvent(IMTBLWidgetEvents.IMTBL_CHECKOUT_WIDGET_EVENT, { detail });
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log('checkout app event ', eventTarget, event);
|
|
71
|
+
if (eventTarget !== undefined)
|
|
72
|
+
eventTarget.dispatchEvent(event);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* List of views that require a connected wallet
|
|
77
|
+
*/
|
|
78
|
+
const connectFirstViewList = [
|
|
79
|
+
CheckoutFlowType.SALE,
|
|
80
|
+
CheckoutFlowType.SWAP,
|
|
81
|
+
CheckoutFlowType.WALLET,
|
|
82
|
+
CheckoutFlowType.ONRAMP,
|
|
83
|
+
CheckoutFlowType.ADD_FUNDS,
|
|
84
|
+
];
|
|
85
|
+
/**
|
|
86
|
+
* Check if the given view requires a connected wallet
|
|
87
|
+
*/
|
|
88
|
+
function getViewShouldConnect(view) {
|
|
89
|
+
return connectFirstViewList.includes(view);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Map Connect Widget Events
|
|
94
|
+
*/
|
|
95
|
+
function mapConnectWidgetEvent(event) {
|
|
96
|
+
const { type, data } = event.detail;
|
|
97
|
+
switch (type) {
|
|
98
|
+
case ConnectEventType.SUCCESS:
|
|
99
|
+
return {
|
|
100
|
+
type: CheckoutEventType.SUCCESS,
|
|
101
|
+
data: {
|
|
102
|
+
type: CheckoutSuccessEventType.CONNECT_SUCCESS,
|
|
103
|
+
data,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
case ConnectEventType.FAILURE:
|
|
107
|
+
return {
|
|
108
|
+
type: CheckoutEventType.FAILURE,
|
|
109
|
+
data: {
|
|
110
|
+
type: CheckoutFailureEventType.CONNECT_FAILED,
|
|
111
|
+
data,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
case ConnectEventType.CLOSE_WIDGET:
|
|
115
|
+
return {
|
|
116
|
+
type: CheckoutEventType.CLOSE,
|
|
117
|
+
data: {},
|
|
118
|
+
};
|
|
119
|
+
default:
|
|
120
|
+
throw new Error(`Unknown connect event type "${event.detail.type}"`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Map Wallet Widget Events
|
|
125
|
+
*/
|
|
126
|
+
function mapWalletWidgetEvent(event) {
|
|
127
|
+
const { type, data } = event.detail;
|
|
128
|
+
switch (type) {
|
|
129
|
+
case WalletEventType.NETWORK_SWITCH:
|
|
130
|
+
return {
|
|
131
|
+
type: CheckoutEventType.USER_ACTION,
|
|
132
|
+
data: {
|
|
133
|
+
type: CheckoutUserActionEventType.NETWORK_SWITCH,
|
|
134
|
+
data,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
case WalletEventType.DISCONNECT_WALLET:
|
|
138
|
+
return {
|
|
139
|
+
type: CheckoutEventType.DISCONNECTED,
|
|
140
|
+
data: {},
|
|
141
|
+
};
|
|
142
|
+
case WalletEventType.CLOSE_WIDGET:
|
|
143
|
+
return {
|
|
144
|
+
type: CheckoutEventType.CLOSE,
|
|
145
|
+
data: {},
|
|
146
|
+
};
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unknown wallet event type "${event.detail.type}"`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Map Swap Widget Events
|
|
153
|
+
*/
|
|
154
|
+
function mapSwapWidgetEvent(event) {
|
|
155
|
+
const { type, data } = event.detail;
|
|
156
|
+
switch (type) {
|
|
157
|
+
case SwapEventType.SUCCESS:
|
|
158
|
+
return {
|
|
159
|
+
type: CheckoutEventType.SUCCESS,
|
|
160
|
+
data: {
|
|
161
|
+
type: CheckoutSuccessEventType.SWAP_SUCCESS,
|
|
162
|
+
data,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
case SwapEventType.FAILURE:
|
|
166
|
+
return {
|
|
167
|
+
type: CheckoutEventType.FAILURE,
|
|
168
|
+
data: {
|
|
169
|
+
type: CheckoutFailureEventType.SWAP_FAILED,
|
|
170
|
+
data,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
case SwapEventType.REJECTED:
|
|
174
|
+
return {
|
|
175
|
+
type: CheckoutEventType.FAILURE,
|
|
176
|
+
data: {
|
|
177
|
+
type: CheckoutFailureEventType.SWAP_REJECTED,
|
|
178
|
+
data,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
case SwapEventType.CLOSE_WIDGET:
|
|
182
|
+
return {
|
|
183
|
+
type: CheckoutEventType.CLOSE,
|
|
184
|
+
data: {},
|
|
185
|
+
};
|
|
186
|
+
default:
|
|
187
|
+
throw new Error(`Unknown swap event type "${event.detail.type}"`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Map Add Funds Widget Events
|
|
192
|
+
*/
|
|
193
|
+
function mapAddFundsWidgetEvent(event) {
|
|
194
|
+
const { type } = event.detail;
|
|
195
|
+
switch (type) {
|
|
196
|
+
default:
|
|
197
|
+
throw new Error(`Unknown add funds event type "${event.detail.type}"`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Map Bridge Widget Events
|
|
202
|
+
*/
|
|
203
|
+
function mapBridgeWidgetEvent(event) {
|
|
204
|
+
const { type, data } = event.detail;
|
|
205
|
+
switch (type) {
|
|
206
|
+
case BridgeEventType.TRANSACTION_SENT:
|
|
207
|
+
return {
|
|
208
|
+
type: CheckoutEventType.SUCCESS,
|
|
209
|
+
data: {
|
|
210
|
+
type: CheckoutSuccessEventType.BRIDGE_SUCCESS,
|
|
211
|
+
data,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
case BridgeEventType.CLAIM_WITHDRAWAL_SUCCESS:
|
|
215
|
+
return {
|
|
216
|
+
type: CheckoutEventType.SUCCESS,
|
|
217
|
+
data: {
|
|
218
|
+
type: CheckoutSuccessEventType.BRIDGE_CLAIM_WITHDRAWAL_SUCCESS,
|
|
219
|
+
data,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
case BridgeEventType.CLAIM_WITHDRAWAL_FAILURE:
|
|
223
|
+
return {
|
|
224
|
+
type: CheckoutEventType.FAILURE,
|
|
225
|
+
data: {
|
|
226
|
+
type: CheckoutFailureEventType.BRIDGE_CLAIM_WITHDRAWAL_FAILED,
|
|
227
|
+
data,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
case BridgeEventType.FAILURE:
|
|
231
|
+
return {
|
|
232
|
+
type: CheckoutEventType.FAILURE,
|
|
233
|
+
data: {
|
|
234
|
+
type: CheckoutFailureEventType.BRIDGE_FAILED,
|
|
235
|
+
data,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
case BridgeEventType.CLOSE_WIDGET:
|
|
239
|
+
return {
|
|
240
|
+
type: CheckoutEventType.CLOSE,
|
|
241
|
+
data: {},
|
|
242
|
+
};
|
|
243
|
+
default:
|
|
244
|
+
throw new Error(`Unknown bridge event type "${event.detail.type}"`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Map Bridge Widget Events
|
|
249
|
+
*/
|
|
250
|
+
function mapOnrampWidgetEvent(event) {
|
|
251
|
+
const { type, data } = event.detail;
|
|
252
|
+
switch (type) {
|
|
253
|
+
case OnRampEventType.SUCCESS:
|
|
254
|
+
return {
|
|
255
|
+
type: CheckoutEventType.SUCCESS,
|
|
256
|
+
data: {
|
|
257
|
+
type: CheckoutSuccessEventType.ONRAMP_SUCCESS,
|
|
258
|
+
data,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
case OnRampEventType.FAILURE:
|
|
262
|
+
return {
|
|
263
|
+
type: CheckoutEventType.FAILURE,
|
|
264
|
+
data: {
|
|
265
|
+
type: CheckoutFailureEventType.ONRAMP_FAILED,
|
|
266
|
+
data,
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
case OnRampEventType.CLOSE_WIDGET:
|
|
270
|
+
return {
|
|
271
|
+
type: CheckoutEventType.CLOSE,
|
|
272
|
+
data: {},
|
|
273
|
+
};
|
|
274
|
+
default:
|
|
275
|
+
throw new Error(`Unknown onRamp event type "${event.detail.type}"`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function mapSaleWidgetEvent(event) {
|
|
279
|
+
const { type, data } = event.detail;
|
|
280
|
+
switch (type) {
|
|
281
|
+
case SaleEventType.SUCCESS:
|
|
282
|
+
return {
|
|
283
|
+
type: CheckoutEventType.SUCCESS,
|
|
284
|
+
data: {
|
|
285
|
+
type: CheckoutSuccessEventType.SALE_SUCCESS,
|
|
286
|
+
data,
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
case SaleEventType.FAILURE:
|
|
290
|
+
return {
|
|
291
|
+
type: CheckoutEventType.FAILURE,
|
|
292
|
+
data: {
|
|
293
|
+
type: CheckoutFailureEventType.SALE_FAILED,
|
|
294
|
+
data,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
case SaleEventType.CLOSE_WIDGET:
|
|
298
|
+
return {
|
|
299
|
+
type: CheckoutEventType.CLOSE,
|
|
300
|
+
data: {},
|
|
301
|
+
};
|
|
302
|
+
case SaleEventType.TRANSACTION_SUCCESS:
|
|
303
|
+
return {
|
|
304
|
+
type: CheckoutEventType.SUCCESS,
|
|
305
|
+
data: {
|
|
306
|
+
type: CheckoutSuccessEventType.SALE_TRANSACTION_SUCCESS,
|
|
307
|
+
data,
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
case SaleEventType.PAYMENT_METHOD:
|
|
311
|
+
return {
|
|
312
|
+
type: CheckoutEventType.USER_ACTION,
|
|
313
|
+
data: {
|
|
314
|
+
type: CheckoutUserActionEventType.PAYMENT_METHOD_SELECTED,
|
|
315
|
+
data,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
case SaleEventType.PAYMENT_TOKEN:
|
|
319
|
+
return {
|
|
320
|
+
type: CheckoutEventType.USER_ACTION,
|
|
321
|
+
data: {
|
|
322
|
+
type: CheckoutUserActionEventType.PAYMENT_TOKEN_SELECTED,
|
|
323
|
+
data,
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
default:
|
|
327
|
+
throw new Error(`Unknown sale event type "${event.detail.type}"`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Map widget events to checkout widget event detail
|
|
332
|
+
*/
|
|
333
|
+
function getCheckoutWidgetEvent(event) {
|
|
334
|
+
if (event.detail.type === ProviderEventType.PROVIDER_UPDATED) {
|
|
335
|
+
return {
|
|
336
|
+
type: CheckoutEventType.PROVIDER_UPDATED,
|
|
337
|
+
data: event.detail.data,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
switch (event.type) {
|
|
341
|
+
case IMTBLWidgetEvents.IMTBL_CONNECT_WIDGET_EVENT:
|
|
342
|
+
return mapConnectWidgetEvent(event);
|
|
343
|
+
case IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT:
|
|
344
|
+
return mapWalletWidgetEvent(event);
|
|
345
|
+
case IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT:
|
|
346
|
+
return mapSwapWidgetEvent(event);
|
|
347
|
+
case IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT:
|
|
348
|
+
return mapAddFundsWidgetEvent(event);
|
|
349
|
+
case IMTBLWidgetEvents.IMTBL_BRIDGE_WIDGET_EVENT:
|
|
350
|
+
return mapBridgeWidgetEvent(event);
|
|
351
|
+
case IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT:
|
|
352
|
+
return mapOnrampWidgetEvent(event);
|
|
353
|
+
case IMTBLWidgetEvents.IMTBL_SALE_WIDGET_EVENT:
|
|
354
|
+
return mapSaleWidgetEvent(event);
|
|
355
|
+
default:
|
|
356
|
+
throw new Error(`Unknown widget event type "${event.type}"`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Get view from orchestration event type
|
|
362
|
+
*/
|
|
363
|
+
function getViewFromOrchestrationEventType(type) {
|
|
364
|
+
switch (type) {
|
|
365
|
+
case OrchestrationEventType.REQUEST_SWAP:
|
|
366
|
+
return CheckoutFlowType.SWAP;
|
|
367
|
+
case OrchestrationEventType.REQUEST_CONNECT:
|
|
368
|
+
return CheckoutFlowType.CONNECT;
|
|
369
|
+
case OrchestrationEventType.REQUEST_WALLET:
|
|
370
|
+
return CheckoutFlowType.WALLET;
|
|
371
|
+
case OrchestrationEventType.REQUEST_BRIDGE:
|
|
372
|
+
return CheckoutFlowType.BRIDGE;
|
|
373
|
+
case OrchestrationEventType.REQUEST_ONRAMP:
|
|
374
|
+
return CheckoutFlowType.ONRAMP;
|
|
375
|
+
case OrchestrationEventType.REQUEST_ADD_FUNDS:
|
|
376
|
+
return CheckoutFlowType.ADD_FUNDS;
|
|
377
|
+
default:
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Orchestration Events List */
|
|
383
|
+
const orchestrationEvents = [
|
|
384
|
+
OrchestrationEventType.REQUEST_CONNECT,
|
|
385
|
+
OrchestrationEventType.REQUEST_WALLET,
|
|
386
|
+
OrchestrationEventType.REQUEST_SWAP,
|
|
387
|
+
OrchestrationEventType.REQUEST_BRIDGE,
|
|
388
|
+
OrchestrationEventType.REQUEST_ONRAMP,
|
|
389
|
+
OrchestrationEventType.REQUEST_ADD_FUNDS,
|
|
390
|
+
OrchestrationEventType.REQUEST_GO_BACK,
|
|
391
|
+
];
|
|
392
|
+
/**
|
|
393
|
+
* Check if event is orchestration event
|
|
394
|
+
*/
|
|
395
|
+
function isOrchestrationEvent(event) {
|
|
396
|
+
return orchestrationEvents.includes(event.detail.type);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Widget Events List */
|
|
400
|
+
const widgetEvents = [
|
|
401
|
+
IMTBLWidgetEvents.IMTBL_CONNECT_WIDGET_EVENT,
|
|
402
|
+
IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT,
|
|
403
|
+
IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT,
|
|
404
|
+
IMTBLWidgetEvents.IMTBL_BRIDGE_WIDGET_EVENT,
|
|
405
|
+
IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT,
|
|
406
|
+
IMTBLWidgetEvents.IMTBL_SALE_WIDGET_EVENT,
|
|
407
|
+
];
|
|
408
|
+
/**
|
|
409
|
+
* Subscribe and Handle widget events
|
|
410
|
+
*/
|
|
411
|
+
function useWidgetEvents(eventTarget, viewState) {
|
|
412
|
+
const [{ history }, viewDispatch] = viewState;
|
|
413
|
+
/**
|
|
414
|
+
* Change view as per orchestration event requests
|
|
415
|
+
*/
|
|
416
|
+
const handleOrchestrationEvent = (event) => {
|
|
417
|
+
const { type, data } = event.detail;
|
|
418
|
+
if (type === OrchestrationEventType.REQUEST_GO_BACK) {
|
|
419
|
+
viewDispatch({
|
|
420
|
+
payload: {
|
|
421
|
+
type: ViewActions.UPDATE_VIEW,
|
|
422
|
+
view: history?.[0],
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const flow = getViewFromOrchestrationEventType(type);
|
|
428
|
+
if (!flow)
|
|
429
|
+
return;
|
|
430
|
+
viewDispatch({
|
|
431
|
+
payload: {
|
|
432
|
+
type: ViewActions.UPDATE_VIEW,
|
|
433
|
+
view: {
|
|
434
|
+
type: flow,
|
|
435
|
+
data: { params: data, config: {}, showBackButton: true },
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Proxy widget events to checkout widget events
|
|
442
|
+
*/
|
|
443
|
+
const handleWidgetEvent = reactExports.useMemo(() => {
|
|
444
|
+
if (!eventTarget)
|
|
445
|
+
return null;
|
|
446
|
+
return (event) => {
|
|
447
|
+
const customEvent = event;
|
|
448
|
+
if (isOrchestrationEvent(customEvent)) {
|
|
449
|
+
handleOrchestrationEvent(customEvent);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const eventDetail = getCheckoutWidgetEvent(customEvent);
|
|
453
|
+
sendCheckoutEvent(eventTarget, eventDetail);
|
|
454
|
+
};
|
|
455
|
+
}, [eventTarget]);
|
|
456
|
+
reactExports.useEffect(() => {
|
|
457
|
+
if (!handleWidgetEvent)
|
|
458
|
+
return () => { };
|
|
459
|
+
widgetEvents.map((event) => window.addEventListener(event, handleWidgetEvent));
|
|
460
|
+
return () => {
|
|
461
|
+
widgetEvents.map((event) => window.removeEventListener(event, handleWidgetEvent));
|
|
462
|
+
};
|
|
463
|
+
}, [handleWidgetEvent]);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Get the chain id for the checkout
|
|
468
|
+
*/
|
|
469
|
+
const getChainId = (checkout) => (checkout.config.isProduction
|
|
470
|
+
? ChainId.IMTBL_ZKEVM_MAINNET
|
|
471
|
+
: ChainId.IMTBL_ZKEVM_TESTNET);
|
|
472
|
+
/**
|
|
473
|
+
* Get the connect loader params for the widget
|
|
474
|
+
*/
|
|
475
|
+
function getConnectLoaderParams(view, checkout, web3Provider) {
|
|
476
|
+
const { type, data } = view;
|
|
477
|
+
switch (type) {
|
|
478
|
+
case CheckoutFlowType.WALLET:
|
|
479
|
+
return {
|
|
480
|
+
checkout,
|
|
481
|
+
web3Provider,
|
|
482
|
+
targetChainId: getChainId(checkout),
|
|
483
|
+
walletProviderName: data.params.walletProviderName,
|
|
484
|
+
allowedChains: [
|
|
485
|
+
getL1ChainId(checkout.config),
|
|
486
|
+
getL2ChainId(checkout.config),
|
|
487
|
+
],
|
|
488
|
+
};
|
|
489
|
+
case CheckoutFlowType.ONRAMP:
|
|
490
|
+
case CheckoutFlowType.ADD_FUNDS:
|
|
491
|
+
return {
|
|
492
|
+
checkout,
|
|
493
|
+
web3Provider,
|
|
494
|
+
targetChainId: getChainId(checkout),
|
|
495
|
+
allowedChains: [
|
|
496
|
+
getL1ChainId(checkout.config),
|
|
497
|
+
getL2ChainId(checkout.config),
|
|
498
|
+
],
|
|
499
|
+
};
|
|
500
|
+
case CheckoutFlowType.SALE:
|
|
501
|
+
case CheckoutFlowType.SWAP:
|
|
502
|
+
return {
|
|
503
|
+
checkout,
|
|
504
|
+
web3Provider,
|
|
505
|
+
targetChainId: getChainId(checkout),
|
|
506
|
+
allowedChains: [getL2ChainId(checkout.config)],
|
|
507
|
+
};
|
|
508
|
+
default:
|
|
509
|
+
return {};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function CheckoutWidget(props) {
|
|
514
|
+
const { flowParams, flowConfig, widgetsConfig, checkout, web3Provider, } = props;
|
|
515
|
+
const { t } = useTranslation();
|
|
516
|
+
const viewState = useViewState();
|
|
517
|
+
const [{ view }, viewDispatch] = viewState;
|
|
518
|
+
const [{ eventTarget }] = useEventTargetState();
|
|
519
|
+
const connectLoaderParams = reactExports.useMemo(() => getConnectLoaderParams(view, checkout, web3Provider), [view, checkout, web3Provider]);
|
|
520
|
+
/**
|
|
521
|
+
* Subscribe and Handle widget events
|
|
522
|
+
*/
|
|
523
|
+
useWidgetEvents(eventTarget, viewState);
|
|
524
|
+
/**
|
|
525
|
+
* Mount the view according to set flow in params
|
|
526
|
+
*/
|
|
527
|
+
reactExports.useEffect(() => {
|
|
528
|
+
if (!flowParams.flow)
|
|
529
|
+
return;
|
|
530
|
+
const { flow, ...mountedWidgetParams } = flowParams;
|
|
531
|
+
viewDispatch({
|
|
532
|
+
payload: {
|
|
533
|
+
type: ViewActions.UPDATE_VIEW,
|
|
534
|
+
view: {
|
|
535
|
+
type: flow,
|
|
536
|
+
data: {
|
|
537
|
+
params: mountedWidgetParams,
|
|
538
|
+
config: { ...(flowConfig?.[flow] || {}) },
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
}, [flowParams]);
|
|
544
|
+
const showBackButton = !!view.data?.showBackButton;
|
|
545
|
+
const shouldConnectView = reactExports.useMemo(() => getViewShouldConnect(view.type), [view.type]);
|
|
546
|
+
return (jsx(ViewContextProvider, { children: jsxs(CheckoutWidgetContextProvicer, { children: [view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), view.type === SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ErrorView, { onCloseClick: () => {
|
|
547
|
+
sendCheckoutEvent(eventTarget, {
|
|
548
|
+
type: CheckoutEventType.CLOSE,
|
|
549
|
+
data: {},
|
|
550
|
+
});
|
|
551
|
+
}, onActionClick: () => {
|
|
552
|
+
// TODO: trigger a retry
|
|
553
|
+
}, actionText: t('views.ERROR_VIEW.actionText') })), view.type === CheckoutFlowType.CONNECT && (jsx(ConnectWidget, { config: widgetsConfig, checkout: checkout, sendCloseEventOverride: () => {
|
|
554
|
+
sendCheckoutEvent(eventTarget, {
|
|
555
|
+
type: CheckoutEventType.CLOSE,
|
|
556
|
+
data: {},
|
|
557
|
+
});
|
|
558
|
+
}, ...(view.data.params || {}) })), view.type === CheckoutFlowType.BRIDGE && (jsx(BridgeWidget, { config: widgetsConfig, checkout: checkout, web3Provider: web3Provider, showBackButton: showBackButton, ...(view.data.params || {}) })), shouldConnectView && (jsx(ConnectLoader, { widgetConfig: widgetsConfig, params: connectLoaderParams, closeEvent: () => {
|
|
559
|
+
sendCheckoutEvent(eventTarget, {
|
|
560
|
+
type: CheckoutEventType.CLOSE,
|
|
561
|
+
data: {},
|
|
562
|
+
});
|
|
563
|
+
}, children: jsxs(reactExports.Suspense, { fallback: jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: [view.type === CheckoutFlowType.WALLET && (jsx(WalletWidget, { config: widgetsConfig, walletConfig: {
|
|
564
|
+
showNetworkMenu: true,
|
|
565
|
+
showDisconnectButton: true,
|
|
566
|
+
...view.data.config,
|
|
567
|
+
}, ...(view.data.params || {}) })), view.type === CheckoutFlowType.SALE && (jsx(SaleWidget, { config: widgetsConfig, ...(view.data.params || {}), hideExcludedPaymentTypes: false,
|
|
568
|
+
waitFulfillmentSettlements: true,
|
|
569
|
+
...view.data.config })), view.type === CheckoutFlowType.ADD_FUNDS && (jsx(AddFundsWidget, { checkout: checkout, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })), view.type === CheckoutFlowType.SWAP && (jsx(SwapWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })), view.type === CheckoutFlowType.ONRAMP && (jsx(OnRampWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton }))] }) }))] }) }));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export { CheckoutWidget as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { O as OnRampWidgetViews, T as TopUpView } from './TopUpView-
|
|
3
|
-
import { S as SpendingCapHero } from './SpendingCapHero-
|
|
1
|
+
import { bI as global, $ as useAnalytics, r as reactExports, Z as ConnectLoaderContext, a1 as EventTargetContext, l as useTranslation, X as ViewContext, p as SharedViews, bJ as ExchangeType, j as jsx, ao as SimpleLayout, ak as HeaderNavigation, bK as sendOnRampWidgetCloseEvent, a7 as orchestrationEvents, I as IMTBLWidgetEvents, G as Box, a6 as UserJourney, V as ViewActions, an as FooterLogo, o as jsxs, aA as SimpleTextBody, aD as viewReducer, aE as initialViewState, bt as NATIVE, L as LoadingView, bL as sendOnRampSuccessEvent, b1 as StatusType, bE as StatusView, bM as sendOnRampFailedEvent } from './index-_4pTEm9m.js';
|
|
2
|
+
import { O as OnRampWidgetViews, T as TopUpView } from './TopUpView-DrTM31Ek.js';
|
|
3
|
+
import { S as SpendingCapHero } from './SpendingCapHero-B1bghRag.js';
|
|
4
4
|
|
|
5
5
|
function isNull(arg) {
|
|
6
6
|
return arg === null;
|