@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,319 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+ import user from '../../api/user.js'
4
+ import api from '../../api/payment.js'
5
+
6
+ export default function (request, context) {
7
+ const { paymentDetail = [] } = context || {}
8
+ return createMachine(
9
+ {
10
+ id: 'withdraw_crypto_cash',
11
+ initial: 'loading',
12
+ context: {
13
+ paymentDetail,
14
+ withdrawRule: null,
15
+ selectedCrypto: null,
16
+ networks: [],
17
+ selectedNetwork: null,
18
+ address: '',
19
+ selectedAmount: null,
20
+ calculation: null,
21
+ processing: null,
22
+
23
+ // otp
24
+ requestId: null,
25
+ status: null,
26
+ target: null,
27
+ ttl: null,
28
+ },
29
+ states: {
30
+ loading: {
31
+ invoke: {
32
+ src: 'fetchInitData',
33
+ onDone: {
34
+ target: 'checking',
35
+ actions: 'setInitData',
36
+ },
37
+ onError: {
38
+ target: 'loaded',
39
+ },
40
+ },
41
+ },
42
+ checking: {
43
+ always: [{ target: 'submitted', cond: 'isProcessing' }, { target: 'loaded' }],
44
+ },
45
+ loaded: {},
46
+ debouncing: {
47
+ after: {
48
+ 1000: [
49
+ {
50
+ target: 'calculating',
51
+ cond: 'isCalculable',
52
+ },
53
+ { target: 'loaded' },
54
+ ],
55
+ },
56
+ },
57
+ calculating: {
58
+ entry: 'resetCharge',
59
+ invoke: {
60
+ src: 'fetchCalculation',
61
+ onDone: {
62
+ target: 'calculated',
63
+ actions: 'setCalculation',
64
+ },
65
+ onError: {
66
+ target: 'calculated',
67
+ },
68
+ },
69
+ },
70
+ calculated: {
71
+ on: {
72
+ SUBMIT: [
73
+ {
74
+ target: 'submitting',
75
+ },
76
+ ],
77
+ },
78
+ },
79
+ submitting: {
80
+ invoke: {
81
+ src: 'submitWithdraw',
82
+ onDone: [
83
+ {
84
+ target: 'otp',
85
+ actions: 'setOtp',
86
+ cond: 'isOtpRequired',
87
+ },
88
+ {
89
+ target: 'submitted',
90
+ actions: 'setProcessing',
91
+ },
92
+ ],
93
+ onError: {
94
+ target: 'loaded',
95
+ },
96
+ },
97
+ },
98
+ submitted: {},
99
+ otp: {
100
+ type: 'parallel',
101
+ states: {
102
+ countdown: {
103
+ after: {
104
+ 1000: {
105
+ target: 'countdown',
106
+ actions: 'decreaseTtl',
107
+ cond: (context) => context.ttl > 0,
108
+ },
109
+ },
110
+ },
111
+ verification: {
112
+ initial: 'idle',
113
+ states: {
114
+ idle: {
115
+ on: {
116
+ ACKNOWLEDGE: {
117
+ target: 'acknowledging',
118
+ },
119
+ RESET_OTP: {
120
+ target: 'reset',
121
+ },
122
+ },
123
+ },
124
+ acknowledging: {
125
+ invoke: {
126
+ src: 'acknowledge',
127
+ onDone: [
128
+ {
129
+ target: '#withdraw_crypto_cash.submitted',
130
+ },
131
+ ],
132
+ onError: {
133
+ target: 'idle',
134
+ },
135
+ },
136
+ },
137
+ reset: {
138
+ invoke: {
139
+ src: 'resetOtp',
140
+ onDone: {
141
+ target: 'idle',
142
+ actions: 'setVerificationData',
143
+ },
144
+ onError: { target: 'idle' },
145
+ },
146
+ },
147
+ },
148
+ },
149
+ },
150
+ },
151
+ },
152
+ on: {
153
+ SET_NETWORK: {
154
+ target: 'debouncing',
155
+ actions: 'setNetwork',
156
+ internal: false,
157
+ },
158
+ SET_ADDRESS: {
159
+ actions: 'setAddress',
160
+ internal: false,
161
+ },
162
+ SET_AMOUNT: {
163
+ target: 'debouncing',
164
+ actions: 'setAmount',
165
+ internal: false,
166
+ },
167
+ },
168
+ },
169
+ {
170
+ actions: {
171
+ setInitData: assign((context, event) => {
172
+ const { withdrawRule, processing } = event.data
173
+ const { paymentDetail } = context
174
+ const selectedCrypto = paymentDetail.find((item) => item.transferType === 'withdraw' && item.category === 'crypto')
175
+ const networks = (selectedCrypto?.networkName || []).map((value, i) => {
176
+ return {
177
+ label: selectedCrypto.networkOptional?.[i],
178
+ value,
179
+ icon: value,
180
+ }
181
+ })
182
+
183
+ return {
184
+ withdrawRule,
185
+ selectedCrypto,
186
+ networks,
187
+ selectedNetwork: networks[0],
188
+ processing,
189
+ }
190
+ }),
191
+ setNetwork: assign((context, event) => {
192
+ return {
193
+ selectedNetwork: event.data,
194
+ }
195
+ }),
196
+ setAddress: assign((context, event) => {
197
+ return {
198
+ address: event.data,
199
+ }
200
+ }),
201
+ setAmount: assign((context, event) => {
202
+ return {
203
+ selectedAmount: event.data,
204
+ }
205
+ }),
206
+ setCalculation: assign((context, event) => {
207
+ return {
208
+ calculation: event.data,
209
+ }
210
+ }),
211
+ resetCharge: assign((context, event) => {
212
+ return {
213
+ charge: null,
214
+ }
215
+ }),
216
+ setTransaction: assign((context, event) => {
217
+ const { realAmount } = event.data
218
+ return {
219
+ realAmount,
220
+ }
221
+ }),
222
+ setOtp: assign((context, event) => {
223
+ const { requestId, status, target, ttl } = event.data
224
+ return {
225
+ requestId,
226
+ status,
227
+ target,
228
+ ttl,
229
+ }
230
+ }),
231
+ decreaseTtl: assign((context, evnet) => {
232
+ const second = context.ttl
233
+ return {
234
+ ttl: Math.max(second - 1, 0),
235
+ }
236
+ }),
237
+ setVerificationData: assign((context, event) => {
238
+ const { requestId, ttl, target } = event.data
239
+ return {
240
+ requestId,
241
+ ttl,
242
+ target,
243
+ }
244
+ }),
245
+ setAttachmentType: assign((context, event) => {
246
+ return {
247
+ attachmentType: event.data,
248
+ }
249
+ }),
250
+ setProcessing: assign((context, event) => {
251
+ return {
252
+ processing: event.data,
253
+ }
254
+ }),
255
+ },
256
+ guards: {
257
+ isProcessing: (context, event) => {
258
+ return context.processing
259
+ },
260
+ isCalculable: (context, event) => {
261
+ const { withdrawRule, selectedCrypto, selectedNetwork, selectedAmount } = context
262
+ const maximum = Math.min(withdrawRule.balance, selectedCrypto.maximum)
263
+ return selectedNetwork && selectedAmount && selectedCrypto.minimum <= selectedAmount && selectedAmount <= maximum
264
+ },
265
+ isOtpRequired: (context, event) => {
266
+ return event.data?.status === 'otp-verifying'
267
+ },
268
+ },
269
+ services: {
270
+ fetchInitData: async (context, event) => {
271
+ const [withdrawRule, orders] = await Promise.all([
272
+ request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
273
+ request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
274
+ ])
275
+
276
+ return {
277
+ withdrawRule,
278
+ processing: orders[0],
279
+ }
280
+ },
281
+ fetchWithdrawRule: async (context, event) => {
282
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
283
+ },
284
+ submitWithdraw: async (context, event) => {
285
+ const { selectedCrypto, selectedNetwork, address, selectedAmount } = context
286
+ return await request.send(
287
+ api.submitWithdrawTransactionCrypto({
288
+ method: selectedCrypto.method,
289
+ amount: selectedAmount,
290
+ cryptoCurrency: selectedCrypto.channel,
291
+ cryptoNetwork: selectedNetwork.value,
292
+ targetAddress: address,
293
+ })
294
+ )
295
+ },
296
+ fetchCalculation: async (context, event) => {
297
+ const { selectedCrypto, selectedNetwork, selectedAmount } = context
298
+ const method = selectedCrypto.method
299
+ return await request.send(
300
+ api.getWithdrawExpectedResult({
301
+ method,
302
+ amount: selectedAmount,
303
+ cryptoNetwork: selectedNetwork.value,
304
+ })
305
+ )
306
+ },
307
+ resetOtp: async (context, event) => {
308
+ const { requestId, target } = context
309
+ return await request.send(user.otpReset({ requestId, target }))
310
+ },
311
+ acknowledge: async (context, event) => {
312
+ const { requestId, target } = context
313
+ const code = event.data
314
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
315
+ },
316
+ },
317
+ }
318
+ )
319
+ }
@@ -1,5 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
- import api from '../api/payment.js'
2
+ import api from '../../api/payment.js'
3
3
 
4
4
  export default function (request) {
5
5
  return createMachine(
@@ -215,7 +215,7 @@ export default function (request) {
215
215
  const { crypto, currentNetwork, currentAddress, withdrawAmount } = context
216
216
  const method = crypto.method
217
217
  return await request.send(
218
- api.submitWithdrawTransaction({
218
+ api.submitWithdrawTransactionCrypto({
219
219
  method,
220
220
  amount: withdrawAmount,
221
221
  cryptoCurrency: crypto.channel,
@@ -0,0 +1,207 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import findLastIndex from 'lodash/findLastIndex.js'
3
+ import payment from '../../api/payment.js'
4
+ import user from '../../api/user.js'
5
+
6
+ export default function (request) {
7
+ const { appSecret } = request.config
8
+ return createMachine(
9
+ {
10
+ id: 'withdraw_krway',
11
+ initial: 'loading',
12
+ context: {
13
+ userInfo: {},
14
+ paymentDetail: {},
15
+ minimum: 0,
16
+ maximum: 0,
17
+ options: [],
18
+ amount: 0,
19
+ bankInfo: [],
20
+ bank: null,
21
+ enableWithdraw: false,
22
+ applyId: '',
23
+ balance: 0,
24
+ realAmount: 0,
25
+ charge: 0,
26
+ withdrawCheck: null,
27
+ },
28
+ states: {
29
+ loading: {
30
+ invoke: {
31
+ src: 'fetchPaymentDetail',
32
+ onDone: {
33
+ target: 'fetching',
34
+ actions: 'setPaymentData',
35
+ },
36
+ onError: {
37
+ target: 'fail',
38
+ },
39
+ },
40
+ },
41
+ fetching: {
42
+ invoke: {
43
+ src: 'fetchWithdrawRules',
44
+ onDone: {
45
+ target: 'checking',
46
+ actions: 'updateWithdrawCondition',
47
+ },
48
+ onError: {
49
+ target: 'fail',
50
+ },
51
+ },
52
+ },
53
+ checking: {
54
+ always: [{ target: 'inProcessing', cond: 'haveProcessing' }, { target: 'withdrawCheck' }],
55
+ },
56
+ withdrawCheck: {
57
+ invoke: {
58
+ src: 'withdrawCheck',
59
+ onDone: [
60
+ {
61
+ target: 'notWithdrawMinDepositAmount',
62
+ cond: 'isNotWithdrawMinDepositAmount',
63
+ actions: assign((context, event) => {
64
+ return {
65
+ withdrawCheck: event.data,
66
+ }
67
+ }),
68
+ },
69
+ {
70
+ target: 'notWithdrawable',
71
+ cond: 'isNotWithdrawable',
72
+ },
73
+ {
74
+ target: 'withdrawable',
75
+ },
76
+ ],
77
+ onError: {
78
+ target: '#withdraw_krway.fail',
79
+ },
80
+ },
81
+ },
82
+ notWithdrawMinDepositAmount: {},
83
+ inProcessing: {},
84
+ notWithdrawable: {},
85
+ withdrawable: {
86
+ on: {
87
+ ADD_AMOUNT: {
88
+ actions: 'addAmount',
89
+ },
90
+ SET_AMOUNT: {
91
+ actions: 'setAmount',
92
+ },
93
+ CLEAR_AMOUNT: {
94
+ actions: 'clearAmount',
95
+ },
96
+ SUBMIT: {
97
+ target: 'submitting',
98
+ cond: 'isSubmittable',
99
+ },
100
+ },
101
+ },
102
+ submitting: {
103
+ invoke: {
104
+ src: 'submitWithdraw',
105
+ onDone: {
106
+ target: 'submitted',
107
+ actions: 'setResult',
108
+ },
109
+ onError: {
110
+ target: 'withdrawable',
111
+ },
112
+ },
113
+ },
114
+ submitted: {
115
+ invoke: {
116
+ src: 'fetchPaymentDetail',
117
+ onDone: {
118
+ target: 'inProcessing',
119
+ actions: 'setPaymentData',
120
+ },
121
+ onError: {
122
+ target: 'fail',
123
+ },
124
+ },
125
+ },
126
+ fail: {},
127
+ },
128
+ },
129
+ {
130
+ actions: {
131
+ setPaymentData: assign((context, event) => {
132
+ const { paymentDetail, bankInfo } = event.data
133
+ const { minimum, maximum, optional } = paymentDetail?.[0] || {}
134
+ return { paymentDetail, bank: bankInfo[0], minimum, maximum, options: optional }
135
+ }),
136
+ updateWithdrawCondition: assign((context, event) => {
137
+ const { enableWithdraw, balance } = event.data
138
+ return {
139
+ balance,
140
+ enableWithdraw,
141
+ }
142
+ }),
143
+ addAmount: assign((context, event) => {
144
+ return {
145
+ amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
146
+ }
147
+ }),
148
+ setAmount: assign((context, event) => {
149
+ return { amount: parseFloat(`${event.data}`) }
150
+ }),
151
+ clearAmount: assign((context, event) => {
152
+ return { amount: null }
153
+ }),
154
+ setResult: assign((context, event) => {
155
+ const { applyId, balance, realAmount, charge } = event.data
156
+ return { applyId, balance, realAmount, charge }
157
+ }),
158
+ },
159
+ guards: {
160
+ haveProcessing: (context, event) => {
161
+ return (context.paymentDetail?.[0]?.processing || []).length > 0
162
+ },
163
+ isSubmittable: (context, event) => {
164
+ const { amount } = context
165
+ return parseFloat(`${amount}`) > 0
166
+ },
167
+ isNotWithdrawable: (context, event) => {
168
+ const { balance, enableWithdraw, paymentDetail } = context
169
+ const minWithdrawAmount = paymentDetail[0]?.minimum || 0
170
+ return !enableWithdraw || balance < minWithdrawAmount
171
+ },
172
+ isNotWithdrawMinDepositAmount: (context, event) => {
173
+ return !event.data?.enableWithdraw
174
+ },
175
+ },
176
+ services: {
177
+ fetchPaymentDetail: async (context, event) => {
178
+ const [paymentDetail = [], { bankInfo }] = await Promise.all([
179
+ request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
180
+ request.send(payment.getPaymentInfo()),
181
+ ])
182
+ return { paymentDetail, bankInfo }
183
+ },
184
+ fetchWithdrawRules: async (context, event) => {
185
+ return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
186
+ },
187
+ submitWithdraw: async (context, event) => {
188
+ const { paymentDetail, amount, bank } = context
189
+ const { method } = paymentDetail[0]
190
+ return await request.send(
191
+ payment.submitWithdrawTransactionVN({
192
+ method,
193
+ amount,
194
+ applyerBankCode: bank.bankCode,
195
+ applyerAccountNumber: bank.accountNumber,
196
+ branch: bank.branch,
197
+ holderName: bank.holderName,
198
+ })
199
+ )
200
+ },
201
+ withdrawCheck: async (context, event) => {
202
+ return await request.send(payment.withdrawCheck())
203
+ },
204
+ },
205
+ }
206
+ )
207
+ }