@jetthai/cuora 1.0.307-dev-2 → 1.1.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 (111) hide show
  1. package/CHANGELOG.md +4 -853
  2. package/README.md +0 -6
  3. package/dist/bundle.mjs +18461 -0
  4. package/package.json +9 -6
  5. package/rollup.config.js +16 -0
  6. package/src/api/activity.js +2 -43
  7. package/src/api/auth.js +7 -22
  8. package/src/api/common.js +1 -3
  9. package/src/api/game.js +7 -20
  10. package/src/api/mailbox.js +5 -9
  11. package/src/api/payment.js +19 -167
  12. package/src/api/user.js +0 -7
  13. package/src/machine/activity/activity.js +26 -111
  14. package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
  15. package/src/machine/activity/continue_deposit_activity.js +2 -11
  16. package/src/machine/activity/deposit_activity.js +4 -13
  17. package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
  18. package/src/machine/activity/fafafa_activity.js +19 -34
  19. package/src/machine/activity/index.js +4 -22
  20. package/src/machine/activity/invite_friends_activity.js +14 -14
  21. package/src/machine/activity/ranking_activity.js +2 -11
  22. package/src/machine/activity/sign_in_activity.js +14 -21
  23. package/src/machine/activity/specify_bets_activity.js +3 -25
  24. package/src/machine/activity/specify_turnover_activity.js +3 -25
  25. package/src/machine/activity/time_bomb_activity.js +2 -11
  26. package/src/machine/auth.js +25 -141
  27. package/src/machine/auth_otp.js +201 -0
  28. package/src/machine/auth_otp_v2.js +4 -10
  29. package/src/machine/auth_otp_v3.js +3 -11
  30. package/src/machine/bank_binding.js +12 -112
  31. package/src/machine/common.js +30 -110
  32. package/src/machine/deposit/crypto.js +29 -50
  33. package/src/machine/deposit/crypto_button.js +39 -174
  34. package/src/machine/deposit/deposit_fc.js +5 -8
  35. package/src/machine/deposit/direct.js +16 -111
  36. package/src/machine/deposit/index.js +2 -43
  37. package/src/machine/deposit/loadcard_vn.js +43 -191
  38. package/src/machine/deposit/manual_vn.js +60 -182
  39. package/src/machine/deposit/qrcode_v2.js +52 -285
  40. package/src/machine/deposit/qrcode_vn.js +206 -0
  41. package/src/machine/game.js +285 -0
  42. package/src/machine/game_favorite.js +123 -0
  43. package/src/machine/game_favorite_v2.js +28 -74
  44. package/src/machine/game_search.js +244 -0
  45. package/src/machine/game_search_v2.js +24 -64
  46. package/src/machine/game_v2.js +356 -0
  47. package/src/machine/inbox.js +34 -259
  48. package/src/machine/index.js +17 -26
  49. package/src/machine/leaderboard.js +8 -31
  50. package/src/machine/reward.js +7 -74
  51. package/src/machine/setting.js +2 -5
  52. package/src/machine/side_v2.js +28 -33
  53. package/src/machine/user_sign_up.js +21 -112
  54. package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
  55. package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
  56. package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
  57. package/src/request/request.js +5 -10
  58. package/src/util/constant.js +1 -19
  59. package/src/util/deviceToken.js +8 -18
  60. package/src/util/index.js +1 -2
  61. package/src/util/storage.js +22 -22
  62. package/.husky/pre-commit +0 -4
  63. package/.prettierignore +0 -1
  64. package/src/lib/fingerprint.js +0 -9779
  65. package/src/machine/activity/activity_cash.js +0 -159
  66. package/src/machine/activity/cash_rain_activity.js +0 -153
  67. package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
  68. package/src/machine/activity/instant_rebate_activity.js +0 -195
  69. package/src/machine/activity/jackpot.js +0 -74
  70. package/src/machine/activity/otp_verified_activity.js +0 -74
  71. package/src/machine/activity/roulette_activity_v2.js +0 -90
  72. package/src/machine/activity/sign_in_monthly_activity.js +0 -65
  73. package/src/machine/activity/vip_card_activity.js +0 -140
  74. package/src/machine/bank_binding_amb.js +0 -145
  75. package/src/machine/deposit/amb.js +0 -92
  76. package/src/machine/deposit/crypto_bank.js +0 -317
  77. package/src/machine/deposit/crypto_bank_cash.js +0 -287
  78. package/src/machine/deposit/crypto_cash.js +0 -255
  79. package/src/machine/deposit/crypto_qrcode.js +0 -148
  80. package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
  81. package/src/machine/deposit/crypto_way.js +0 -239
  82. package/src/machine/deposit/crypto_way_cash.js +0 -256
  83. package/src/machine/deposit/direct_cash.js +0 -217
  84. package/src/machine/deposit/float.js +0 -366
  85. package/src/machine/deposit/krway.js +0 -151
  86. package/src/machine/deposit/loadcard_cash.js +0 -207
  87. package/src/machine/deposit/manual_cash.js +0 -356
  88. package/src/machine/deposit/qrcode_cash.js +0 -217
  89. package/src/machine/deposit/usdt.js +0 -144
  90. package/src/machine/deposit/usdt_cash.js +0 -138
  91. package/src/machine/deposit/vpay.js +0 -359
  92. package/src/machine/game_info.js +0 -57
  93. package/src/machine/game_search_cash.js +0 -390
  94. package/src/machine/game_v2_1.js +0 -662
  95. package/src/machine/honor_board.js +0 -118
  96. package/src/machine/honor_board_cash.js +0 -89
  97. package/src/machine/navbar.js +0 -57
  98. package/src/machine/promotions.js +0 -171
  99. package/src/machine/reward_cash.js +0 -219
  100. package/src/machine/roulette_v2.js +0 -276
  101. package/src/machine/side_cash.js +0 -110
  102. package/src/machine/user_photo.js +0 -65
  103. package/src/machine/withdraw/index.js +0 -23
  104. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  105. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
  106. package/src/machine/withdraw/withdraw_krway.js +0 -220
  107. package/src/machine/withdraw/withdraw_manual.js +0 -610
  108. package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
  109. package/src/machine/withdraw/withdraw_vn.js +0 -546
  110. package/src/machine/withdraw/withdraw_vn2.js +0 -561
  111. package/src/util/math.js +0 -4
@@ -1,540 +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_crypto2',
13
- initial: 'loading',
14
- context: {
15
- mode: null,
16
- siteConfig: null,
17
- balance: null,
18
-
19
- methods: [],
20
- paymentDetail: [],
21
-
22
- currentWithdrawLimit: null,
23
- targetWithdrawLimit: null,
24
-
25
- maxWithdrawAmount: null,
26
- availableWithdrawAmount: null,
27
- enableWithdraw: false,
28
- enableWithdrawAmount: 0,
29
- withdrawRules: [],
30
- withdrawRule: {},
31
- attachmentType: null, // null | 'withdraw' | 'pool'
32
- networks: [],
33
- selectedNetwork: null,
34
- address: '',
35
- amount: null,
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: 'pending',
51
- actions: ['setInitData', 'preset'],
52
- },
53
- onError: {
54
- target: 'fail',
55
- },
56
- },
57
- },
58
- pending: {
59
- on: {
60
- SET_MODE: {
61
- target: 'fetching',
62
- actions: 'setMode',
63
- },
64
- },
65
- },
66
- fetching: {
67
- invoke: {
68
- src: 'fetchWithdrawRules',
69
- onDone: {
70
- target: 'mode',
71
- actions: 'updateWithdrawCondition',
72
- },
73
- onError: {
74
- target: '#withdraw_crypto2.fail',
75
- },
76
- },
77
- },
78
- mode: {
79
- always: [{ target: 'activity', cond: 'isActivity' }, { target: 'cash' }],
80
- },
81
- activity: {
82
- initial: 'checking',
83
- states: {
84
- checking: {
85
- always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
86
- },
87
- notConvertible: {
88
- on: {
89
- GIVE_UP: {
90
- target: 'fetchWithdrawRule',
91
- },
92
- },
93
- },
94
- fetchWithdrawRule: {
95
- invoke: {
96
- src: 'fetchWithdrawRulePreview',
97
- onDone: {
98
- target: 'giveUp',
99
- actions: 'setWithdrawRulePreview',
100
- },
101
- onError: {
102
- target: 'notConvertible',
103
- },
104
- },
105
- },
106
- giveUp: {
107
- on: {
108
- CONFIRM: {
109
- target: 'givingUp',
110
- },
111
- BACK: {
112
- target: 'notConvertible',
113
- },
114
- },
115
- },
116
- givingUp: {
117
- invoke: {
118
- src: 'giveUp',
119
- onDone: {
120
- target: 'gaveUp',
121
- },
122
- onError: {
123
- target: '#withdraw_crypto2.fail',
124
- },
125
- },
126
- },
127
- gaveUp: {},
128
- convertible: {
129
- on: {
130
- SUBMIT: {
131
- target: 'converting',
132
- actions: 'setAttachmentType',
133
- },
134
- },
135
- },
136
- converting: {
137
- invoke: {
138
- src: 'convertFreeCredit',
139
- onDone: [
140
- {
141
- target: '#withdraw_crypto2.otp',
142
- actions: 'setOtp',
143
- cond: 'isOtpRequired',
144
- },
145
- { target: 'converted' },
146
- ],
147
- onError: {
148
- target: 'convertible',
149
- },
150
- },
151
- },
152
- converted: {
153
- always: [{ target: '#withdraw_crypto2.cash.withdrawable', cond: 'hasAttachmentType' }],
154
- },
155
- },
156
- },
157
- cash: {
158
- initial: 'checking',
159
- states: {
160
- checking: {
161
- always: [
162
- { target: 'inProcessing', cond: 'haveProcessing' },
163
- { target: 'notWithdrawable', cond: 'isNotWithdrawable' },
164
- { target: 'withdrawable' },
165
- ],
166
- },
167
- notWithdrawable: {},
168
- inProcessing: {},
169
- withdrawable: {
170
- on: {
171
- SET_NETWORK: {
172
- actions: ['resetCharge', 'setNetwork'],
173
- },
174
- SET_ADDRESS: {
175
- actions: 'setAddress',
176
- },
177
- SET_AMOUNT: {
178
- actions: ['resetCharge', 'setAmount'],
179
- },
180
- CALCULATE: {
181
- target: 'calculating',
182
- cond: 'isCalculable',
183
- },
184
- PREVIEW: {
185
- target: 'submittable',
186
- cond: 'isSubmittable',
187
- },
188
- SET_ATTACHMENT_TYPE: {
189
- actions: 'setAttachmentType',
190
- },
191
- POOL: {
192
- target: 'pooling',
193
- cond: (context, event) => {
194
- const { amount, attachmentType } = context
195
- return attachmentType === 'pool' && amount > 0
196
- },
197
- },
198
- },
199
- },
200
- calculating: {
201
- entry: 'resetCharge',
202
- invoke: {
203
- src: 'fetchCalculation',
204
- onDone: {
205
- target: 'withdrawable',
206
- actions: 'setCalculatedResult',
207
- },
208
- onError: {
209
- target: 'withdrawable',
210
- },
211
- },
212
- },
213
- submittable: {
214
- on: {
215
- SUBMIT: [
216
- {
217
- target: 'pooling',
218
- cond: (context, event) => {
219
- const { amount, attachmentType } = context
220
- return attachmentType === 'pool' && amount > 0
221
- },
222
- },
223
- {
224
- target: 'submitting',
225
- },
226
- ],
227
- BACK: {
228
- target: 'withdrawable',
229
- },
230
- },
231
- },
232
- submitting: {
233
- invoke: {
234
- src: 'submitWithdraw',
235
- onDone: [
236
- {
237
- target: '#withdraw_crypto2.otp',
238
- actions: 'setOtp',
239
- cond: 'isOtpRequired',
240
- },
241
- {
242
- target: 'submitted',
243
- },
244
- ],
245
- onError: {
246
- target: 'withdrawable',
247
- },
248
- },
249
- },
250
- submitted: {},
251
- pooling: {
252
- invoke: {
253
- src: 'pool',
254
- onDone: { target: 'pooled' },
255
- onError: {
256
- target: 'withdrawable',
257
- },
258
- },
259
- },
260
- pooled: {},
261
- },
262
- },
263
- otp: {
264
- type: 'parallel',
265
- states: {
266
- countdown: {
267
- after: {
268
- 1000: {
269
- target: 'countdown',
270
- actions: 'decreaseTtl',
271
- cond: (context) => context.ttl > 0,
272
- },
273
- },
274
- },
275
- verification: {
276
- initial: 'idle',
277
- states: {
278
- idle: {
279
- on: {
280
- ACKNOWLEDGE: {
281
- target: 'acknowledging',
282
- },
283
- RESET_OTP: {
284
- target: 'reset',
285
- },
286
- BACK: [
287
- {
288
- target: '#withdraw_crypto2.activity.convertible',
289
- cond: 'isFree',
290
- },
291
- {
292
- target: '#withdraw_crypto2.cash.submittable',
293
- },
294
- ],
295
- },
296
- },
297
- acknowledging: {
298
- invoke: {
299
- src: 'acknowledge',
300
- onDone: [
301
- {
302
- target: '#withdraw_crypto2.activity.converted',
303
- cond: 'isFree',
304
- },
305
- {
306
- target: '#withdraw_crypto2.cash.submitted',
307
- },
308
- ],
309
- onError: {
310
- target: 'idle',
311
- },
312
- },
313
- },
314
- reset: {
315
- invoke: {
316
- src: 'resetOtp',
317
- onDone: {
318
- target: 'idle',
319
- actions: 'setVerificationData',
320
- },
321
- onError: { target: 'idle' },
322
- },
323
- },
324
- },
325
- },
326
- },
327
- },
328
- fail: {},
329
- },
330
- on: {
331
- REFRESH: {
332
- target: 'loading',
333
- },
334
- },
335
- },
336
- {
337
- actions: {
338
- setInitData: assign((context, event) => {
339
- const method = event.data.paymentDetail?.[0]
340
- return {
341
- paymentDetail: event.data.paymentDetail,
342
- crypto: method,
343
- networks:
344
- method?.networkName?.map?.((value, i) => {
345
- return {
346
- label: method?.networkOptional?.[i],
347
- value,
348
- icon: value,
349
- }
350
- }) || [],
351
- }
352
- }),
353
- preset: assign((context, event) => {
354
- const { siteConfig } = context
355
- const methods = siteConfig?.paymentMethods?.withdraw || []
356
- return {
357
- methods,
358
- attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
359
- }
360
- }),
361
- setMode: assign((context, event) => {
362
- return {
363
- mode: event.data,
364
- }
365
- }),
366
- updateWithdrawCondition: assign((context, event) => {
367
- const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
368
- const withdrawRules = event.data?.rules || []
369
- const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
370
- const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
371
-
372
- let maxWithdrawAmount = 0
373
-
374
- if (lastMatchedIndex > -1) {
375
- rules[lastMatchedIndex].match = true
376
- maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
377
- } else if (rules.length > 0) {
378
- maxWithdrawAmount = rules[0].maxWithdrawAmount
379
- } else {
380
- maxWithdrawAmount = balance
381
- }
382
-
383
- return {
384
- balance,
385
- currentWithdrawLimit,
386
- targetWithdrawLimit,
387
- maxWithdrawAmount,
388
- enableWithdrawAmount: +enableWithdrawAmount,
389
- enableWithdraw,
390
- withdrawRules,
391
- }
392
- }),
393
- setWithdrawRulePreview: assign((context, event) => {
394
- return {
395
- withdrawRule: event.data,
396
- }
397
- }),
398
- setNetwork: assign((context, event) => {
399
- return {
400
- selectedNetwork: event.data,
401
- }
402
- }),
403
- setAddress: assign((context, event) => {
404
- return {
405
- address: event.data,
406
- }
407
- }),
408
- setAmount: assign((context, event) => {
409
- return {
410
- amount: event.data,
411
- }
412
- }),
413
- setCalculatedResult: assign((context, event) => {
414
- return {
415
- charge: event.data.charge,
416
- }
417
- }),
418
- resetCharge: assign((context, event) => {
419
- return {
420
- charge: null,
421
- }
422
- }),
423
- setOtp: assign((context, event) => {
424
- const { requestId, status, target, ttl } = event.data
425
- return {
426
- requestId,
427
- status,
428
- target,
429
- ttl,
430
- }
431
- }),
432
- decreaseTtl: assign((context, evnet) => {
433
- const second = context.ttl
434
- return {
435
- ttl: Math.max(second - 1, 0),
436
- }
437
- }),
438
- setVerificationData: assign((context, event) => {
439
- const { requestId, ttl, target } = event.data
440
- return {
441
- requestId,
442
- ttl,
443
- target,
444
- }
445
- }),
446
- setAttachmentType: assign((context, event) => {
447
- return {
448
- attachmentType: event.data,
449
- }
450
- }),
451
- },
452
- guards: {
453
- isActivity: (context, event) => {
454
- return context.mode === 'ACTIVITY'
455
- },
456
- hasAttachmentType: (context, event) => {
457
- return ['withdraw', 'pool'].includes(context.attachmentType)
458
- },
459
- haveProcessing: (context, event) => {
460
- return (context.paymentDetail?.[0]?.processing || []).length > 0
461
- },
462
- isSubmittable: (context, event) => {
463
- const { selectedNetwork, address, amount, charge } = context
464
- return selectedNetwork && address && amount && charge
465
- },
466
- isConvertible: (context, event) => {
467
- const { enableWithdraw } = context
468
- return enableWithdraw
469
- },
470
- isNotWithdrawable: (context, event) => {
471
- const { enableWithdraw } = context
472
- return !enableWithdraw
473
- },
474
- isCalculable: (context, event) => {
475
- const { selectedNetwork, amount } = context
476
- return selectedNetwork && amount
477
- },
478
- isOtpRequired: (context, event) => {
479
- return event.data?.status === 'otp-verifying'
480
- },
481
- },
482
- services: {
483
- fetchInitData: async (context, event) => {
484
- const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
485
- return { paymentDetail }
486
- },
487
- fetchWithdrawRules: async (context, event) => {
488
- const { mode } = context
489
- return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
490
- },
491
- fetchWithdrawRulePreview: async (context, event) => {
492
- const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
493
- return data
494
- },
495
- submitWithdraw: async (context, event) => {
496
- const { crypto, selectedNetwork, address, amount } = context
497
- return await request.send(
498
- api.submitWithdrawTransactionCrypto({
499
- method: crypto.method,
500
- amount,
501
- cryptoCurrency: crypto.channel,
502
- cryptoNetwork: selectedNetwork.value,
503
- targetAddress: address,
504
- })
505
- )
506
- },
507
- convertFreeCredit: async (context, event) => {
508
- return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
509
- },
510
- fetchCalculation: async (context, event) => {
511
- const { crypto, selectedNetwork, amount } = context
512
- const method = crypto.method
513
- return await request.send(
514
- api.getWithdrawExpectedResult({
515
- method,
516
- amount,
517
- cryptoNetwork: selectedNetwork.value,
518
- })
519
- )
520
- },
521
- resetOtp: async (context, event) => {
522
- const { requestId, target } = context
523
- return await request.send(user.otpReset({ requestId, target }))
524
- },
525
- acknowledge: async (context, event) => {
526
- const { requestId, target } = context
527
- const code = event.data
528
- return await request.send(user.otpAcknowledge({ requestId, target, code }))
529
- },
530
- pool: async (context, event) => {
531
- const { amount } = context
532
- return await request.send(payment.restore({ amount }))
533
- },
534
- giveUp: async (context, event) => {
535
- return await request.send(payment.giveUp())
536
- },
537
- },
538
- }
539
- )
540
- }