@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,256 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '@jetthai/cuora/src/api/payment.js'
3
+ import { max } from '../../util/index.js'
4
+
5
+ export default function (request, context) {
6
+ const { paymentDetail = [], promotion, selectedAmount } = context || {}
7
+ return createMachine(
8
+ {
9
+ id: 'crypto_way_cash',
10
+ initial: 'loading',
11
+ context: {
12
+ paymentDetail,
13
+ promotion,
14
+ selectedAmount,
15
+
16
+ cryptos: [],
17
+ sourceAddress: '',
18
+ options: [],
19
+
20
+ selectedCrypto: null,
21
+
22
+ currentCategory: 'cryptoWay',
23
+
24
+ calculation: null,
25
+ result: null,
26
+ ttl: 0,
27
+ },
28
+ states: {
29
+ loading: {
30
+ always: [
31
+ {
32
+ target: 'debouncing',
33
+ actions: 'setInitData',
34
+ },
35
+ ],
36
+ },
37
+ loaded: {},
38
+ debouncing: {
39
+ entry: 'clearCalculation',
40
+ after: {
41
+ 1000: [
42
+ {
43
+ target: 'calculating',
44
+ cond: 'isCalculable',
45
+ },
46
+ {
47
+ target: 'loaded',
48
+ },
49
+ ],
50
+ },
51
+ },
52
+ calculating: {
53
+ invoke: {
54
+ src: 'fetchCalculation',
55
+ onDone: {
56
+ target: 'calculated',
57
+ actions: 'setCalculation',
58
+ },
59
+ onError: {
60
+ target: 'calculated',
61
+ },
62
+ },
63
+ },
64
+ calculated: {
65
+ on: {
66
+ SUBMIT: [
67
+ {
68
+ target: 'submitting',
69
+ cond: 'isSubmittable',
70
+ },
71
+ ],
72
+ },
73
+ },
74
+ submitting: {
75
+ invoke: {
76
+ src: 'submitDeposit',
77
+ onDone: {
78
+ target: 'submitted',
79
+ actions: ['setResult', 'setTtl'],
80
+ },
81
+ onError: {
82
+ target: 'calculated',
83
+ },
84
+ },
85
+ },
86
+ submitted: {
87
+ after: {
88
+ 1000: {
89
+ target: 'submitted',
90
+ actions: 'decreaseTtl',
91
+ cond: (context) => context.ttl > 0,
92
+ },
93
+ },
94
+ },
95
+ },
96
+ on: {
97
+ SET_PROMOTION: {
98
+ target: '.debouncing',
99
+ actions: 'setPromotion',
100
+ internal: false,
101
+ },
102
+ SET_CRYPTO: {
103
+ target: '.debouncing',
104
+ actions: 'setCrypto',
105
+ internal: false,
106
+ },
107
+ SET_ADDRESS: {
108
+ actions: 'setAddress',
109
+ internal: false,
110
+ },
111
+ SET_AMOUNT: {
112
+ target: '.debouncing',
113
+ actions: 'setAmount',
114
+ internal: false,
115
+ },
116
+ INPUT_AMOUNT: {
117
+ target: '.debouncing',
118
+ actions: 'inputAmount',
119
+ internal: false,
120
+ },
121
+ },
122
+ },
123
+ {
124
+ actions: {
125
+ setInitData: assign((context, event) => {
126
+ const { paymentDetail } = context
127
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
128
+ const cryptos = payments.map((payment) => ({
129
+ ...payment,
130
+ label: payment.cryptoOptional?.[0],
131
+ network: payment.networkName?.[0],
132
+ value: payment.method,
133
+ icon: payment.channel,
134
+ }))
135
+
136
+ return {
137
+ cryptos,
138
+ selectedCrypto: cryptos[0],
139
+ options: cryptos[0].optional,
140
+ }
141
+ }),
142
+ setCrypto: assign((context, event) => {
143
+ const { cryptos } = context
144
+ const selectedCrypto = cryptos.find((crypto) => crypto.label === event.data.label)
145
+ return {
146
+ selectedCrypto: selectedCrypto,
147
+ selectedAmount: null,
148
+ calculation: null,
149
+ options: selectedCrypto.optional,
150
+ }
151
+ }),
152
+ setAmount: assign((context, event) => {
153
+ // 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
154
+ if (context.selectedCrypto?.grandTotalEnable === 1) {
155
+ return {
156
+ selectedAmount: preciseAdd(`${parseFloat(context.selectedAmount || 0)}`, `${parseFloat(event.data)}`),
157
+ }
158
+ } else {
159
+ return { selectedAmount: event.data }
160
+ }
161
+ }),
162
+ inputAmount: assign((context, event) => {
163
+ return { selectedAmount: event.data }
164
+ }),
165
+ setAddress: assign((context, event) => {
166
+ return {
167
+ sourceAddress: event.data,
168
+ }
169
+ }),
170
+ setCalculation: assign((context, event) => {
171
+ return {
172
+ calculation: event.data,
173
+ }
174
+ }),
175
+ clearCalculation: assign((context, event) => {
176
+ return {
177
+ calculation: null,
178
+ }
179
+ }),
180
+ setResult: assign((context, event) => {
181
+ return {
182
+ result: event.data,
183
+ }
184
+ }),
185
+ setPromotion: assign((context, event) => {
186
+ const { selectedCrypto, selectedAmount } = context
187
+ const promotion = event.data
188
+ return {
189
+ promotion,
190
+ selectedAmount: max(promotion.minimumAmount, selectedCrypto.minimum, selectedAmount, 0),
191
+ calculation: null,
192
+ }
193
+ }),
194
+ setTtl: assign((context, event) => {
195
+ const { cdtime } = event.data
196
+ return {
197
+ ttl: cdtime,
198
+ }
199
+ }),
200
+ decreaseTtl: assign((context, evnet) => {
201
+ return {
202
+ ttl: Math.max(context.ttl - 1000, 0),
203
+ }
204
+ }),
205
+ },
206
+ guards: {
207
+ isCalculable: (context, event) => {
208
+ const { selectedCrypto, selectedAmount } = context
209
+ return selectedCrypto && selectedAmount && selectedCrypto.minimum <= +selectedAmount && +selectedAmount <= selectedCrypto.maximum
210
+ },
211
+ isSubmittable: (context, event) => {
212
+ const { selectedCrypto, selectedAmount, calculation } = context
213
+ return selectedCrypto && selectedAmount && calculation
214
+ },
215
+ },
216
+ services: {
217
+ fetchCalculation: async (context, event) => {
218
+ const { selectedCrypto, selectedAmount, promotion } = context
219
+ return await request.send(
220
+ payment.getCryptoDepositExpectedResult({
221
+ method: selectedCrypto.method,
222
+ amount: selectedAmount,
223
+ cryptoCurrency: selectedCrypto.channel,
224
+ promotionsNo: promotion?.promotionsNo,
225
+ })
226
+ )
227
+ },
228
+ submitDeposit: async (context, event) => {
229
+ const { selectedCrypto, selectedAmount, sourceAddress, promotion } = context
230
+ return await request.send(
231
+ payment.submitDepositTransactionCrypto({
232
+ method: selectedCrypto.method,
233
+ amount: selectedAmount,
234
+ cryptoCurrency: selectedCrypto.channel,
235
+ cryptoNetwork: selectedCrypto.network,
236
+ sourceAddress: sourceAddress,
237
+ promotionsNo: promotion?.promotionsNo,
238
+ })
239
+ )
240
+ },
241
+ },
242
+ }
243
+ )
244
+ }
245
+
246
+ function preciseAdd(a, b) {
247
+ let aStr = a.toString()
248
+ let bStr = b.toString()
249
+
250
+ let aDecimalPlaces = aStr.split('.')[1] ? aStr.split('.')[1].length : 0
251
+ let bDecimalPlaces = bStr.split('.')[1] ? bStr.split('.')[1].length : 0
252
+
253
+ let factor = Math.pow(10, Math.max(aDecimalPlaces, bDecimalPlaces))
254
+
255
+ return (Math.round(a * factor) + Math.round(b * factor)) / factor
256
+ }
@@ -59,9 +59,7 @@ export default function (request) {
59
59
  },
60
60
  checking: {
61
61
  entry: 'clearCalculatedResult',
62
- always: [
63
- { target: 'debouncing', cond: 'isCalculable' },
64
- { target: 'loaded'}]
62
+ always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
65
63
  },
66
64
  debouncing: {
67
65
  after: {
@@ -132,7 +130,12 @@ export default function (request) {
132
130
  actions: {
133
131
  setCryptos: assign((context, event) => {
134
132
  return {
135
- cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })),
133
+ cryptos: event.data.map((crypto) => ({
134
+ ...crypto,
135
+ label: crypto.channel,
136
+ value: crypto.method,
137
+ icon: crypto.channel,
138
+ })),
136
139
  }
137
140
  }),
138
141
  setCrypto: assign((context, event) => {
@@ -238,7 +241,7 @@ export default function (request) {
238
241
  submitDeposit: async (context, event) => {
239
242
  const { currentCrypto, currentNetwork, calculatedResult } = context
240
243
  return await request.send(
241
- payment.submitDepositTransaction({
244
+ payment.submitDepositTransactionCrypto({
242
245
  method: currentCrypto.method,
243
246
  amount: calculatedResult.actualAmount,
244
247
  cryptoCurrency: currentCrypto.channel,
@@ -1,13 +1,16 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
+ import common from '../../api/common.js'
3
4
 
4
5
  export default function (request) {
6
+ const { appSecret } = request.config
5
7
  return createMachine(
6
8
  {
7
9
  id: 'direct',
8
10
  initial: 'loading',
9
11
  context: {
10
- paymentDetails: [],
12
+ siteConfig: null,
13
+ paymentDetail: [],
11
14
  directs: [],
12
15
  currentDirect: null,
13
16
  banks: [],
@@ -17,6 +20,9 @@ export default function (request) {
17
20
  currentMethod: null,
18
21
  amount: null,
19
22
  result: null,
23
+
24
+ // use for wallet mode 3
25
+ promotion: null,
20
26
  },
21
27
  states: {
22
28
  loading: {
@@ -38,7 +44,7 @@ export default function (request) {
38
44
  invoke: {
39
45
  src: 'fetchBanksList',
40
46
  onDone: {
41
- target: '#direct.loaded',
47
+ target: '#direct.promotion',
42
48
  actions: 'setBanks',
43
49
  },
44
50
  onError: {
@@ -48,6 +54,22 @@ export default function (request) {
48
54
  },
49
55
  },
50
56
  },
57
+ promotion: {
58
+ always: [
59
+ {
60
+ target: 'loaded',
61
+ cond: 'isDoubleWalletMode',
62
+ },
63
+ {
64
+ target: 'calculating',
65
+ actions: 'setPromotionDefaultAmount',
66
+ cond: 'hasMinPromotionDeposit',
67
+ },
68
+ {
69
+ target: 'loaded',
70
+ },
71
+ ],
72
+ },
51
73
  loaded: {
52
74
  on: {
53
75
  SELECT_DIRECT: {
@@ -64,15 +86,61 @@ export default function (request) {
64
86
  actions: 'clearCalculation',
65
87
  },
66
88
  CALCULATE: {
67
- target: 'calculating',
68
- cond: 'isCalculable',
89
+ target: 'debouncing',
69
90
  },
91
+ SUBMIT: [
92
+ {
93
+ target: 'pending',
94
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
95
+ },
96
+ {
97
+ target: 'submitting',
98
+ cond: 'isSubmittable',
99
+ },
100
+ ],
101
+ },
102
+ },
103
+ pending: {
104
+ on: {
70
105
  SUBMIT: {
71
106
  target: 'submitting',
72
107
  cond: 'isSubmittable',
73
108
  },
74
109
  },
75
110
  },
111
+ debouncing: {
112
+ on: {
113
+ SELECT_DIRECT: {
114
+ actions: ['setDirect', 'reset'],
115
+ target: 'loading.fetching',
116
+ },
117
+ SELECT_BANK: {
118
+ actions: 'setSelectedBank',
119
+ },
120
+ SET_AMOUNT: {
121
+ actions: ['setAmount', 'clearCalculation'],
122
+ },
123
+ CLEAR_CALCULATION: {
124
+ actions: 'clearCalculation',
125
+ },
126
+ CALCULATE: {
127
+ target: 'debouncing',
128
+ },
129
+ SUBMIT: [
130
+ {
131
+ target: 'pending',
132
+ cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
133
+ },
134
+ {
135
+ target: 'submitting',
136
+ cond: 'isSubmittable',
137
+ },
138
+ ],
139
+ },
140
+ after: {
141
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
142
+ },
143
+ },
76
144
  calculating: {
77
145
  invoke: {
78
146
  src: 'fetchCalculation',
@@ -100,6 +168,11 @@ export default function (request) {
100
168
  submitted: {},
101
169
  fail: {},
102
170
  },
171
+ on: {
172
+ SET_PROMOTION: {
173
+ actions: 'setPromotion',
174
+ },
175
+ },
103
176
  },
104
177
  {
105
178
  actions: {
@@ -109,22 +182,23 @@ export default function (request) {
109
182
  amount: null,
110
183
  selectedBank: banks[0],
111
184
  calculation: null,
185
+ result: null,
112
186
  }
113
187
  }),
114
188
  setInitData: assign((context, event) => {
115
- const paymentDetails = event.data
116
- const directs = paymentDetails.filter((element) => element.category === context.currentCategory)
117
-
189
+ const { siteConfig, paymentDetail } = event.data
190
+ const directs = paymentDetail.filter((element) => element.category === context.currentCategory)
191
+ const currentDirect = directs[0]
118
192
  return {
119
- paymentDetails,
193
+ siteConfig,
194
+ paymentDetail,
120
195
  directs,
121
- currentDirect: directs[0],
122
- currentMethod: directs[0]?.method,
196
+ currentDirect,
197
+ currentMethod: currentDirect?.method,
123
198
  }
124
199
  }),
125
200
  setBanks: assign((context, event) => {
126
201
  const banks = event.data
127
-
128
202
  return {
129
203
  banks,
130
204
  selectedBank: banks[0],
@@ -161,24 +235,44 @@ export default function (request) {
161
235
  result: event.data,
162
236
  }
163
237
  }),
238
+ setPromotion: assign((context, event) => {
239
+ return {
240
+ promotion: event.data,
241
+ }
242
+ }),
243
+ setPromotionDefaultAmount: assign((context, event) => {
244
+ return {
245
+ amount: context.promotion.minimumAmount,
246
+ }
247
+ }),
164
248
  },
165
249
  guards: {
250
+ isDoubleWalletMode: (context, event) => {
251
+ return context.siteConfig?.walletMode === '4'
252
+ },
166
253
  isCalculable: (context, event) => {
167
254
  const {
168
255
  amount,
169
256
  currentDirect: { maximum, minimum },
170
257
  } = context
171
-
172
258
  return amount && minimum <= +amount && +amount <= maximum
173
259
  },
174
260
  isSubmittable: (context, event) => {
175
261
  const { amount, currentMethod, selectedBank } = context
176
262
  return amount && currentMethod && selectedBank?.bankCode
177
263
  },
264
+ hasMinPromotionDeposit: (context, event) => {
265
+ return context.promotion?.minimumAmount
266
+ },
178
267
  },
179
268
  services: {
180
269
  fetchInitData: async (context, event) => {
181
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
270
+ const [{ config }, paymentDetail = []] = await Promise.all([
271
+ request.send(common.getConfig({ appSecret })),
272
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
273
+ ])
274
+ const siteConfig = JSON.parse(window.atob(config))
275
+ return { siteConfig, paymentDetail }
182
276
  },
183
277
  fetchBanksList: async (context, event) => {
184
278
  const { currentDirect } = context
@@ -186,22 +280,23 @@ export default function (request) {
186
280
  return await request.send(payment.getBankList(method))
187
281
  },
188
282
  fetchCalculation: async (context, event) => {
189
- const { currentMethod, amount } = context
190
-
283
+ const { currentMethod, amount, promotion } = context
191
284
  return await request.send(
192
285
  payment.getDepositExpectedResult({
193
286
  method: currentMethod,
194
287
  amount,
288
+ promotionsNo: promotion?.activityNo,
195
289
  })
196
290
  )
197
291
  },
198
292
  submitDeposit: async (context, event) => {
199
- const { currentMethod, amount, selectedBank } = context
293
+ const { currentMethod, amount, selectedBank, promotion } = context
200
294
  return await request.send(
201
295
  payment.submitDepositTransactionBank({
202
296
  method: currentMethod,
203
297
  amount,
204
298
  applyerBankCode: selectedBank.bankCode,
299
+ promotionsNo: promotion?.activityNo,
205
300
  })
206
301
  )
207
302
  },