@imtbl/checkout-widgets 2.10.3-alpha.0 → 2.10.4-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-Dfnd2VvT.js → AddTokensWidget-7xP3ash_.js} +24 -24
- package/dist/browser/{BridgeWidget-BM10WzmU.js → BridgeWidget-xF3mC-MN.js} +32 -32
- package/dist/browser/{CommerceWidget-Cz82zzFs.js → CommerceWidget-Dx44BFWy.js} +182 -182
- package/dist/browser/{FeesBreakdown-BsQ1oMQE.js → FeesBreakdown-Dy1ctSpO.js} +2 -2
- package/dist/browser/{OnRampWidget-cMjW2rIE.js → OnRampWidget-hWptERhu.js} +40 -26
- package/dist/browser/{SaleWidget-CU6ufFXx.js → SaleWidget-SueR-4Ck.js} +45 -45
- package/dist/browser/{SpendingCapHero-CELugT6p.js → SpendingCapHero-kPkYD5HR.js} +1 -1
- package/dist/browser/{SwapWidget-BrIskEwG.js → SwapWidget-B9Lgj2-6.js} +12 -12
- package/dist/browser/{TokenImage-BFM95uHq.js → TokenImage-C44Kn3Pq.js} +1 -1
- package/dist/browser/{TopUpView-h1VXHAgm.js → TopUpView-DZ6urV-T.js} +4 -4
- package/dist/browser/{WalletApproveHero-B2ON1dC3.js → WalletApproveHero-B3gMB-AI.js} +2 -2
- package/dist/browser/{WalletWidget-CReuAddE.js → WalletWidget-Cq1IwRPp.js} +11 -11
- package/dist/browser/{auto-track-C985jpFQ.js → auto-track-1sIh5Cg-.js} +1 -1
- package/dist/browser/{index-SmtxzcBz.js → index-BAjyTG-F.js} +1 -1
- package/dist/browser/{index-0LzWkrX3.js → index-BS6qjzzl.js} +1 -1
- package/dist/browser/{index-Co-HzKB-.js → index-BpeF_Hv4.js} +1 -1
- package/dist/browser/{index-BbuVyAAi.js → index-CJrC7v34.js} +1 -1
- package/dist/browser/{index-COUrrJgu.js → index-C_2UQ8ka.js} +2 -2
- package/dist/browser/{index-DEgS4sei.js → index-Cc4A5E_A.js} +1 -1
- package/dist/browser/{index-BJKKPxKK.js → index-DA9Xu4LZ.js} +1 -1
- package/dist/browser/{index-Dm7h0Kka.js → index-DFAGr0d5.js} +348 -338
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-CDN3jaZ3.js → index.umd-BDwQTcot.js} +1 -1
- package/dist/browser/{useInterval-jAu1Whfi.js → useInterval-apxTIl_n.js} +1 -1
- package/dist/types/components/Transak/useTransakIframe.d.ts +5 -0
- package/package.json +7 -7
- package/src/components/Transak/useTransakIframe.ts +39 -12
- package/src/widgets/on-ramp/views/OnRampMain.tsx +56 -26
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { o as oo,
|
|
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 { r as ro, A as Ao, o as oo, m as mo, n as no, f as fo, g as go, a as ao, E as Eo, i as io, R as Ro, l as lo, u as uo, s as so, C as Co, T as To, p as po, b as reactExports, V as ViewActions, c as parseUnits, d as formatZeroAmount, e as calculateCryptoToFiat, h as Contract, j as ie, k as useTranslation, q as dist, t as getRemoteRive, v as tt, w as jsx, x as jsxs, B as Box, H as Heading, L as Link, y as Button, S as Stack, z as SimpleLayout, D as Body, F as useAnalytics, G as EventTargetContext, I as CryptoFiatContext, J as tokenValueFormat, K as getDefaultTokenImage, U as UserJourney, M as HeaderNavigation, N as sendCloseWidgetEvent, O as orchestrationEvents$1, P as amountInputValidation, 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-DFAGr0d5.js';
|
|
2
|
+
import { S as SelectInput, a as SwapWidget } from './SwapWidget-B9Lgj2-6.js';
|
|
3
|
+
import { B as BridgeWidget } from './BridgeWidget-xF3mC-MN.js';
|
|
4
|
+
import OnRampWidget from './OnRampWidget-hWptERhu.js';
|
|
5
|
+
import WalletWidget from './WalletWidget-Cq1IwRPp.js';
|
|
6
|
+
import SaleWidget from './SaleWidget-SueR-4Ck.js';
|
|
7
|
+
import AddTokensWidget from './AddTokensWidget-7xP3ash_.js';
|
|
8
|
+
import { g as getAllowedBalances, T as TextInputForm } from './WalletApproveHero-B3gMB-AI.js';
|
|
9
|
+
import './useInterval-apxTIl_n.js';
|
|
10
|
+
import './TopUpView-DZ6urV-T.js';
|
|
11
|
+
import './FeesBreakdown-Dy1ctSpO.js';
|
|
12
|
+
import './SpendingCapHero-kPkYD5HR.js';
|
|
13
|
+
import './TokenImage-C44Kn3Pq.js';
|
|
14
14
|
|
|
15
15
|
const sendCheckoutEvent = (eventTarget, detail) => {
|
|
16
|
-
const event = new CustomEvent(
|
|
16
|
+
const event = new CustomEvent(ro.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
|
+
Ao.SALE,
|
|
28
|
+
Ao.SWAP,
|
|
29
|
+
Ao.WALLET,
|
|
30
|
+
Ao.ONRAMP,
|
|
31
|
+
Ao.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
|
+
Ao.ADD_TOKENS,
|
|
38
|
+
Ao.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 no.SUCCESS:
|
|
60
60
|
return {
|
|
61
|
-
type:
|
|
61
|
+
type: mo.SUCCESS,
|
|
62
62
|
data: {
|
|
63
|
-
type:
|
|
63
|
+
type: go.CONNECT_SUCCESS,
|
|
64
64
|
data,
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
|
-
case
|
|
67
|
+
case no.FAILURE:
|
|
68
68
|
return {
|
|
69
|
-
type:
|
|
69
|
+
type: mo.FAILURE,
|
|
70
70
|
data: {
|
|
71
|
-
type:
|
|
71
|
+
type: fo.CONNECT_FAILED,
|
|
72
72
|
data,
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
-
case
|
|
75
|
+
case no.CLOSE_WIDGET:
|
|
76
76
|
return {
|
|
77
|
-
type:
|
|
77
|
+
type: mo.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 ao.NETWORK_SWITCH:
|
|
91
91
|
return {
|
|
92
|
-
type:
|
|
92
|
+
type: mo.USER_ACTION,
|
|
93
93
|
data: {
|
|
94
|
-
type:
|
|
94
|
+
type: Eo.NETWORK_SWITCH,
|
|
95
95
|
data,
|
|
96
96
|
},
|
|
97
97
|
};
|
|
98
|
-
case
|
|
98
|
+
case ao.DISCONNECT_WALLET:
|
|
99
99
|
return {
|
|
100
|
-
type:
|
|
100
|
+
type: mo.DISCONNECTED,
|
|
101
101
|
data: {},
|
|
102
102
|
};
|
|
103
|
-
case
|
|
103
|
+
case ao.CLOSE_WIDGET:
|
|
104
104
|
return {
|
|
105
|
-
type:
|
|
105
|
+
type: mo.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 io.SUCCESS:
|
|
119
119
|
return {
|
|
120
|
-
type:
|
|
120
|
+
type: mo.SUCCESS,
|
|
121
121
|
data: {
|
|
122
|
-
type:
|
|
122
|
+
type: go.SWAP_SUCCESS,
|
|
123
123
|
data,
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
|
-
case
|
|
126
|
+
case io.FAILURE:
|
|
127
127
|
return {
|
|
128
|
-
type:
|
|
128
|
+
type: mo.FAILURE,
|
|
129
129
|
data: {
|
|
130
|
-
type:
|
|
130
|
+
type: fo.SWAP_FAILED,
|
|
131
131
|
data,
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
|
-
case
|
|
134
|
+
case io.REJECTED:
|
|
135
135
|
return {
|
|
136
|
-
type:
|
|
136
|
+
type: mo.FAILURE,
|
|
137
137
|
data: {
|
|
138
|
-
type:
|
|
138
|
+
type: fo.SWAP_REJECTED,
|
|
139
139
|
data,
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
|
-
case
|
|
142
|
+
case io.CLOSE_WIDGET:
|
|
143
143
|
return {
|
|
144
|
-
type:
|
|
144
|
+
type: mo.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 Ro.SUCCESS:
|
|
158
158
|
return {
|
|
159
|
-
type:
|
|
159
|
+
type: mo.SUCCESS,
|
|
160
160
|
data: {
|
|
161
|
-
type:
|
|
161
|
+
type: go.ADD_TOKENS_SUCCESS,
|
|
162
162
|
data: event.detail.data,
|
|
163
163
|
},
|
|
164
164
|
};
|
|
165
|
-
case
|
|
165
|
+
case Ro.CONNECT_SUCCESS:
|
|
166
166
|
return {
|
|
167
|
-
type:
|
|
167
|
+
type: mo.SUCCESS,
|
|
168
168
|
data: {
|
|
169
|
-
type:
|
|
169
|
+
type: go.ADD_TOKENS_CONNECT_SUCCESS,
|
|
170
170
|
data: event.detail.data,
|
|
171
171
|
},
|
|
172
172
|
};
|
|
173
|
-
case
|
|
173
|
+
case Ro.FAILURE:
|
|
174
174
|
return {
|
|
175
|
-
type:
|
|
175
|
+
type: mo.FAILURE,
|
|
176
176
|
data: {
|
|
177
|
-
type:
|
|
177
|
+
type: fo.ADD_TOKENS_FAILED,
|
|
178
178
|
data: event.detail.data,
|
|
179
179
|
},
|
|
180
180
|
};
|
|
181
|
-
case
|
|
181
|
+
case Ro.CLOSE_WIDGET:
|
|
182
182
|
return {
|
|
183
|
-
type:
|
|
183
|
+
type: mo.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 lo.TRANSACTION_SENT:
|
|
197
197
|
return {
|
|
198
|
-
type:
|
|
198
|
+
type: mo.SUCCESS,
|
|
199
199
|
data: {
|
|
200
|
-
type:
|
|
200
|
+
type: go.BRIDGE_SUCCESS,
|
|
201
201
|
data,
|
|
202
202
|
},
|
|
203
203
|
};
|
|
204
|
-
case
|
|
204
|
+
case lo.CLAIM_WITHDRAWAL_SUCCESS:
|
|
205
205
|
return {
|
|
206
|
-
type:
|
|
206
|
+
type: mo.SUCCESS,
|
|
207
207
|
data: {
|
|
208
|
-
type:
|
|
208
|
+
type: go.BRIDGE_CLAIM_WITHDRAWAL_SUCCESS,
|
|
209
209
|
data,
|
|
210
210
|
},
|
|
211
211
|
};
|
|
212
|
-
case
|
|
212
|
+
case lo.CLAIM_WITHDRAWAL_FAILURE:
|
|
213
213
|
return {
|
|
214
|
-
type:
|
|
214
|
+
type: mo.FAILURE,
|
|
215
215
|
data: {
|
|
216
|
-
type:
|
|
216
|
+
type: fo.BRIDGE_CLAIM_WITHDRAWAL_FAILED,
|
|
217
217
|
data,
|
|
218
218
|
},
|
|
219
219
|
};
|
|
220
|
-
case
|
|
220
|
+
case lo.FAILURE:
|
|
221
221
|
return {
|
|
222
|
-
type:
|
|
222
|
+
type: mo.FAILURE,
|
|
223
223
|
data: {
|
|
224
|
-
type:
|
|
224
|
+
type: fo.BRIDGE_FAILED,
|
|
225
225
|
data,
|
|
226
226
|
},
|
|
227
227
|
};
|
|
228
|
-
case
|
|
228
|
+
case lo.CLOSE_WIDGET:
|
|
229
229
|
return {
|
|
230
|
-
type:
|
|
230
|
+
type: mo.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 uo.SUCCESS:
|
|
244
244
|
return {
|
|
245
|
-
type:
|
|
245
|
+
type: mo.SUCCESS,
|
|
246
246
|
data: {
|
|
247
|
-
type:
|
|
247
|
+
type: go.ONRAMP_SUCCESS,
|
|
248
248
|
data,
|
|
249
249
|
},
|
|
250
250
|
};
|
|
251
|
-
case
|
|
251
|
+
case uo.FAILURE:
|
|
252
252
|
return {
|
|
253
|
-
type:
|
|
253
|
+
type: mo.FAILURE,
|
|
254
254
|
data: {
|
|
255
|
-
type:
|
|
255
|
+
type: fo.ONRAMP_FAILED,
|
|
256
256
|
data,
|
|
257
257
|
},
|
|
258
258
|
};
|
|
259
|
-
case
|
|
259
|
+
case uo.CLOSE_WIDGET:
|
|
260
260
|
return {
|
|
261
|
-
type:
|
|
261
|
+
type: mo.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 so.SUCCESS:
|
|
272
272
|
return {
|
|
273
|
-
type:
|
|
273
|
+
type: mo.SUCCESS,
|
|
274
274
|
data: {
|
|
275
|
-
type:
|
|
275
|
+
type: go.SALE_SUCCESS,
|
|
276
276
|
data,
|
|
277
277
|
},
|
|
278
278
|
};
|
|
279
|
-
case
|
|
279
|
+
case so.FAILURE:
|
|
280
280
|
return {
|
|
281
|
-
type:
|
|
281
|
+
type: mo.FAILURE,
|
|
282
282
|
data: {
|
|
283
|
-
type:
|
|
283
|
+
type: fo.SALE_FAILED,
|
|
284
284
|
data,
|
|
285
285
|
},
|
|
286
286
|
};
|
|
287
|
-
case
|
|
287
|
+
case so.CLOSE_WIDGET:
|
|
288
288
|
return {
|
|
289
|
-
type:
|
|
289
|
+
type: mo.CLOSE,
|
|
290
290
|
data: {},
|
|
291
291
|
};
|
|
292
|
-
case
|
|
292
|
+
case so.TRANSACTION_SUCCESS:
|
|
293
293
|
return {
|
|
294
|
-
type:
|
|
294
|
+
type: mo.SUCCESS,
|
|
295
295
|
data: {
|
|
296
|
-
type:
|
|
296
|
+
type: go.SALE_TRANSACTION_SUCCESS,
|
|
297
297
|
data,
|
|
298
298
|
},
|
|
299
299
|
};
|
|
300
|
-
case
|
|
300
|
+
case so.PAYMENT_METHOD:
|
|
301
301
|
return {
|
|
302
|
-
type:
|
|
302
|
+
type: mo.USER_ACTION,
|
|
303
303
|
data: {
|
|
304
|
-
type:
|
|
304
|
+
type: Eo.PAYMENT_METHOD_SELECTED,
|
|
305
305
|
data,
|
|
306
306
|
},
|
|
307
307
|
};
|
|
308
|
-
case
|
|
308
|
+
case so.PAYMENT_TOKEN:
|
|
309
309
|
return {
|
|
310
|
-
type:
|
|
310
|
+
type: mo.USER_ACTION,
|
|
311
311
|
data: {
|
|
312
|
-
type:
|
|
312
|
+
type: Eo.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 Co.SUCCESS:
|
|
324
324
|
return {
|
|
325
|
-
type:
|
|
325
|
+
type: mo.SUCCESS,
|
|
326
326
|
data: {
|
|
327
|
-
type:
|
|
327
|
+
type: go.SALE_SUCCESS,
|
|
328
328
|
data,
|
|
329
329
|
},
|
|
330
330
|
};
|
|
331
|
-
case
|
|
331
|
+
case Co.FAILURE:
|
|
332
332
|
return {
|
|
333
|
-
type:
|
|
333
|
+
type: mo.FAILURE,
|
|
334
334
|
data: {
|
|
335
|
-
type:
|
|
335
|
+
type: fo.SALE_FAILED,
|
|
336
336
|
data,
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
|
-
case
|
|
339
|
+
case Co.CLOSE_WIDGET:
|
|
340
340
|
return {
|
|
341
|
-
type:
|
|
341
|
+
type: mo.CLOSE,
|
|
342
342
|
data: {},
|
|
343
343
|
};
|
|
344
344
|
default:
|
|
@@ -351,25 +351,25 @@ function mapPurchaseWidgetEvent(event) {
|
|
|
351
351
|
function mapTransferWidgetEvent(event) {
|
|
352
352
|
const { type, data } = event.detail;
|
|
353
353
|
switch (type) {
|
|
354
|
-
case
|
|
354
|
+
case To.SUCCESS:
|
|
355
355
|
return {
|
|
356
|
-
type:
|
|
356
|
+
type: mo.SUCCESS,
|
|
357
357
|
data: {
|
|
358
|
-
type:
|
|
358
|
+
type: go.TRANSFER_SUCCESS,
|
|
359
359
|
data,
|
|
360
360
|
},
|
|
361
361
|
};
|
|
362
|
-
case
|
|
362
|
+
case To.FAILURE:
|
|
363
363
|
return {
|
|
364
|
-
type:
|
|
364
|
+
type: mo.FAILURE,
|
|
365
365
|
data: {
|
|
366
|
-
type:
|
|
366
|
+
type: fo.TRANSFER_FAILED,
|
|
367
367
|
data,
|
|
368
368
|
},
|
|
369
369
|
};
|
|
370
|
-
case
|
|
370
|
+
case To.CLOSE_WIDGET:
|
|
371
371
|
return {
|
|
372
|
-
type:
|
|
372
|
+
type: mo.CLOSE,
|
|
373
373
|
data: {},
|
|
374
374
|
};
|
|
375
375
|
default:
|
|
@@ -380,30 +380,30 @@ function mapTransferWidgetEvent(event) {
|
|
|
380
380
|
* Map widget events to commerce widget event detail
|
|
381
381
|
*/
|
|
382
382
|
function getCommerceWidgetEvent(event) {
|
|
383
|
-
if (event.detail.type ===
|
|
383
|
+
if (event.detail.type === oo.PROVIDER_UPDATED) {
|
|
384
384
|
return {
|
|
385
|
-
type:
|
|
385
|
+
type: mo.PROVIDER_UPDATED,
|
|
386
386
|
data: event.detail.data,
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
switch (event.type) {
|
|
390
|
-
case
|
|
390
|
+
case ro.IMTBL_CONNECT_WIDGET_EVENT:
|
|
391
391
|
return mapConnectWidgetEvent(event);
|
|
392
|
-
case
|
|
392
|
+
case ro.IMTBL_WALLET_WIDGET_EVENT:
|
|
393
393
|
return mapWalletWidgetEvent(event);
|
|
394
|
-
case
|
|
394
|
+
case ro.IMTBL_SWAP_WIDGET_EVENT:
|
|
395
395
|
return mapSwapWidgetEvent(event);
|
|
396
|
-
case
|
|
396
|
+
case ro.IMTBL_ADD_TOKENS_WIDGET_EVENT:
|
|
397
397
|
return mapAddTokensWidgetEvent(event);
|
|
398
|
-
case
|
|
398
|
+
case ro.IMTBL_BRIDGE_WIDGET_EVENT:
|
|
399
399
|
return mapBridgeWidgetEvent(event);
|
|
400
|
-
case
|
|
400
|
+
case ro.IMTBL_ONRAMP_WIDGET_EVENT:
|
|
401
401
|
return mapOnrampWidgetEvent(event);
|
|
402
|
-
case
|
|
402
|
+
case ro.IMTBL_SALE_WIDGET_EVENT:
|
|
403
403
|
return mapSaleWidgetEvent(event);
|
|
404
|
-
case
|
|
404
|
+
case ro.IMTBL_PURCHASE_WIDGET_EVENT:
|
|
405
405
|
return mapPurchaseWidgetEvent(event);
|
|
406
|
-
case
|
|
406
|
+
case ro.IMTBL_TRANSFER_WIDGET_EVENT:
|
|
407
407
|
return mapTransferWidgetEvent(event);
|
|
408
408
|
default:
|
|
409
409
|
throw new Error(`Unknown widget event type "${event.type}"`);
|
|
@@ -415,20 +415,20 @@ function getCommerceWidgetEvent(event) {
|
|
|
415
415
|
*/
|
|
416
416
|
function getViewFromOrchestrationEventType(type) {
|
|
417
417
|
switch (type) {
|
|
418
|
-
case
|
|
419
|
-
return
|
|
420
|
-
case
|
|
421
|
-
return
|
|
422
|
-
case
|
|
423
|
-
return
|
|
424
|
-
case
|
|
425
|
-
return
|
|
426
|
-
case
|
|
427
|
-
return
|
|
428
|
-
case
|
|
429
|
-
return
|
|
430
|
-
case
|
|
431
|
-
return
|
|
418
|
+
case po.REQUEST_SWAP:
|
|
419
|
+
return Ao.SWAP;
|
|
420
|
+
case po.REQUEST_CONNECT:
|
|
421
|
+
return Ao.CONNECT;
|
|
422
|
+
case po.REQUEST_WALLET:
|
|
423
|
+
return Ao.WALLET;
|
|
424
|
+
case po.REQUEST_BRIDGE:
|
|
425
|
+
return Ao.BRIDGE;
|
|
426
|
+
case po.REQUEST_ONRAMP:
|
|
427
|
+
return Ao.ONRAMP;
|
|
428
|
+
case po.REQUEST_ADD_TOKENS:
|
|
429
|
+
return Ao.ADD_TOKENS;
|
|
430
|
+
case po.REQUEST_PURCHASE:
|
|
431
|
+
return Ao.PURCHASE;
|
|
432
432
|
default:
|
|
433
433
|
return null;
|
|
434
434
|
}
|
|
@@ -436,14 +436,14 @@ function getViewFromOrchestrationEventType(type) {
|
|
|
436
436
|
|
|
437
437
|
/** Orchestration Events List */
|
|
438
438
|
const orchestrationEvents = [
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
439
|
+
po.REQUEST_CONNECT,
|
|
440
|
+
po.REQUEST_WALLET,
|
|
441
|
+
po.REQUEST_SWAP,
|
|
442
|
+
po.REQUEST_BRIDGE,
|
|
443
|
+
po.REQUEST_ONRAMP,
|
|
444
|
+
po.REQUEST_ADD_TOKENS,
|
|
445
|
+
po.REQUEST_PURCHASE,
|
|
446
|
+
po.REQUEST_GO_BACK,
|
|
447
447
|
];
|
|
448
448
|
/**
|
|
449
449
|
* Check if event is orchestration event
|
|
@@ -454,15 +454,15 @@ function isOrchestrationEvent(event) {
|
|
|
454
454
|
|
|
455
455
|
/** Widget Events List */
|
|
456
456
|
const widgetEvents = [
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
457
|
+
ro.IMTBL_CONNECT_WIDGET_EVENT,
|
|
458
|
+
ro.IMTBL_WALLET_WIDGET_EVENT,
|
|
459
|
+
ro.IMTBL_SWAP_WIDGET_EVENT,
|
|
460
|
+
ro.IMTBL_BRIDGE_WIDGET_EVENT,
|
|
461
|
+
ro.IMTBL_ONRAMP_WIDGET_EVENT,
|
|
462
|
+
ro.IMTBL_SALE_WIDGET_EVENT,
|
|
463
|
+
ro.IMTBL_ADD_TOKENS_WIDGET_EVENT,
|
|
464
|
+
ro.IMTBL_PURCHASE_WIDGET_EVENT,
|
|
465
|
+
ro.IMTBL_TRANSFER_WIDGET_EVENT,
|
|
466
466
|
];
|
|
467
467
|
/**
|
|
468
468
|
* Subscribe and Handle widget events
|
|
@@ -474,7 +474,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
474
474
|
*/
|
|
475
475
|
const handleOrchestrationEvent = (event) => {
|
|
476
476
|
const { type, data } = event.detail;
|
|
477
|
-
if (type ===
|
|
477
|
+
if (type === po.REQUEST_GO_BACK) {
|
|
478
478
|
viewDispatch({
|
|
479
479
|
payload: {
|
|
480
480
|
type: ViewActions.UPDATE_VIEW,
|
|
@@ -483,7 +483,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
483
483
|
});
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
if (type ===
|
|
486
|
+
if (type === po.REQUEST_ONRAMP) {
|
|
487
487
|
const onRampEvent = data;
|
|
488
488
|
if (onRampEvent.provider) {
|
|
489
489
|
handleProviderUpdated(onRampEvent.provider);
|
|
@@ -517,7 +517,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
517
517
|
// ignore walletconnect provider updated event on CONNECT
|
|
518
518
|
// as that is not really consumed and the provider is available to the consumer on success event
|
|
519
519
|
// GFI-596
|
|
520
|
-
const isConnectProviderUpdatedEvent = customEvent.detail.type ===
|
|
520
|
+
const isConnectProviderUpdatedEvent = customEvent.detail.type === no.WALLETCONNECT_PROVIDER_UPDATED;
|
|
521
521
|
if (isConnectProviderUpdatedEvent) {
|
|
522
522
|
return;
|
|
523
523
|
}
|
|
@@ -541,7 +541,7 @@ function useWidgetEvents(eventTarget, viewState, handleProviderUpdated) {
|
|
|
541
541
|
function getConnectLoaderParams(view, flowConfig, checkout, browserProvider) {
|
|
542
542
|
const { type } = view;
|
|
543
543
|
switch (type) {
|
|
544
|
-
case
|
|
544
|
+
case Ao.WALLET:
|
|
545
545
|
return {
|
|
546
546
|
checkout,
|
|
547
547
|
browserProvider,
|
|
@@ -553,8 +553,8 @@ function getConnectLoaderParams(view, flowConfig, checkout, browserProvider) {
|
|
|
553
553
|
allowlistWalletRdns: flowConfig.CONNECT?.allowlistWalletRdns,
|
|
554
554
|
walletProviderName: undefined,
|
|
555
555
|
};
|
|
556
|
-
case
|
|
557
|
-
case
|
|
556
|
+
case Ao.ONRAMP:
|
|
557
|
+
case Ao.ADD_TOKENS:
|
|
558
558
|
return {
|
|
559
559
|
checkout,
|
|
560
560
|
browserProvider,
|
|
@@ -566,9 +566,9 @@ function getConnectLoaderParams(view, flowConfig, checkout, browserProvider) {
|
|
|
566
566
|
allowlistWalletRdns: flowConfig.CONNECT?.allowlistWalletRdns,
|
|
567
567
|
walletProviderName: undefined,
|
|
568
568
|
};
|
|
569
|
-
case
|
|
570
|
-
case
|
|
571
|
-
case
|
|
569
|
+
case Ao.SALE:
|
|
570
|
+
case Ao.SWAP:
|
|
571
|
+
case Ao.TRANSFER:
|
|
572
572
|
return {
|
|
573
573
|
checkout,
|
|
574
574
|
browserProvider,
|
|
@@ -650,7 +650,7 @@ const loadBalances = async (checkout, provider) => {
|
|
|
650
650
|
const result = await getAllowedBalances({
|
|
651
651
|
checkout,
|
|
652
652
|
provider,
|
|
653
|
-
allowTokenListType:
|
|
653
|
+
allowTokenListType: ie.ALL,
|
|
654
654
|
});
|
|
655
655
|
if (!result)
|
|
656
656
|
throw new Error('Failed to load balances');
|
|
@@ -780,7 +780,7 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
780
780
|
}, [token, t]);
|
|
781
781
|
const isButtonDisabled = reactExports.useMemo(() => !viewState.amount || !viewState.toAddress || !token, [viewState.amount, viewState.toAddress, token]);
|
|
782
782
|
return (jsx(SimpleLayout, { header: showHeader ? (jsx(HeaderNavigation, { title: title, onCloseButtonClick: () => sendCloseWidgetEvent(eventTarget), showBack: showBackButton, onBackButtonClick: () => {
|
|
783
|
-
orchestrationEvents$1.sendRequestGoBackEvent(eventTarget,
|
|
783
|
+
orchestrationEvents$1.sendRequestGoBackEvent(eventTarget, ro.IMTBL_TRANSFER_WIDGET_EVENT, {});
|
|
784
784
|
} })) : undefined, children: jsxs(Stack, { justifyContent: "space-between", sx: {
|
|
785
785
|
height: '100%',
|
|
786
786
|
mt: 'base.spacing.x6',
|
|
@@ -790,9 +790,9 @@ function TransferForm({ config, viewState, setViewState, onSend, showBackButton,
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
const sendSuccessEvent = (eventTarget, transactionHash) => {
|
|
793
|
-
const successEvent = new CustomEvent(
|
|
793
|
+
const successEvent = new CustomEvent(ro.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
794
794
|
detail: {
|
|
795
|
-
type:
|
|
795
|
+
type: To.SUCCESS,
|
|
796
796
|
data: {
|
|
797
797
|
transactionHash,
|
|
798
798
|
},
|
|
@@ -804,9 +804,9 @@ const sendSuccessEvent = (eventTarget, transactionHash) => {
|
|
|
804
804
|
eventTarget.dispatchEvent(successEvent);
|
|
805
805
|
};
|
|
806
806
|
const sendFailedEvent = (eventTarget, reason) => {
|
|
807
|
-
const failedEvent = new CustomEvent(
|
|
807
|
+
const failedEvent = new CustomEvent(ro.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
808
808
|
detail: {
|
|
809
|
-
type:
|
|
809
|
+
type: To.FAILURE,
|
|
810
810
|
data: {
|
|
811
811
|
reason,
|
|
812
812
|
timestamp: new Date().getTime(),
|
|
@@ -819,9 +819,9 @@ const sendFailedEvent = (eventTarget, reason) => {
|
|
|
819
819
|
eventTarget.dispatchEvent(failedEvent);
|
|
820
820
|
};
|
|
821
821
|
const sendRejectedEvent = (eventTarget, reason) => {
|
|
822
|
-
const rejectedEvent = new CustomEvent(
|
|
822
|
+
const rejectedEvent = new CustomEvent(ro.IMTBL_TRANSFER_WIDGET_EVENT, {
|
|
823
823
|
detail: {
|
|
824
|
-
type:
|
|
824
|
+
type: To.REJECTED,
|
|
825
825
|
data: {
|
|
826
826
|
reason,
|
|
827
827
|
timestamp: new Date().getTime(),
|
|
@@ -998,8 +998,8 @@ function CommerceWidget(props) {
|
|
|
998
998
|
const commerceReducerValues = reactExports.useMemo(() => ({ commerceState, commerceDispatch }), [commerceState, commerceDispatch]);
|
|
999
999
|
const { provider } = commerceState;
|
|
1000
1000
|
const connectLoaderParams = reactExports.useMemo(() => getConnectLoaderParams(view, flowConfig, checkout, provider || browserProvider), [view, flowConfig, checkout, provider, browserProvider]);
|
|
1001
|
-
const connectLoaderSuccessEvent = (flowParams.flow ===
|
|
1002
|
-
|| flowParams.flow ===
|
|
1001
|
+
const connectLoaderSuccessEvent = (flowParams.flow === Ao.ADD_TOKENS
|
|
1002
|
+
|| flowParams.flow === Ao.PURCHASE) ? () => { } : undefined;
|
|
1003
1003
|
const goToPreviousView = reactExports.useCallback(() => {
|
|
1004
1004
|
const sharedViews = [
|
|
1005
1005
|
SharedViews.LOADING_VIEW,
|
|
@@ -1097,28 +1097,28 @@ function CommerceWidget(props) {
|
|
|
1097
1097
|
const showBackButton = !!view.data?.showBackButton;
|
|
1098
1098
|
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: () => {
|
|
1099
1099
|
sendCheckoutEvent(eventTarget, {
|
|
1100
|
-
type:
|
|
1100
|
+
type: mo.CLOSE,
|
|
1101
1101
|
data: {},
|
|
1102
1102
|
});
|
|
1103
1103
|
}, onActionClick: () => {
|
|
1104
1104
|
// TODO: trigger a retry
|
|
1105
|
-
}, actionText: t('views.ERROR_VIEW.actionText') })), view.type ===
|
|
1105
|
+
}, actionText: t('views.ERROR_VIEW.actionText') })), view.type === Ao.CONNECT && (jsx(ConnectWidget, { config: widgetsConfig, checkout: checkout, sendCloseEventOverride: () => {
|
|
1106
1106
|
sendCheckoutEvent(eventTarget, {
|
|
1107
|
-
type:
|
|
1107
|
+
type: mo.CLOSE,
|
|
1108
1108
|
data: {},
|
|
1109
1109
|
});
|
|
1110
|
-
}, ...(view.data.params || {}) })), view.type ===
|
|
1110
|
+
}, ...(view.data.params || {}) })), view.type === Ao.BRIDGE && (jsx(BridgeWidget, { config: widgetsConfig, checkout: checkout, browserProvider: browserProvider, showBackButton: showBackButton, ...(view.data.params || {}) })), shouldWrapWithProvidersContext && view.type === Ao.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 === Ao.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: () => {
|
|
1111
1111
|
sendCheckoutEvent(eventTarget, {
|
|
1112
|
-
type:
|
|
1112
|
+
type: mo.CLOSE,
|
|
1113
1113
|
data: {},
|
|
1114
1114
|
});
|
|
1115
|
-
}, showBackButton: showBackButton, goBackEvent: goToPreviousView, children: jsxs(reactExports.Suspense, { fallback: jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: [view.type ===
|
|
1115
|
+
}, showBackButton: showBackButton, goBackEvent: goToPreviousView, children: jsxs(reactExports.Suspense, { fallback: jsx(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: [view.type === Ao.WALLET && (jsx(WalletWidget, { config: widgetsConfig, walletConfig: {
|
|
1116
1116
|
showNetworkMenu: true,
|
|
1117
1117
|
showDisconnectButton: true,
|
|
1118
1118
|
...view.data.config,
|
|
1119
|
-
}, ...(view.data.params || {}) })), view.type ===
|
|
1119
|
+
}, ...(view.data.params || {}) })), view.type === Ao.SALE && (jsx(SaleWidget, { config: widgetsConfig, ...(view.data.params || {}), hideExcludedPaymentTypes: false,
|
|
1120
1120
|
waitFulfillmentSettlements: true,
|
|
1121
|
-
...view.data.config })), view.type ===
|
|
1121
|
+
...view.data.config })), view.type === Ao.SWAP && (jsx(SwapWidget, { config: widgetsConfig, swapConfig: view.data.config, ...(view.data.params || {}), showBackButton: showBackButton })), view.type === Ao.ONRAMP && (jsx(OnRampWidget, { config: widgetsConfig, ...(view.data.params || {}), onrampConfig: view.data.config, showBackButton: showBackButton })), view.type === Ao.TRANSFER && (jsx(TransferWidget, { config: widgetsConfig, transferConfig: view.data.config, ...(view.data.params || {}), showBackButton: showBackButton }))] }) }))] }) }));
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
export { CommerceWidget as default };
|