@jetthai/cuora 1.1.364-dev-5 → 1.1.364-dev-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.
Files changed (38) hide show
  1. package/CHANGELOG.md +25 -15
  2. package/package.json +1 -1
  3. package/resetGitBranch.sh +49 -0
  4. package/src/api/activity.js +2 -2
  5. package/src/api/game.js +14 -1
  6. package/src/api/payment.js +5 -0
  7. package/src/api/ranking.js +4 -3
  8. package/src/machine/activity/activity.js +7 -6
  9. package/src/machine/activity/vip_card_activity.js +17 -9
  10. package/src/machine/bank_binding.js +44 -10
  11. package/src/machine/common.js +3 -1
  12. package/src/machine/deposit/direct.js +2 -6
  13. package/src/machine/deposit/float.js +2 -2
  14. package/src/machine/deposit/loadcard_vn.js +10 -51
  15. package/src/machine/deposit/manual_vn.js +3 -23
  16. package/src/machine/deposit/qrcode_v2.js +6 -132
  17. package/src/machine/deposit/virtual_bank_vn.js +3 -31
  18. package/src/machine/deposit/vpay.js +2 -2
  19. package/src/machine/game_betslip.js +46 -0
  20. package/src/machine/game_search_cash.js +10 -2
  21. package/src/machine/game_search_v2.js +10 -2
  22. package/src/machine/game_v2_1.js +81 -12
  23. package/src/machine/inbox.js +13 -1
  24. package/src/machine/index.js +2 -0
  25. package/src/machine/promotions.js +4 -5
  26. package/src/machine/ranking.js +38 -22
  27. package/src/machine/reward.js +57 -5
  28. package/src/machine/reward_cash.js +56 -15
  29. package/src/machine/setting.js +7 -0
  30. package/src/machine/withdraw/index.js +0 -12
  31. package/src/machine/withdraw/withdraw_manual.js +3 -97
  32. package/src/machine/withdraw/withdraw_manual_cash.js +1 -1
  33. package/src/machine/withdraw/withdraw_amb.js +0 -373
  34. package/src/machine/withdraw/withdraw_crypto.js +0 -495
  35. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  36. package/src/machine/withdraw/withdraw_fc.js +0 -251
  37. package/src/machine/withdraw/withdraw_vn.js +0 -548
  38. package/src/machine/withdraw/withdraw_vn2.js +0 -563
@@ -1,495 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import findLastIndex from 'lodash/findLastIndex.js'
3
- import payment from '../../api/payment.js'
4
- import common from '../../api/common.js'
5
- import user from '../../api/user.js'
6
- import api from '../../api/payment.js'
7
-
8
- export default function (request) {
9
- const { appSecret } = request.config
10
- return createMachine(
11
- {
12
- id: 'withdraw_crypto',
13
- initial: 'loading',
14
- context: {
15
- siteConfig: null,
16
- userInfo: null,
17
- balance: null,
18
-
19
- methods: [],
20
- paymentDetail: [],
21
-
22
- withdrawLimit: null,
23
- targetWithdrawLimit: null,
24
-
25
- maxWithdrawAmount: null,
26
- enableWithdraw: false,
27
- withdrawRules: [],
28
-
29
- attachmentType: null, // null | 'withdraw' | 'pool'
30
-
31
- networks: [],
32
- selectedNetwork: null,
33
- address: '',
34
- amount: null,
35
-
36
- charge: null,
37
- realAmount: null,
38
-
39
- // otp
40
- requestId: null,
41
- status: null,
42
- target: null,
43
- ttl: null,
44
- },
45
- states: {
46
- loading: {
47
- invoke: {
48
- src: 'fetchInitData',
49
- onDone: {
50
- target: 'mode',
51
- actions: ['setInitData', 'preset', 'updateWithdrawCondition'],
52
- },
53
- onError: {
54
- target: 'fail',
55
- },
56
- },
57
- },
58
- mode: {
59
- always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
60
- },
61
- free: {
62
- initial: 'checking',
63
- states: {
64
- checking: {
65
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
66
- },
67
- notConvertible: {
68
- on: {
69
- GIVE_UP: {
70
- target: 'givingUp',
71
- },
72
- },
73
- },
74
- givingUp: {
75
- invoke: {
76
- src: 'giveUp',
77
- onDone: {
78
- target: 'gaveUp',
79
- },
80
- onError: {
81
- target: 'convertible',
82
- },
83
- },
84
- },
85
- gaveUp: {},
86
- convertible: {
87
- on: {
88
- SUBMIT: {
89
- target: 'converting',
90
- actions: 'setAttachmentType',
91
- },
92
- },
93
- },
94
- converting: {
95
- invoke: {
96
- src: 'convertFreeCredit',
97
- onDone: [
98
- {
99
- target: '#withdraw_crypto.otp',
100
- actions: 'setOtp',
101
- cond: 'isOtpRequired',
102
- },
103
- {
104
- target: 'converted',
105
- },
106
- ],
107
- onError: {
108
- target: 'convertible',
109
- },
110
- },
111
- },
112
- converted: {
113
- always: [{ target: '#withdraw_crypto.cash.withdrawable', cond: 'hasAttachmentType' }],
114
- },
115
- },
116
- },
117
- cash: {
118
- initial: 'checking',
119
- states: {
120
- checking: {
121
- always: [
122
- { target: 'inProcessing', cond: 'haveProcessing' },
123
- { target: 'notWithdrawable', cond: 'isNotWithdrawable' },
124
- { target: 'withdrawable' },
125
- ],
126
- },
127
- notWithdrawable: {},
128
- inProcessing: {},
129
- withdrawable: {
130
- on: {
131
- SET_NETWORK: {
132
- actions: ['resetCharge', 'setNetwork'],
133
- },
134
- SET_ADDRESS: {
135
- actions: 'setAddress',
136
- },
137
- SET_AMOUNT: {
138
- actions: ['resetCharge', 'setAmount'],
139
- },
140
- CALCULATE: {
141
- target: 'calculating',
142
- cond: 'isCalculable',
143
- },
144
- PREVIEW: {
145
- target: 'submittable',
146
- cond: 'isSubmittable',
147
- },
148
- SET_ATTACHMENT_TYPE: {
149
- actions: 'setAttachmentType',
150
- cond: 'isNewWalletMode',
151
- },
152
- POOL: {
153
- target: 'pooling',
154
- cond: (context, event) => {
155
- const { amount, attachmentType } = context
156
- return attachmentType === 'pool' && amount > 0
157
- },
158
- },
159
- },
160
- },
161
- calculating: {
162
- entry: 'resetCharge',
163
- invoke: {
164
- src: 'fetchCalculation',
165
- onDone: {
166
- target: 'withdrawable',
167
- actions: 'setCalculatedResult',
168
- },
169
- onError: {
170
- target: 'withdrawable',
171
- },
172
- },
173
- },
174
- submittable: {
175
- on: {
176
- SUBMIT: [
177
- {
178
- target: 'pooling',
179
- cond: (context, event) => {
180
- const { amount, attachmentType } = context
181
- return attachmentType === 'pool' && amount > 0
182
- },
183
- },
184
- {
185
- target: 'submitting',
186
- },
187
- ],
188
- BACK: {
189
- target: 'withdrawable',
190
- },
191
- },
192
- },
193
- submitting: {
194
- invoke: {
195
- src: 'submitWithdraw',
196
- onDone: [
197
- {
198
- target: '#withdraw_crypto.otp',
199
- actions: 'setOtp',
200
- cond: 'isOtpRequired',
201
- },
202
- {
203
- target: 'submitted',
204
- },
205
- ],
206
- onError: {
207
- target: 'withdrawable',
208
- },
209
- },
210
- },
211
- submitted: {},
212
- pooling: {
213
- invoke: {
214
- src: 'pool',
215
- onDone: { target: 'pooled' },
216
- onError: {
217
- target: 'withdrawable',
218
- },
219
- },
220
- },
221
- pooled: {},
222
- },
223
- },
224
- otp: {
225
- type: 'parallel',
226
- states: {
227
- countdown: {
228
- after: {
229
- 1000: {
230
- target: 'countdown',
231
- actions: 'decreaseTtl',
232
- cond: (context) => context.ttl > 0,
233
- },
234
- },
235
- },
236
- verification: {
237
- initial: 'idle',
238
- states: {
239
- idle: {
240
- on: {
241
- ACKNOWLEDGE: {
242
- target: 'acknowledging',
243
- },
244
- RESET_OTP: {
245
- target: 'reset',
246
- },
247
- BACK: [
248
- {
249
- target: '#withdraw_crypto.free.convertible',
250
- cond: 'isFree',
251
- },
252
- {
253
- target: '#withdraw_crypto.cash.submittable',
254
- },
255
- ],
256
- },
257
- },
258
- acknowledging: {
259
- invoke: {
260
- src: 'acknowledge',
261
- onDone: [
262
- {
263
- target: '#withdraw_crypto.free.converted',
264
- cond: 'isFree',
265
- },
266
- {
267
- target: '#withdraw_crypto.cash.submitted',
268
- },
269
- ],
270
- onError: {
271
- target: 'idle',
272
- },
273
- },
274
- },
275
- reset: {
276
- invoke: {
277
- src: 'resetOtp',
278
- onDone: {
279
- target: 'idle',
280
- actions: 'setVerificationData',
281
- },
282
- onError: { target: 'idle' },
283
- },
284
- },
285
- },
286
- },
287
- },
288
- },
289
- fail: {},
290
- },
291
- on: {
292
- REFRESH: {
293
- target: 'loading',
294
- },
295
- },
296
- },
297
- {
298
- actions: {
299
- setInitData: assign((context, event) => {
300
- const method = event.data.paymentDetail?.[0]
301
- return {
302
- paymentDetail: event.data.paymentDetail,
303
- crypto: method,
304
- networks:
305
- method?.networkName?.map?.((value, i) => {
306
- return {
307
- label: method?.networkOptional?.[i],
308
- value,
309
- icon: value,
310
- }
311
- }) || [],
312
- }
313
- }),
314
- preset: assign((context, event) => {
315
- const { userInfo, siteConfig } = event.data
316
- const { withdraw_limit, target_withdraw_limit } = userInfo || {}
317
- const balance = parseFloat(userInfo?.balance)
318
- const methods = siteConfig?.paymentMethods?.withdraw || []
319
- return {
320
- withdrawLimit: Math.abs(withdraw_limit),
321
- targetWithdrawLimit: Math.abs(target_withdraw_limit),
322
- methods,
323
- balance,
324
- siteConfig,
325
- userInfo,
326
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
327
- }
328
- }),
329
- updateWithdrawCondition: assign((context, event) => {
330
- const { enableWithdraw, enableWithdrawAmount } = event.data?.withdrawRule
331
- const withdrawRules = event.data?.withdrawRule?.rules || []
332
- const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
333
- const { balance } = context
334
- const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
335
-
336
- let maxWithdrawAmount = 0
337
-
338
- if (lastMatchedIndex > -1) {
339
- rules[lastMatchedIndex].match = true
340
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
341
- } else if (rules.length > 0) {
342
- maxWithdrawAmount = rules[0].maxWithdrawAmount
343
- } else {
344
- maxWithdrawAmount = balance
345
- }
346
-
347
- return {
348
- maxWithdrawAmount,
349
- enableWithdrawAmount: +enableWithdrawAmount,
350
- enableWithdraw,
351
- withdrawRules,
352
- }
353
- }),
354
- setNetwork: assign((context, event) => {
355
- return {
356
- selectedNetwork: event.data,
357
- }
358
- }),
359
- setAddress: assign((context, event) => {
360
- return {
361
- address: event.data,
362
- }
363
- }),
364
- setAmount: assign((context, event) => {
365
- return {
366
- amount: event.data,
367
- }
368
- }),
369
- setCalculatedResult: assign((context, event) => {
370
- return {
371
- charge: event.data.charge,
372
- }
373
- }),
374
- resetCharge: assign((context, event) => {
375
- return {
376
- charge: null,
377
- }
378
- }),
379
- setOtp: assign((context, event) => {
380
- const { requestId, status, target, ttl } = event.data
381
- return {
382
- requestId,
383
- status,
384
- target,
385
- ttl,
386
- }
387
- }),
388
- decreaseTtl: assign((context, evnet) => {
389
- const second = context.ttl
390
- return {
391
- ttl: Math.max(second - 1, 0),
392
- }
393
- }),
394
- setVerificationData: assign((context, event) => {
395
- const { requestId, ttl, target } = event.data
396
- return {
397
- requestId,
398
- ttl,
399
- target,
400
- }
401
- }),
402
- setAttachmentType: assign((context, event) => {
403
- return {
404
- attachmentType: event.data,
405
- }
406
- }),
407
- },
408
- guards: {
409
- isFree: (context, event) => {
410
- return context.userInfo?.withdraw_rule !== 'DEFAULT'
411
- },
412
- hasAttachmentType: (context, event) => {
413
- return ['withdraw', 'pool'].includes(context.attachmentType)
414
- },
415
- haveProcessing: (context, event) => {
416
- return (context.paymentDetail?.[0]?.processing || []).length > 0
417
- },
418
- isSubmittable: (context, event) => {
419
- const { selectedNetwork, address, amount, charge } = context
420
- return selectedNetwork && address && amount && charge
421
- },
422
- isConvertible: (context, event) => {
423
- const { enableWithdraw } = context
424
- return enableWithdraw
425
- },
426
- isNotWithdrawable: (context, event) => {
427
- const { enableWithdraw } = context
428
- return !enableWithdraw
429
- },
430
- isCalculable: (context, event) => {
431
- const { selectedNetwork, amount } = context
432
- return selectedNetwork && amount
433
- },
434
- isOtpRequired: (context, event) => {
435
- return event.data?.status === 'otp-verifying'
436
- },
437
- isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
438
- },
439
- services: {
440
- fetchInitData: async (context, event) => {
441
- const [{ config }, userInfo, paymentDetail = [], withdrawRule] = await Promise.all([
442
- request.send(common.getConfig({ appSecret })),
443
- request.send(user.getUserInfo()),
444
- request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
445
- request.send(payment.getCurrentWithdrawRule()),
446
- ])
447
- const siteConfig = JSON.parse(window.atob(config))
448
- return { siteConfig, userInfo, paymentDetail, withdrawRule }
449
- },
450
- submitWithdraw: async (context, event) => {
451
- const { crypto, selectedNetwork, address, amount } = context
452
- return await request.send(
453
- api.submitWithdrawTransactionCrypto({
454
- method: crypto.method,
455
- amount,
456
- cryptoCurrency: crypto.channel,
457
- cryptoNetwork: selectedNetwork.value,
458
- targetAddress: address,
459
- })
460
- )
461
- },
462
- convertFreeCredit: async (context, event) => {
463
- return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
464
- },
465
- fetchCalculation: async (context, event) => {
466
- const { crypto, selectedNetwork, amount } = context
467
- const method = crypto.method
468
- return await request.send(
469
- api.getWithdrawExpectedResult({
470
- method,
471
- amount,
472
- cryptoNetwork: selectedNetwork.value,
473
- })
474
- )
475
- },
476
- resetOtp: async (context, event) => {
477
- const { requestId, target } = context
478
- return await request.send(user.otpReset({ requestId, target }))
479
- },
480
- acknowledge: async (context, event) => {
481
- const { requestId, target } = context
482
- const code = event.data
483
- return await request.send(user.otpAcknowledge({ requestId, target, code }))
484
- },
485
- pool: async (context, event) => {
486
- const { amount } = context
487
- return await request.send(payment.restore({ amount }))
488
- },
489
- giveUp: async (context, event) => {
490
- return await request.send(payment.giveUp())
491
- },
492
- },
493
- }
494
- )
495
- }