@jetthai/cuora 1.0.204 → 1.0.302-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 (110) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +1 -0
  3. package/CHANGELOG.md +848 -0
  4. package/README.md +6 -0
  5. package/package.json +6 -9
  6. package/src/api/activity.js +43 -2
  7. package/src/api/auth.js +22 -7
  8. package/src/api/common.js +3 -1
  9. package/src/api/game.js +20 -7
  10. package/src/api/mailbox.js +9 -5
  11. package/src/api/payment.js +167 -19
  12. package/src/api/user.js +7 -0
  13. package/src/lib/fingerprint.js +9779 -0
  14. package/src/machine/activity/activity.js +111 -26
  15. package/src/machine/activity/activity_cash.js +159 -0
  16. package/src/machine/activity/cash_rain_activity.js +153 -0
  17. package/src/machine/activity/continue_deposit_activity.js +11 -2
  18. package/src/machine/activity/deposit_activity.js +13 -4
  19. package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
  20. package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
  21. package/src/machine/activity/fafafa_activity.js +34 -19
  22. package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
  23. package/src/machine/activity/index.js +22 -4
  24. package/src/machine/activity/instant_rebate_activity.js +217 -0
  25. package/src/machine/activity/invite_friends_activity.js +14 -14
  26. package/src/machine/activity/jackpot.js +74 -0
  27. package/src/machine/activity/otp_verified_activity.js +74 -0
  28. package/src/machine/activity/ranking_activity.js +11 -2
  29. package/src/machine/activity/roulette_activity_v2.js +90 -0
  30. package/src/machine/activity/sign_in_activity.js +21 -14
  31. package/src/machine/activity/sign_in_monthly_activity.js +65 -0
  32. package/src/machine/activity/specify_bets_activity.js +25 -3
  33. package/src/machine/activity/specify_turnover_activity.js +25 -3
  34. package/src/machine/activity/time_bomb_activity.js +11 -2
  35. package/src/machine/activity/vip_card_activity.js +140 -0
  36. package/src/machine/auth.js +141 -27
  37. package/src/machine/auth_otp_v2.js +10 -4
  38. package/src/machine/auth_otp_v3.js +11 -3
  39. package/src/machine/bank_binding.js +112 -12
  40. package/src/machine/bank_binding_amb.js +145 -0
  41. package/src/machine/common.js +113 -25
  42. package/src/machine/deposit/amb.js +92 -0
  43. package/src/machine/deposit/crypto.js +50 -29
  44. package/src/machine/deposit/crypto_bank.js +317 -0
  45. package/src/machine/deposit/crypto_bank_cash.js +287 -0
  46. package/src/machine/deposit/crypto_button.js +174 -39
  47. package/src/machine/deposit/crypto_cash.js +255 -0
  48. package/src/machine/deposit/crypto_qrcode.js +148 -0
  49. package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  50. package/src/machine/deposit/crypto_way.js +239 -0
  51. package/src/machine/deposit/crypto_way_cash.js +256 -0
  52. package/src/machine/deposit/deposit_fc.js +8 -5
  53. package/src/machine/deposit/direct.js +111 -16
  54. package/src/machine/deposit/direct_cash.js +217 -0
  55. package/src/machine/deposit/float.js +366 -0
  56. package/src/machine/deposit/index.js +43 -2
  57. package/src/machine/deposit/krway.js +151 -0
  58. package/src/machine/deposit/loadcard_cash.js +207 -0
  59. package/src/machine/deposit/loadcard_vn.js +191 -43
  60. package/src/machine/deposit/manual_cash.js +356 -0
  61. package/src/machine/deposit/manual_vn.js +182 -60
  62. package/src/machine/deposit/qrcode_cash.js +217 -0
  63. package/src/machine/deposit/qrcode_v2.js +285 -52
  64. package/src/machine/deposit/usdt.js +144 -0
  65. package/src/machine/deposit/usdt_cash.js +138 -0
  66. package/src/machine/deposit/vpay.js +359 -0
  67. package/src/machine/game_favorite_v2.js +70 -28
  68. package/src/machine/game_info.js +57 -0
  69. package/src/machine/game_search_cash.js +390 -0
  70. package/src/machine/game_search_v2.js +64 -24
  71. package/src/machine/game_v2_1.js +662 -0
  72. package/src/machine/honor_board_cash.js +63 -0
  73. package/src/machine/inbox.js +259 -34
  74. package/src/machine/index.js +24 -17
  75. package/src/machine/leaderboard.js +31 -8
  76. package/src/machine/navbar.js +57 -0
  77. package/src/machine/promotions.js +171 -0
  78. package/src/machine/reward.js +74 -7
  79. package/src/machine/reward_cash.js +219 -0
  80. package/src/machine/roulette_v2.js +276 -0
  81. package/src/machine/setting.js +5 -2
  82. package/src/machine/side_cash.js +110 -0
  83. package/src/machine/side_v2.js +33 -28
  84. package/src/machine/user_photo.js +65 -0
  85. package/src/machine/user_sign_up.js +117 -17
  86. package/src/machine/withdraw/index.js +23 -0
  87. package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
  88. package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
  89. package/src/machine/withdraw/withdraw_crypto2.js +540 -0
  90. package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
  91. package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
  92. package/src/machine/withdraw/withdraw_krway.js +207 -0
  93. package/src/machine/withdraw/withdraw_manual.js +595 -0
  94. package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
  95. package/src/machine/withdraw/withdraw_vn.js +533 -0
  96. package/src/machine/withdraw/withdraw_vn2.js +548 -0
  97. package/src/request/request.js +10 -5
  98. package/src/util/constant.js +19 -1
  99. package/src/util/deviceToken.js +18 -8
  100. package/src/util/index.js +2 -1
  101. package/src/util/math.js +4 -0
  102. package/src/util/storage.js +22 -22
  103. package/dist/bundle.mjs +0 -18462
  104. package/rollup.config.js +0 -16
  105. package/src/machine/auth_otp.js +0 -201
  106. package/src/machine/deposit/qrcode_vn.js +0 -206
  107. package/src/machine/game.js +0 -285
  108. package/src/machine/game_favorite.js +0 -123
  109. package/src/machine/game_search.js +0 -244
  110. package/src/machine/game_v2.js +0 -356
@@ -0,0 +1,303 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+ import user from '../../api/user.js'
4
+
5
+ export default function (request, context) {
6
+ const { paymentDetail = [] } = context || {}
7
+ return createMachine(
8
+ {
9
+ id: 'withdraw_manual_cash',
10
+ initial: 'loading',
11
+ context: {
12
+ paymentDetail,
13
+ currentPayment: null,
14
+ banks: [],
15
+ paymentInfo: null,
16
+ withdrawRule: null,
17
+ userBanks: [],
18
+ selectedUserBank: null,
19
+ selectedAmount: null,
20
+ processing: null,
21
+
22
+ // otp
23
+ requestId: null,
24
+ status: null,
25
+ target: null,
26
+ ttl: null,
27
+ },
28
+ states: {
29
+ loading: {
30
+ invoke: {
31
+ src: 'fetchInitData',
32
+ onDone: {
33
+ target: 'checking',
34
+ actions: 'setInitData',
35
+ },
36
+ onError: {
37
+ target: 'loaded',
38
+ },
39
+ },
40
+ },
41
+ checking: {
42
+ always: [{ target: 'submitted', cond: 'isProcessing' }, { target: 'loaded' }],
43
+ },
44
+ loaded: {},
45
+ debouncing: {
46
+ always: [{ target: 'calculated', cond: 'isSubmittable' }, { target: 'loaded' }],
47
+ },
48
+ calculated: {
49
+ on: {
50
+ SUBMIT: {
51
+ target: 'submitting',
52
+ },
53
+ SUBMIT_CRYPTO: {
54
+ target: 'submitting_crypto',
55
+ },
56
+ },
57
+ },
58
+ submitting: {
59
+ invoke: {
60
+ src: 'submitWithdraw',
61
+ onDone: [
62
+ {
63
+ target: 'otp',
64
+ actions: 'setOtp',
65
+ cond: 'isOtpRequired',
66
+ },
67
+ {
68
+ target: 'submitted',
69
+ actions: 'setProcessing',
70
+ },
71
+ ],
72
+ onError: {
73
+ target: 'calculated',
74
+ },
75
+ },
76
+ },
77
+ submitting_crypto: {
78
+ invoke: {
79
+ src: 'submitWithdrawCrypto',
80
+ onDone: [
81
+ {
82
+ target: 'otp',
83
+ actions: 'setOtp',
84
+ cond: 'isOtpRequired',
85
+ },
86
+ {
87
+ target: 'submitted',
88
+ actions: 'setProcessing',
89
+ },
90
+ ],
91
+ onError: {
92
+ target: 'calculated',
93
+ },
94
+ },
95
+ },
96
+ submitted: {},
97
+ otp: {
98
+ type: 'parallel',
99
+ states: {
100
+ countdown: {
101
+ after: {
102
+ 1000: {
103
+ target: 'countdown',
104
+ actions: 'decreaseTtl',
105
+ cond: (context) => context.ttl > 0,
106
+ },
107
+ },
108
+ },
109
+ verification: {
110
+ initial: 'idle',
111
+ states: {
112
+ idle: {
113
+ on: {
114
+ ACKNOWLEDGE: {
115
+ target: 'acknowledging',
116
+ },
117
+ RESET_OTP: {
118
+ target: 'reset',
119
+ },
120
+ BACK: [
121
+ // {
122
+ // target: '#withdraw_vn2.activity.convertible',
123
+ // cond: 'isActivity',
124
+ // },
125
+ // {
126
+ // target: '#withdraw_vn2.cash.withdrawable',
127
+ // },
128
+ ],
129
+ },
130
+ },
131
+ acknowledging: {
132
+ invoke: {
133
+ src: 'acknowledge',
134
+ onDone: [
135
+ // {
136
+ // target: '#withdraw_vn2.activity.converted',
137
+ // cond: 'isActivity',
138
+ // },
139
+ // {
140
+ // target: '#withdraw_vn2.cash.submitted',
141
+ // },
142
+ ],
143
+ onError: {
144
+ target: 'idle',
145
+ },
146
+ },
147
+ },
148
+ reset: {
149
+ invoke: {
150
+ src: 'resetOtp',
151
+ onDone: {
152
+ target: 'idle',
153
+ actions: 'setVerificationData',
154
+ },
155
+ onError: { target: 'idle' },
156
+ },
157
+ },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ },
163
+ on: {
164
+ REFRESH: { target: 'loading', internal: false, cond: 'hasNoBank' },
165
+ SET_AMOUNT: {
166
+ target: 'debouncing',
167
+ actions: 'setAmount',
168
+ internal: false,
169
+ },
170
+ SELECT_USER_BANK: {
171
+ actions: 'setUserBank',
172
+ },
173
+ },
174
+ },
175
+ {
176
+ actions: {
177
+ setInitData: assign((context, event) => {
178
+ const { currentPayment, paymentInfo, withdrawRule, processing } = event.data
179
+ const userBanks = [...paymentInfo.bankList, ...paymentInfo.cryptoList, ...paymentInfo.ewalletList]
180
+
181
+ return {
182
+ currentPayment,
183
+ processing,
184
+ paymentInfo,
185
+ withdrawRule,
186
+ userBanks,
187
+ selectedUserBank: userBanks[0],
188
+ }
189
+ }),
190
+ setAmount: assign((context, event) => {
191
+ return {
192
+ selectedAmount: event.data,
193
+ }
194
+ }),
195
+ setUserBank: assign((context, event) => {
196
+ return {
197
+ selectedUserBank: event.data,
198
+ }
199
+ }),
200
+ setProcessing: assign((context, event) => {
201
+ return {
202
+ processing: event.data,
203
+ }
204
+ }),
205
+ setOtp: assign((context, event) => {
206
+ const { requestId, status, target, ttl } = event.data
207
+ return {
208
+ requestId,
209
+ status,
210
+ target,
211
+ ttl,
212
+ }
213
+ }),
214
+ decreaseTtl: assign((context, evnet) => {
215
+ const second = context.ttl
216
+ return {
217
+ ttl: Math.max(second - 1, 0),
218
+ }
219
+ }),
220
+ setVerificationData: assign((context, event) => {
221
+ const { requestId, ttl, target } = event.data
222
+ return {
223
+ requestId,
224
+ ttl,
225
+ target,
226
+ }
227
+ }),
228
+ },
229
+ guards: {
230
+ hasNoBank: (context, event) => {
231
+ return !context.userBanks.length
232
+ },
233
+ isProcessing: (context, event) => {
234
+ return context.processing
235
+ },
236
+ isSubmittable: (context, event) => {
237
+ const { currentPayment, selectedUserBank, selectedAmount } = context
238
+ return selectedUserBank && selectedAmount > 0 && currentPayment.minimum <= selectedAmount && selectedAmount <= currentPayment.maximum
239
+ },
240
+ isOtpRequired: (context, event) => {
241
+ return event.data?.status === 'otp-verifying'
242
+ },
243
+ },
244
+ services: {
245
+ fetchInitData: async (context, event) => {
246
+ const { paymentDetail = [] } = context
247
+ const currentPayment = paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
248
+
249
+ const [paymentInfo, withdrawRule, orders] = await Promise.all([
250
+ request.send(payment.getBindingPaymentInfo()),
251
+ request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
252
+ request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
253
+ ])
254
+
255
+ return {
256
+ currentPayment,
257
+ paymentInfo,
258
+ withdrawRule,
259
+ processing: orders[0],
260
+ }
261
+ },
262
+ submitWithdraw: async (context, event) => {
263
+ const { currentPayment, selectedUserBank, selectedAmount } = context
264
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(selectedUserBank.bankCode) ? '' : selectedUserBank.branch
265
+ return await request.send(
266
+ payment.submitWithdrawTransactionVN({
267
+ method: currentPayment.method,
268
+ amount: selectedAmount,
269
+ applyerBankCode: selectedUserBank.bankCode,
270
+ applyerAccountNumber: selectedUserBank.accountNumber,
271
+ applyerIfscCode: selectedUserBank.ifscCode,
272
+ branch: branchTemp,
273
+ applyerHolderName: selectedUserBank.holderName,
274
+ })
275
+ )
276
+ },
277
+ submitWithdrawCrypto: async (context, event) => {
278
+ const { currentPayment, selectedUserBank, selectedAmount } = context
279
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(selectedUserBank.bankCode) ? '' : selectedUserBank.branch
280
+ return await request.send(
281
+ payment.submitWithdrawTransactionCrypto({
282
+ method: currentPayment.method,
283
+ amount: selectedAmount,
284
+ cryptoCurrency: selectedUserBank.cryptoCurrency,
285
+ cryptoNetwork: selectedUserBank.cryptoNetwork,
286
+ targetAddress: selectedUserBank.cryptoAddress,
287
+ applyerHolderName: selectedUserBank.holderName,
288
+ })
289
+ )
290
+ },
291
+ resetOtp: async (context, event) => {
292
+ const { requestId, target } = context
293
+ return await request.send(user.otpReset({ requestId, target }))
294
+ },
295
+ acknowledge: async (context, event) => {
296
+ const { requestId, target } = context
297
+ const code = event.data
298
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
299
+ },
300
+ },
301
+ }
302
+ )
303
+ }