@imtbl/checkout-widgets 2.4.1 → 2.4.2-alpha.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-C7WvIzVB.js → AddTokensWidget-DyaSNxb9.js} +13 -13
- package/dist/browser/{BridgeWidget-B1Wu23zB.js → BridgeWidget-CC3HoG-f.js} +18 -18
- package/dist/browser/{CommerceWidget-DumWCWme.js → CommerceWidget-CTQ4KlsY.js} +171 -171
- package/dist/browser/{FeesBreakdown-BYJrY7h0.js → FeesBreakdown-CXCCZO8Y.js} +1 -1
- package/dist/browser/{OnRampWidget-DJ6lRZIv.js → OnRampWidget-D3mMWz-D.js} +5 -5
- package/dist/browser/{SaleWidget-CroZTFC-.js → SaleWidget-C3_vgKdS.js} +42 -42
- package/dist/browser/{SpendingCapHero-CwKV5CXn.js → SpendingCapHero-9hMtorO0.js} +1 -1
- package/dist/browser/{SwapWidget-C6I2fCpc.js → SwapWidget-B583872v.js} +15 -15
- package/dist/browser/{TokenImage-Bw5JLoGQ.js → TokenImage-DIQAWWQ8.js} +1 -1
- package/dist/browser/{TopUpView-DESM41IF.js → TopUpView-ZH8ArNep.js} +4 -4
- package/dist/browser/{WalletApproveHero-DZlFc1Nj.js → WalletApproveHero-OJwL-DBm.js} +3 -3
- package/dist/browser/{WalletWidget-hRjuhzEr.js → WalletWidget-BBu55NDF.js} +8 -8
- package/dist/browser/{auto-track-D__zrCK7.js → auto-track-CLMvF6S6.js} +1 -1
- package/dist/browser/{index-YeyP_iah.js → index-C0jRMAZA.js} +1 -1
- package/dist/browser/{index-CEfrmZzQ.js → index-C4XLneTe.js} +1 -1
- package/dist/browser/{index-DoMmAj9u.js → index-CN86wAag.js} +1 -1
- package/dist/browser/{index-BXlX70_L.js → index-D-N55IPR.js} +1 -1
- package/dist/browser/{index-CuJhn9sR.js → index-DFqiWhIF.js} +194 -194
- package/dist/browser/{index-BFyrNz4O.js → index-DLzYYXML.js} +2 -2
- package/dist/browser/{index-9wAv7OEf.js → index-VQiYAYMX.js} +1 -1
- package/dist/browser/{index-DQXCcnS_.js → index-lsDJnzuG.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-D1wm4N7h.js → index.umd-v4vSwYO3.js} +1 -1
- package/dist/browser/{useInterval-BxDw5ss0.js → useInterval-Dp0AIWS5.js} +1 -1
- package/package.json +7 -7
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as SelectInput, a as SwapWidget } from './SwapWidget-
|
|
3
|
-
import { B as BridgeWidget } from './BridgeWidget-
|
|
4
|
-
import OnRampWidget from './OnRampWidget-
|
|
5
|
-
import WalletWidget from './WalletWidget-
|
|
6
|
-
import SaleWidget from './SaleWidget-
|
|
7
|
-
import AddTokensWidget from './AddTokensWidget-
|
|
8
|
-
import { g as getAllowedBalances, T as TextInputForm } from './WalletApproveHero-
|
|
9
|
-
import './useInterval-
|
|
10
|
-
import './TopUpView-
|
|
11
|
-
import './FeesBreakdown-
|
|
12
|
-
import './SpendingCapHero-
|
|
13
|
-
import './TokenImage-
|
|
1
|
+
import { o as oo, w as wo, n as no, g as go, a as ao, E as Eo, f as fo, i as io, R as Ro, s as so, C as Co, p as po, m as mo, c as co, T as To, u as uo, r as reactExports, V as ViewActions, b as parseUnits, d as Contract, e as ae, h as formatZeroAmount, j as calculateCryptoToFiat, k as useTranslation, l as dist, q as getRemoteRive, t as tt, v as jsx, x as jsxs, B as Box, H as Heading, L as Link, y as Button, S as Stack, z as SimpleLayout, A as Body, D as useAnalytics, F as EventTargetContext, G as CryptoFiatContext, I as tokenValueFormat, J as getDefaultTokenImage, U as UserJourney, K as HeaderNavigation, M as sendCloseWidgetEvent, N as orchestrationEvents$1, O as amountInputValidation, P as Io, Q as useTheme, W as CloudImage, X as getRemoteImage, Y as CryptoFiatProvider, Z as ConnectLoaderContext, _ as isAddress, $ as isError, a0 as LoadingView, a1 as CryptoFiatActions, a2 as useViewState, a3 as useEventTargetState, a4 as commerceFlows, a5 as SharedViews, a6 as ErrorView, a7 as ConnectWidget, a8 as ProvidersContextProvider, a9 as PurchaseWidget, aa as ConnectLoader, ab as ViewContextProvider } from './index-DFqiWhIF.js';
|
|
2
|
+
import { S as SelectInput, a as SwapWidget } from './SwapWidget-B583872v.js';
|
|
3
|
+
import { B as BridgeWidget } from './BridgeWidget-CC3HoG-f.js';
|
|
4
|
+
import OnRampWidget from './OnRampWidget-D3mMWz-D.js';
|
|
5
|
+
import WalletWidget from './WalletWidget-BBu55NDF.js';
|
|
6
|
+
import SaleWidget from './SaleWidget-C3_vgKdS.js';
|
|
7
|
+
import AddTokensWidget from './AddTokensWidget-DyaSNxb9.js';
|
|
8
|
+
import { g as getAllowedBalances, T as TextInputForm } from './WalletApproveHero-OJwL-DBm.js';
|
|
9
|
+
import './useInterval-Dp0AIWS5.js';
|
|
10
|
+
import './TopUpView-ZH8ArNep.js';
|
|
11
|
+
import './FeesBreakdown-CXCCZO8Y.js';
|
|
12
|
+
import './SpendingCapHero-9hMtorO0.js';
|
|
13
|
+
import './TokenImage-DIQAWWQ8.js';
|
|
14
14
|
|
|
15
15
|
const sendCheckoutEvent = (eventTarget, detail) => {
|
|
16
|
-
const event = new CustomEvent(
|
|
16
|
+
const event = new CustomEvent(oo.IMTBL_COMMERCE_WIDGET_EVENT, { detail });
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.log('checkout app event ', eventTarget, event);
|
|
19
19
|
if (eventTarget !== undefined)
|
|
@@ -24,18 +24,18 @@ const sendCheckoutEvent = (eventTarget, detail) => {
|
|
|
24
24
|
* List of views that require a connect loader wrapper
|
|
25
25
|
*/
|
|
26
26
|
const connectLoaderFlows = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
wo.SALE,
|
|
28
|
+
wo.SWAP,
|
|
29
|
+
wo.WALLET,
|
|
30
|
+
wo.ONRAMP,
|
|
31
|
+
wo.TRANSFER,
|
|
32
32
|
];
|
|
33
33
|
/**
|
|
34
34
|
* List of views that require a providers context wrapper
|
|
35
35
|
*/
|
|
36
36
|
const providersContextFlows = [
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
wo.ADD_TOKENS,
|
|
38
|
+
wo.PURCHASE,
|
|
39
39
|
];
|
|
40
40
|
/**
|
|
41
41
|
* Check if the given view requires a connected wallet
|
|
@@ -56,25 +56,25 @@ function isProvidersContextFlow(view) {
|
|
|
56
56
|
function mapConnectWidgetEvent(event) {
|
|
57
57
|
const { type, data } = event.detail;
|
|
58
58
|
switch (type) {
|
|
59
|
-
case
|
|
59
|
+
case ao.SUCCESS:
|
|
60
60
|
return {
|
|
61
|
-
type:
|
|
61
|
+
type: go.SUCCESS,
|
|
62
62
|
data: {
|
|
63
|
-
type:
|
|
63
|
+
type: fo.CONNECT_SUCCESS,
|
|
64
64
|
data,
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
|
-
case
|
|
67
|
+
case ao.FAILURE:
|
|
68
68
|
return {
|
|
69
|
-
type:
|
|
69
|
+
type: go.FAILURE,
|
|
70
70
|
data: {
|
|
71
|
-
type:
|
|
71
|
+
type: Eo.CONNECT_FAILED,
|
|
72
72
|
data,
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
-
case
|
|
75
|
+
case ao.CLOSE_WIDGET:
|
|
76
76
|
return {
|
|
77
|
-
type:
|
|
77
|
+
type: go.CLOSE,
|
|
78
78
|
data: {},
|
|
79
79
|
};
|
|
80
80
|
default:
|
|
@@ -87,22 +87,22 @@ function mapConnectWidgetEvent(event) {
|
|
|
87
87
|
function mapWalletWidgetEvent(event) {
|
|
88
88
|
const { type, data } = event.detail;
|
|
89
89
|
switch (type) {
|
|
90
|
-
case
|
|
90
|
+
case io.NETWORK_SWITCH:
|
|
91
91
|
return {
|
|
92
|
-
type:
|
|
92
|
+
type: go.USER_ACTION,
|
|
93
93
|
data: {
|
|
94
|
-
type:
|
|
94
|
+
type: Ro.NETWORK_SWITCH,
|
|
95
95
|
data,
|
|
96
96
|
},
|
|
97
97
|
};
|
|
98
|
-
case
|
|
98
|
+
case io.DISCONNECT_WALLET:
|
|
99
99
|
return {
|
|
100
|
-
type:
|
|
100
|
+
type: go.DISCONNECTED,
|
|
101
101
|
data: {},
|
|
102
102
|
};
|
|
103
|
-
case
|
|
103
|
+
case io.CLOSE_WIDGET:
|
|
104
104
|
return {
|
|
105
|
-
type:
|
|
105
|
+
type: go.CLOSE,
|
|
106
106
|
data: {},
|
|
107
107
|
};
|
|
108
108
|
default:
|
|
@@ -115,33 +115,33 @@ function mapWalletWidgetEvent(event) {
|
|
|
115
115
|
function mapSwapWidgetEvent(event) {
|
|
116
116
|
const { type, data } = event.detail;
|
|
117
117
|
switch (type) {
|
|
118
|
-
case
|
|
118
|
+
case so.SUCCESS:
|
|
119
119
|
return {
|
|
120
|
-
type:
|
|
120
|
+
type: go.SUCCESS,
|
|
121
121
|
data: {
|
|
122
|
-
type:
|
|
122
|
+
type: fo.SWAP_SUCCESS,
|
|
123
123
|
data,
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
|
-
case
|
|
126
|
+
case so.FAILURE:
|
|
127
127
|
return {
|
|
128
|
-
type:
|
|
128
|
+
type: go.FAILURE,
|
|
129
129
|
data: {
|
|
130
|
-
type:
|
|
130
|
+
type: Eo.SWAP_FAILED,
|
|
131
131
|
data,
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
|
-
case
|
|
134
|
+
case so.REJECTED:
|
|
135
135
|
return {
|
|
136
|
-
type:
|
|
136
|
+
type: go.FAILURE,
|
|
137
137
|
data: {
|
|
138
|
-
type:
|
|
138
|
+
type: Eo.SWAP_REJECTED,
|
|
139
139
|
data,
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
|
-
case
|
|
142
|
+
case so.CLOSE_WIDGET:
|
|
143
143
|
return {
|
|
144
|
-
type:
|
|
144
|
+
type: go.CLOSE,
|
|
145
145
|
data: {},
|
|
146
146
|
};
|
|
147
147
|
default:
|
|
@@ -154,33 +154,33 @@ function mapSwapWidgetEvent(event) {
|
|
|
154
154
|
function mapAddTokensWidgetEvent(event) {
|
|
155
155
|
const { type } = event.detail;
|
|
156
156
|
switch (type) {
|
|
157
|
-
case
|
|
157
|
+
case Co.SUCCESS:
|
|
158
158
|
return {
|
|
159
|
-
type:
|
|
159
|
+
type: go.SUCCESS,
|
|
160
160
|
data: {
|
|
161
|
-
type:
|
|
161
|
+
type: fo.ADD_TOKENS_SUCCESS,
|
|
162
162
|
data: event.detail.data,
|
|
163
163
|
},
|
|
164
164
|
};
|
|
165
|
-
case
|
|
165
|
+
case Co.CONNECT_SUCCESS:
|
|
166
166
|
return {
|
|
167
|
-
type:
|
|
167
|
+
type: go.SUCCESS,
|
|
168
168
|
data: {
|
|
169
|
-
type:
|
|
169
|
+
type: fo.ADD_TOKENS_CONNECT_SUCCESS,
|
|
170
170
|
data: event.detail.data,
|
|
171
171
|
},
|
|
172
172
|
};
|
|
173
|
-
case
|
|
173
|
+
case Co.FAILURE:
|
|
174
174
|
return {
|
|
175
|
-
type:
|
|
175
|
+
type: go.FAILURE,
|
|
176
176
|
data: {
|
|
177
|
-
type:
|
|
177
|
+
type: Eo.ADD_TOKENS_FAILED,
|
|
178
178
|
data: event.detail.data,
|
|
179
179
|
},
|
|
180
180
|
};
|
|
181
|
-
case
|
|
181
|
+
case Co.CLOSE_WIDGET:
|
|
182
182
|
return {
|
|
183
|
-
type:
|
|
183
|
+
type: go.CLOSE,
|
|
184
184
|
data: {},
|
|
185
185
|
};
|
|
186
186
|
default:
|
|
@@ -193,41 +193,41 @@ function mapAddTokensWidgetEvent(event) {
|
|
|
193
193
|
function mapBridgeWidgetEvent(event) {
|
|
194
194
|
const { type, data } = event.detail;
|
|
195
195
|
switch (type) {
|
|
196
|
-
case
|
|
196
|
+
case po.TRANSACTION_SENT:
|
|
197
197
|
return {
|
|
198
|
-
type:
|
|
198
|
+
type: go.SUCCESS,
|
|
199
199
|
data: {
|
|
200
|
-
type:
|
|
200
|
+
type: fo.BRIDGE_SUCCESS,
|
|
201
201
|
data,
|
|
202
202
|
},
|
|
203
203
|
};
|
|
204
|
-
case
|
|
204
|
+
case po.CLAIM_WITHDRAWAL_SUCCESS:
|
|
205
205
|
return {
|
|
206
|
-
type:
|
|
206
|
+
type: go.SUCCESS,
|
|
207
207
|
data: {
|
|
208
|
-
type:
|
|
208
|
+
type: fo.BRIDGE_CLAIM_WITHDRAWAL_SUCCESS,
|
|
209
209
|
data,
|
|
210
210
|
},
|
|
211
211
|
};
|
|
212
|
-
case
|
|
212
|
+
case po.CLAIM_WITHDRAWAL_FAILURE:
|
|
213
213
|
return {
|
|
214
|
-
type:
|
|
214
|
+
type: go.FAILURE,
|
|
215
215
|
data: {
|
|
216
|
-
type:
|
|
216
|
+
type: Eo.BRIDGE_CLAIM_WITHDRAWAL_FAILED,
|
|
217
217
|
data,
|
|
218
218
|
},
|
|
219
219
|
};
|
|
220
|
-
case
|
|
220
|
+
case po.FAILURE:
|
|
221
221
|
return {
|
|
222
|
-
type:
|
|
222
|
+
type: go.FAILURE,
|
|
223
223
|
data: {
|
|
224
|
-
type:
|
|
224
|
+
type: Eo.BRIDGE_FAILED,
|
|
225
225
|
data,
|
|
226
226
|
},
|
|
227
227
|
};
|
|
228
|
-
case
|
|
228
|
+
case po.CLOSE_WIDGET:
|
|
229
229
|
return {
|
|
230
|
-
type:
|
|
230
|
+
type: go.CLOSE,
|
|
231
231
|
data: {},
|
|
232
232
|
};
|
|
233
233
|
default:
|
|
@@ -240,25 +240,25 @@ function mapBridgeWidgetEvent(event) {
|
|
|
240
240
|
function mapOnrampWidgetEvent(event) {
|
|
241
241
|
const { type, data } = event.detail;
|
|
242
242
|
switch (type) {
|
|
243
|
-
case
|
|
243
|
+
case mo.SUCCESS:
|
|
244
244
|
return {
|
|
245
|
-
type:
|
|
245
|
+
type: go.SUCCESS,
|
|
246
246
|
data: {
|
|
247
|
-
type:
|
|
247
|
+
type: fo.ONRAMP_SUCCESS,
|
|
248
248
|
data,
|
|
249
249
|
},
|
|
250
250
|
};
|
|
251
|
-
case
|
|
251
|
+
case mo.FAILURE:
|
|
252
252
|
return {
|
|
253
|
-
type:
|
|
253
|
+
type: go.FAILURE,
|
|
254
254
|
data: {
|
|
255
|
-
type:
|
|
255
|
+
type: Eo.ONRAMP_FAILED,
|
|
256
256
|
data,
|
|
257
257
|
},
|
|
258
258
|
};
|
|
259
|
-
case
|
|
259
|
+
case mo.CLOSE_WIDGET:
|
|
260
260
|
return {
|
|
261
|
-
type:
|
|
261
|
+
type: go.CLOSE,
|
|
262
262
|
data: {},
|
|
263
263
|
};
|
|
264
264
|
default:
|
|
@@ -268,48 +268,48 @@ function mapOnrampWidgetEvent(event) {
|
|
|
268
268
|
function mapSaleWidgetEvent(event) {
|
|
269
269
|
const { type, data } = event.detail;
|
|
270
270
|
switch (type) {
|
|
271
|
-
case
|
|
271
|
+
case co.SUCCESS:
|
|
272
272
|
return {
|
|
273
|
-
type:
|
|
273
|
+
type: go.SUCCESS,
|
|
274
274
|
data: {
|
|
275
|
-
type:
|
|
275
|
+
type: fo.SALE_SUCCESS,
|
|
276
276
|
data,
|
|
277
277
|
},
|
|
278
278
|
};
|
|
279
|
-
case
|
|
279
|
+
case co.FAILURE:
|
|
280
280
|
return {
|
|
281
|
-
type:
|
|
281
|
+
type: go.FAILURE,
|
|
282
282
|
data: {
|
|
283
|
-
type:
|
|
283
|
+
type: Eo.SALE_FAILED,
|
|
284
284
|
data,
|
|
285
285
|
},
|
|
286
286
|
};
|
|
287
|
-
case
|
|
287
|
+
case co.CLOSE_WIDGET:
|
|
288
288
|
return {
|
|
289
|
-
type:
|
|
289
|
+
type: go.CLOSE,
|
|
290
290
|
data: {},
|
|
291
291
|
};
|
|
292
|
-
case
|
|
292
|
+
case co.TRANSACTION_SUCCESS:
|
|
293
293
|
return {
|
|
294
|
-
type:
|
|
294
|
+
type: go.SUCCESS,
|
|
295
295
|
data: {
|
|
296
|
-
type:
|
|
296
|
+
type: fo.SALE_TRANSACTION_SUCCESS,
|
|
297
297
|
data,
|
|
298
298
|
},
|
|
299
299
|
};
|
|
300
|
-
case
|
|
300
|
+
case co.PAYMENT_METHOD:
|
|
301
301
|
return {
|
|
302
|
-
type:
|
|
302
|
+
type: go.USER_ACTION,
|
|
303
303
|
data: {
|
|
304
|
-
type:
|
|
304
|
+
type: Ro.PAYMENT_METHOD_SELECTED,
|
|
305
305
|
data,
|
|
306
306
|
},
|
|
307
307
|
};
|
|
308
|
-
case
|
|
308
|
+
case co.PAYMENT_TOKEN:
|
|
309
309
|
return {
|
|
310
|
-
type:
|
|
310
|
+
type: go.USER_ACTION,
|
|
311
311
|
data: {
|
|
312
|
-
type:
|
|
312
|
+
type: Ro.PAYMENT_TOKEN_SELECTED,
|
|
313
313
|
data,
|
|
314
314
|
},
|
|
315
315
|
};
|
|
@@ -320,25 +320,25 @@ function mapSaleWidgetEvent(event) {
|
|
|
320
320
|
function mapPurchaseWidgetEvent(event) {
|
|
321
321
|
const { type, data } = event.detail;
|
|
322
322
|
switch (type) {
|
|
323
|
-
case
|
|
323
|
+
case To.SUCCESS:
|
|
324
324
|
return {
|
|
325
|
-
type:
|
|
325
|
+
type: go.SUCCESS,
|
|
326
326
|
data: {
|
|
327
|
-
type:
|
|
327
|
+
type: fo.SALE_SUCCESS,
|
|
328
328
|
data,
|
|
329
329
|
},
|
|
330
330
|
};
|
|
331
|
-
case
|
|
331
|
+
case To.FAILURE:
|
|
332
332
|
return {
|
|
333
|
-
type:
|
|
333
|
+
type: go.FAILURE,
|
|
334
334
|
data: {
|
|
335
|
-
type:
|
|
335
|
+
type: Eo.SALE_FAILED,
|
|
336
336
|
data,
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
|
-
case
|
|
339
|
+
case To.CLOSE_WIDGET:
|
|
340
340
|
return {
|
|
341
|
-
type:
|
|
341
|
+
type: go.CLOSE,
|
|
342
342
|
data: {},
|
|
343
343
|
};
|
|
344
344
|
default:
|
|
@@ -349,28 +349,28 @@ function mapPurchaseWidgetEvent(event) {
|
|
|
349
349
|
* Map widget events to commerce widget event detail
|
|
350
350
|
*/
|
|
351
351
|
function getCommerceWidgetEvent(event) {
|
|
352
|
-
if (event.detail.type ===
|
|
352
|
+
if (event.detail.type === no.PROVIDER_UPDATED) {
|
|
353
353
|
return {
|
|
354
|
-
type:
|
|
354
|
+
type: go.PROVIDER_UPDATED,
|
|
355
355
|
data: event.detail.data,
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
358
|
switch (event.type) {
|
|
359
|
-
case
|
|
359
|
+
case oo.IMTBL_CONNECT_WIDGET_EVENT:
|
|
360
360
|
return mapConnectWidgetEvent(event);
|
|
361
|
-
case
|
|
361
|
+
case oo.IMTBL_WALLET_WIDGET_EVENT:
|
|
362
362
|
return mapWalletWidgetEvent(event);
|
|
363
|
-
case
|
|
363
|
+
case oo.IMTBL_SWAP_WIDGET_EVENT:
|
|
364
364
|
return mapSwapWidgetEvent(event);
|
|
365
|
-
case
|
|
365
|
+
case oo.IMTBL_ADD_TOKENS_WIDGET_EVENT:
|
|
366
366
|
return mapAddTokensWidgetEvent(event);
|
|
367
|
-
case
|
|
367
|
+
case oo.IMTBL_BRIDGE_WIDGET_EVENT:
|
|
368
368
|
return mapBridgeWidgetEvent(event);
|
|
369
|
-
case
|
|
369
|
+
case oo.IMTBL_ONRAMP_WIDGET_EVENT:
|
|
370
370
|
return mapOnrampWidgetEvent(event);
|
|
371
|
-
case
|
|
371
|
+
case oo.IMTBL_SALE_WIDGET_EVENT:
|
|
372
372
|
return mapSaleWidgetEvent(event);
|
|
373
|
-
case
|
|
373
|
+
case oo.IMTBL_PURCHASE_WIDGET_EVENT:
|
|
374
374
|
return mapPurchaseWidgetEvent(event);
|
|
375
375
|
default:
|
|
376
376
|
throw new Error(`Unknown widget event type "${event.type}"`);
|
|
@@ -382,20 +382,20 @@ function getCommerceWidgetEvent(event) {
|
|
|
382
382
|
*/
|
|
383
383
|
function getViewFromOrchestrationEventType(type) {
|
|
384
384
|
switch (type) {
|
|
385
|
-
case
|
|
386
|
-
return
|
|
387
|
-
case
|
|
388
|
-
return
|
|
389
|
-
case
|
|
390
|
-
return
|
|
391
|
-
case
|
|
392
|
-
return
|
|
393
|
-
case
|
|
394
|
-
return
|
|
395
|
-
case
|
|
396
|
-
return
|
|
397
|
-
case
|
|
398
|
-
return
|
|
385
|
+
case uo.REQUEST_SWAP:
|
|
386
|
+
return wo.SWAP;
|
|
387
|
+
case uo.REQUEST_CONNECT:
|
|
388
|
+
return wo.CONNECT;
|
|
389
|
+
case uo.REQUEST_WALLET:
|
|
390
|
+
return wo.WALLET;
|
|
391
|
+
case uo.REQUEST_BRIDGE:
|
|
392
|
+
return wo.BRIDGE;
|
|
393
|
+
case uo.REQUEST_ONRAMP:
|
|
394
|
+
return wo.ONRAMP;
|
|
395
|
+
case uo.REQUEST_ADD_TOKENS:
|
|
396
|
+
return wo.ADD_TOKENS;
|
|
397
|
+
case uo.REQUEST_PURCHASE:
|
|
398
|
+
return wo.PURCHASE;
|
|
399
399
|
default:
|
|
400
400
|
return null;
|
|
401
401
|
}
|
|
@@ -403,14 +403,14 @@ function getViewFromOrchestrationEventType(type) {
|
|
|
403
403
|
|
|
404
404
|
/** Orchestration Events List */
|
|
405
405
|
const orchestrationEvents = [
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
406
|
+
uo.REQUEST_CONNECT,
|
|
407
|
+
uo.REQUEST_WALLET,
|
|
408
|
+
uo.REQUEST_SWAP,
|
|
409
|
+
uo.REQUEST_BRIDGE,
|
|
410
|
+
uo.REQUEST_ONRAMP,
|
|
411
|
+
uo.REQUEST_ADD_TOKENS,
|
|
412
|
+
uo.REQUEST_PURCHASE,
|
|
413
|
+
uo.REQUEST_GO_BACK,
|
|
414
414
|
];
|
|
415
415
|
/**
|
|
416
416
|
* Check if event is orchestration event
|
|
@@ -421,14 +421,14 @@ function isOrchestrationEvent(event) {
|
|
|
421
421
|
|
|
422
422
|
/** Widget Events List */
|
|
423
423
|
const widgetEvents = [
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
424
|
+
oo.IMTBL_CONNECT_WIDGET_EVENT,
|
|
425
|
+
oo.IMTBL_WALLET_WIDGET_EVENT,
|
|
426
|
+
oo.IMTBL_SWAP_WIDGET_EVENT,
|
|
427
|
+
oo.IMTBL_BRIDGE_WIDGET_EVENT,
|
|
428
|
+
oo.IMTBL_ONRAMP_WIDGET_EVENT,
|
|
429
|
+
oo.IMTBL_SALE_WIDGET_EVENT,
|
|
430
|
+
oo.IMTBL_ADD_TOKENS_WIDGET_EVENT,
|
|
431
|
+
oo.IMTBL_PURCHASE_WIDGET_EVENT,
|
|
432
432
|
];
|
|
433
433
|
/**
|
|
434
434
|
* Subscribe and Handle widget events
|
|
@@ -440,7 +440,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
440
440
|
*/
|
|
441
441
|
const handleOrchestrationEvent = (event) => {
|
|
442
442
|
const { type, data } = event.detail;
|
|
443
|
-
if (type ===
|
|
443
|
+
if (type === uo.REQUEST_GO_BACK) {
|
|
444
444
|
viewDispatch({
|
|
445
445
|
payload: {
|
|
446
446
|
type: ViewActions.UPDATE_VIEW,
|
|
@@ -449,7 +449,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
449
449
|
});
|
|
450
450
|
return;
|
|
451
451
|
}
|
|
452
|
-
if (type ===
|
|
452
|
+
if (type === uo.REQUEST_ONRAMP) {
|
|
453
453
|
const onRampEvent = data;
|
|
454
454
|
if (onRampEvent.provider) {
|
|
455
455
|
handleProviderUpdated(onRampEvent.provider);
|
|
@@ -483,7 +483,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
483
483
|
// ignore walletconnect provider updated event on CONNECT
|
|
484
484
|
// as that is not really consumed and the provider is available to the consumer on success event
|
|
485
485
|
// GFI-596
|
|
486
|
-
const isConnectProviderUpdatedEvent = customEvent.detail.type ===
|
|
486
|
+
const isConnectProviderUpdatedEvent = customEvent.detail.type === ao.WALLETCONNECT_PROVIDER_UPDATED;
|
|
487
487
|
if (isConnectProviderUpdatedEvent) {
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
@@ -507,7 +507,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
507
507
|
function getConnectLoaderParams(view, checkout, browserProvider) {
|
|
508
508
|
const { type } = view;
|
|
509
509
|
switch (type) {
|
|
510
|
-
case
|
|
510
|
+
case wo.WALLET:
|
|
511
511
|
return {
|
|
512
512
|
checkout,
|
|
513
513
|
browserProvider,
|
|
@@ -517,8 +517,8 @@ function getConnectLoaderParams(view, checkout, browserProvider) {
|
|
|
517
517
|
checkout.config.l2ChainId,
|
|
518
518
|
],
|
|
519
519
|
};
|
|
520
|
-
case
|
|
521
|
-
case
|
|
520
|
+
case wo.ONRAMP:
|
|
521
|
+
case wo.ADD_TOKENS:
|
|
522
522
|
return {
|
|
523
523
|
checkout,
|
|
524
524
|
browserProvider,
|
|
@@ -528,9 +528,9 @@ function getConnectLoaderParams(view, checkout, browserProvider) {
|
|
|
528
528
|
checkout.config.l2ChainId,
|
|
529
529
|
],
|
|
530
530
|
};
|
|
531
|
-
case
|
|
532
|
-
case
|
|
533
|
-
case
|
|
531
|
+
case wo.SALE:
|
|
532
|
+
case wo.SWAP:
|
|
533
|
+
case wo.TRANSFER:
|
|
534
534
|
return {
|
|
535
535
|
checkout,
|
|
536
536
|
browserProvider,
|
|
@@ -740,7 +740,7 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
740
740
|
}, [token]);
|
|
741
741
|
const isButtonDisabled = reactExports.useMemo(() => !viewState.amount || !viewState.toAddress || !token, [viewState.amount, viewState.toAddress, token]);
|
|
742
742
|
return (jsx(SimpleLayout, { header: (jsx(HeaderNavigation, { title: t('views.TRANSFER.header.title'), onCloseButtonClick: () => sendCloseWidgetEvent(eventTarget), showBack: showBackButton, onBackButtonClick: () => {
|
|
743
|
-
orchestrationEvents$1.sendRequestGoBackEvent(eventTarget,
|
|
743
|
+
orchestrationEvents$1.sendRequestGoBackEvent(eventTarget, oo.IMTBL_TRANSFER_WIDGET_EVENT, {});
|
|
744
744
|
} })), children: jsxs(Stack, { justifyContent: "space-between", sx: {
|
|
745
745
|
height: '100%',
|
|
746
746
|
mt: 'base.spacing.x6',
|
|
@@ -750,9 +750,9 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
const sendSuccessEvent = (eventTarget, transactionHash) => {
|
|
753
|
-
const successEvent = new CustomEvent(
|
|
753
|
+
const successEvent = new CustomEvent(oo.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
754
754
|
detail: {
|
|
755
|
-
type:
|
|
755
|
+
type: Io.SUCCESS,
|
|
756
756
|
data: {
|
|
757
757
|
transactionHash,
|
|
758
758
|
},
|
|
@@ -764,9 +764,9 @@ const sendSuccessEvent = (eventTarget, transactionHash) => {
|
|
|
764
764
|
eventTarget.dispatchEvent(successEvent);
|
|
765
765
|
};
|
|
766
766
|
const sendFailedEvent = (eventTarget, reason) => {
|
|
767
|
-
const failedEvent = new CustomEvent(
|
|
767
|
+
const failedEvent = new CustomEvent(oo.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
768
768
|
detail: {
|
|
769
|
-
type:
|
|
769
|
+
type: Io.FAILURE,
|
|
770
770
|
data: {
|
|
771
771
|
reason,
|
|
772
772
|
timestamp: new Date().getTime(),
|
|
@@ -779,9 +779,9 @@ const sendFailedEvent = (eventTarget, reason) => {
|
|
|
779
779
|
eventTarget.dispatchEvent(failedEvent);
|
|
780
780
|
};
|
|
781
781
|
const sendRejectedEvent = (eventTarget, reason) => {
|
|
782
|
-
const rejectedEvent = new CustomEvent(
|
|
782
|
+
const rejectedEvent = new CustomEvent(oo.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
783
783
|
detail: {
|
|
784
|
-
type:
|
|
784
|
+
type: Io.REJECTED,
|
|
785
785
|
data: {
|
|
786
786
|
reason,
|
|
787
787
|
timestamp: new Date().getTime(),
|
|
@@ -958,8 +958,8 @@ function CommerceWidget(props) {
|
|
|
958
958
|
const commerceReducerValues = reactExports.useMemo(() => ({ commerceState, commerceDispatch }), [commerceState, commerceDispatch]);
|
|
959
959
|
const { provider } = commerceState;
|
|
960
960
|
const connectLoaderParams = reactExports.useMemo(() => getConnectLoaderParams(view, checkout, provider || browserProvider), [view, checkout, provider, browserProvider]);
|
|
961
|
-
const connectLoaderSuccessEvent = (flowParams.flow ===
|
|
962
|
-
|| flowParams.flow ===
|
|
961
|
+
const connectLoaderSuccessEvent = (flowParams.flow === wo.ADD_TOKENS
|
|
962
|
+
|| flowParams.flow === wo.PURCHASE) ? () => { } : undefined;
|
|
963
963
|
const goToPreviousView = reactExports.useCallback(() => {
|
|
964
964
|
const sharedViews = [
|
|
965
965
|
SharedViews.LOADING_VIEW,
|
|
@@ -1057,28 +1057,28 @@ function CommerceWidget(props) {
|
|
|
1057
1057
|
const showBackButton = !!view.data?.showBackButton;
|
|
1058
1058
|
return (jsx(ViewContextProvider, { children: jsxs(CommerceContext.Provider, { value: commerceReducerValues, children: [view.type === SharedViews.LOADING_VIEW && (jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { onCloseClick: () => {
|
|
1059
1059
|
sendCheckoutEvent(eventTarget, {
|
|
1060
|
-
type:
|
|
1060
|
+
type: go.CLOSE,
|
|
1061
1061
|
data: {},
|
|
1062
1062
|
});
|
|
1063
1063
|
}, onActionClick: () => {
|
|
1064
1064
|
// TODO: trigger a retry
|
|
1065
|
-
}, actionText: t('views.ERROR_VIEW.actionText') })), view.type ===
|
|
1065
|
+
}, actionText: t('views.ERROR_VIEW.actionText') })), view.type === wo.CONNECT && (jsx(ConnectWidget, { config: widgetsConfig, checkout: checkout, sendCloseEventOverride: () => {
|
|
1066
1066
|
sendCheckoutEvent(eventTarget, {
|
|
1067
|
-
type:
|
|
1067
|
+
type: go.CLOSE,
|
|
1068
1068
|
data: {},
|
|
1069
1069
|
});
|
|
1070
|
-
}, ...(view.data.params || {}) })), view.type ===
|
|
1070
|
+
}, ...(view.data.params || {}) })), view.type === wo.BRIDGE && (jsx(BridgeWidget, { config: widgetsConfig, checkout: checkout, browserProvider: browserProvider, showBackButton: showBackButton, ...(view.data.params || {}) })), shouldWrapWithProvidersContext && view.type === wo.ADD_TOKENS && (jsx(ProvidersContextProvider, { initialState: { checkout, toProvider: view.data.params.toProvider }, children: jsx(AddTokensWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton }) })), shouldWrapWithProvidersContext && view.type === wo.PURCHASE && (jsx(ProvidersContextProvider, { initialState: { checkout }, children: jsx(PurchaseWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton }) })), shouldWrapWithConnectLoader && (jsx(ConnectLoader, { widgetConfig: widgetsConfig, params: connectLoaderParams, successEvent: connectLoaderSuccessEvent, closeEvent: () => {
|
|
1071
1071
|
sendCheckoutEvent(eventTarget, {
|
|
1072
|
-
type:
|
|
1072
|
+
type: go.CLOSE,
|
|
1073
1073
|
data: {},
|
|
1074
1074
|
});
|
|
1075
|
-
}, showBackButton: showBackButton, goBackEvent: goToPreviousView, children: jsxs(reactExports.Suspense, { fallback: jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: [view.type ===
|
|
1075
|
+
}, showBackButton: showBackButton, goBackEvent: goToPreviousView, children: jsxs(reactExports.Suspense, { fallback: jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: [view.type === wo.WALLET && (jsx(WalletWidget, { config: widgetsConfig, walletConfig: {
|
|
1076
1076
|
showNetworkMenu: true,
|
|
1077
1077
|
showDisconnectButton: true,
|
|
1078
1078
|
...view.data.config,
|
|
1079
|
-
}, ...(view.data.params || {}) })), view.type ===
|
|
1079
|
+
}, ...(view.data.params || {}) })), view.type === wo.SALE && (jsx(SaleWidget, { config: widgetsConfig, ...(view.data.params || {}), hideExcludedPaymentTypes: false,
|
|
1080
1080
|
waitFulfillmentSettlements: true,
|
|
1081
|
-
...view.data.config })), view.type ===
|
|
1081
|
+
...view.data.config })), view.type === wo.SWAP && (jsx(SwapWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })), view.type === wo.ONRAMP && (jsx(OnRampWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton })), view.type === wo.TRANSFER && (jsx(TransferWidget, { config: widgetsConfig, ...(view.data.params || {}), ...(view.data.config || {}), showBackButton: showBackButton }))] }) }))] }) }));
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
1084
|
export { CommerceWidget as default };
|