@jetthai/cuora 1.0.66-sabai-2 → 1.0.67
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.
- package/CHANGELOG.md +0 -638
- package/README.md +0 -6
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +30 -0
- package/package.json +11 -13
- package/src/api/activity.js +3 -10
- package/src/api/auth.js +5 -47
- package/src/api/game.js +2 -64
- package/src/api/index.js +8 -8
- package/src/api/payment.js +7 -86
- package/src/api/user.js +0 -18
- package/src/index.js +5 -7
- package/src/machine/activity/activity.js +10 -97
- package/src/machine/activity/continue_deposit_activity.js +1 -1
- package/src/machine/activity/deposit_activity.js +1 -1
- package/src/machine/activity/{diamond_shop_activity_fc.js → diamond_shop_activity.js} +5 -33
- package/src/machine/activity/{diamond_shop_activity_vn.js → diamond_shop_activity_single_exchange.js} +21 -66
- package/src/machine/activity/fafafa_activity.js +2 -4
- package/src/machine/activity/index.js +10 -24
- package/src/machine/activity/invite_friends_activity.js +8 -3
- package/src/machine/activity/ranking_activity.js +46 -40
- package/src/machine/activity/return_bonus_activity.js +3 -5
- package/src/machine/activity/specify_bets_activity.js +1 -1
- package/src/machine/auth.js +79 -234
- package/src/machine/{auth_otp_v3.js → auth_otp.js} +17 -80
- package/src/machine/bank_binding.js +14 -15
- package/src/machine/common.js +17 -80
- package/src/machine/{deposit/deposit_fc.js → deposit.js} +15 -27
- package/src/machine/error.js +1 -1
- package/src/machine/game.js +10 -17
- package/src/machine/game_favorite.js +2 -2
- package/src/machine/game_hot_new.js +1 -1
- package/src/machine/game_search.js +7 -3
- package/src/machine/inbox.js +6 -5
- package/src/machine/index.js +25 -56
- package/src/machine/merge.js +2 -2
- package/src/machine/payment_data.js +5 -6
- package/src/machine/reward.js +3 -84
- package/src/machine/setting.js +2 -5
- package/src/machine/side.js +27 -34
- package/src/machine/user_info.js +1 -1
- package/src/machine/user_reset_password.js +2 -2
- package/src/machine/user_sign_up.js +56 -111
- package/src/machine/welcome.js +8 -6
- package/src/machine/withdraw.js +380 -0
- package/src/machine/withdraw_vn.js +65 -248
- package/src/request/config.js +1 -7
- package/src/request/cookie.js +52 -0
- package/src/request/request.js +15 -11
- package/webpack.config.js +33 -0
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/dist/bundle.mjs +0 -27623
- package/rollup.config.js +0 -12
- package/src/lib/fingerprint.js +0 -5779
- package/src/machine/activity/affiliate_invite_friends_activity.js +0 -216
- package/src/machine/activity/mini_game_activity.js +0 -68
- package/src/machine/activity/roulette_activity_v2.js +0 -81
- package/src/machine/activity/sign_in_activity.js +0 -149
- package/src/machine/activity/specify_turnover_activity.js +0 -113
- package/src/machine/activity/time_bomb_activity.js +0 -80
- package/src/machine/auth_otp_v2.js +0 -177
- package/src/machine/bank_binding_amb.js +0 -140
- package/src/machine/bonus.js +0 -75
- package/src/machine/deposit/amb.js +0 -90
- package/src/machine/deposit/crypto.js +0 -267
- package/src/machine/deposit/crypto_button.js +0 -449
- package/src/machine/deposit/direct.js +0 -246
- package/src/machine/deposit/float.js +0 -295
- package/src/machine/deposit/index.js +0 -25
- package/src/machine/deposit/loadcard_vn.js +0 -390
- package/src/machine/deposit/manual_vn.js +0 -382
- package/src/machine/deposit/qrcode_v2.js +0 -451
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/vpay.js +0 -292
- package/src/machine/game_favorite_v2.js +0 -119
- package/src/machine/game_search_v2.js +0 -379
- package/src/machine/game_v2.js +0 -381
- package/src/machine/game_v2_1.js +0 -442
- package/src/machine/leaderboard.js +0 -108
- package/src/machine/promotions.js +0 -170
- package/src/machine/reward_fc.js +0 -97
- package/src/machine/roulette_v2.js +0 -271
- package/src/machine/side_v2.js +0 -200
- package/src/machine/vip_table.js +0 -50
- package/src/machine/withdraw_amb.js +0 -373
- package/src/machine/withdraw_crypto.js +0 -560
- package/src/machine/withdraw_fc.js +0 -251
- package/src/util/constant.js +0 -2
- package/src/util/deviceToken.js +0 -33
- package/src/util/index.js +0 -6
- package/src/util/storage.js +0 -28
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/payment'
|
|
3
|
+
import findLastIndex from 'lodash/findLastIndex'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'withdraw',
|
|
9
|
+
initial: 'idle',
|
|
10
|
+
context: {
|
|
11
|
+
isTurnoverMode: false,
|
|
12
|
+
siteConfig: null,
|
|
13
|
+
userInfo: null,
|
|
14
|
+
crypto: null,
|
|
15
|
+
networks: [],
|
|
16
|
+
currentNetwork: null,
|
|
17
|
+
currentAddress: '',
|
|
18
|
+
withdrawMethods: [],
|
|
19
|
+
withdrawRuleName: null,
|
|
20
|
+
withdrawRules: [],
|
|
21
|
+
withdrawLimit: null,
|
|
22
|
+
withdrawAmount: null,
|
|
23
|
+
withdrawDistance: null,
|
|
24
|
+
tutorialUrls: [],
|
|
25
|
+
balance: null,
|
|
26
|
+
charge: null,
|
|
27
|
+
},
|
|
28
|
+
states: {
|
|
29
|
+
idle: {
|
|
30
|
+
on: {
|
|
31
|
+
PRESET: {
|
|
32
|
+
target: 'preparing',
|
|
33
|
+
actions: ['setSiteConfig', 'setUserInfo', 'preset'],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
preparing: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'fetchPaymentConfig',
|
|
40
|
+
onDone: {
|
|
41
|
+
target: 'mode',
|
|
42
|
+
actions: 'setCrypto',
|
|
43
|
+
},
|
|
44
|
+
onError: {
|
|
45
|
+
target: 'fail',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
fail: {},
|
|
50
|
+
mode: {
|
|
51
|
+
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
52
|
+
},
|
|
53
|
+
free: {
|
|
54
|
+
initial: 'preparing',
|
|
55
|
+
states: {
|
|
56
|
+
preparing: {
|
|
57
|
+
invoke: {
|
|
58
|
+
src: 'fetchWithdrawRules',
|
|
59
|
+
onDone: {
|
|
60
|
+
target: 'checking',
|
|
61
|
+
actions: 'updateWithdrawCondition',
|
|
62
|
+
},
|
|
63
|
+
onError: {
|
|
64
|
+
target: 'notConvertible',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
checking: {
|
|
69
|
+
entry: 'recalculateDistance',
|
|
70
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
71
|
+
},
|
|
72
|
+
notConvertible: {},
|
|
73
|
+
convertible: {
|
|
74
|
+
initial: 'operation',
|
|
75
|
+
states: {
|
|
76
|
+
operation: {
|
|
77
|
+
on: {
|
|
78
|
+
SUBMIT: {
|
|
79
|
+
target: '#withdraw.free.converting',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
calculating: {
|
|
84
|
+
entry: 'resetCharge',
|
|
85
|
+
invoke: {
|
|
86
|
+
src: 'fetchCalculation',
|
|
87
|
+
onDone: {
|
|
88
|
+
target: 'operation',
|
|
89
|
+
actions: 'setCalculatedResult',
|
|
90
|
+
},
|
|
91
|
+
onError: {
|
|
92
|
+
target: 'operation',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
on: {
|
|
98
|
+
SET_NETWORK: {
|
|
99
|
+
actions: 'setNetwork',
|
|
100
|
+
},
|
|
101
|
+
SET_ADDRESS: {
|
|
102
|
+
actions: 'setAddress',
|
|
103
|
+
},
|
|
104
|
+
CALCULATE: {
|
|
105
|
+
target: '.calculating',
|
|
106
|
+
cond: 'isCalculable',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
converting: {
|
|
111
|
+
invoke: {
|
|
112
|
+
src: 'submitWithdrawFree',
|
|
113
|
+
onDone: {
|
|
114
|
+
target: 'converted',
|
|
115
|
+
},
|
|
116
|
+
onError: {
|
|
117
|
+
target: 'convertible.operation',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
converted: {},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
cash: {
|
|
125
|
+
initial: 'checking',
|
|
126
|
+
states: {
|
|
127
|
+
checking: {
|
|
128
|
+
entry: 'recalculateDistance',
|
|
129
|
+
always: [
|
|
130
|
+
{ target: 'disable', cond: 'isWithdrawDisable' },
|
|
131
|
+
{ target: 'transferable', cond: 'isTransferable' },
|
|
132
|
+
{ target: 'notTransferable' },
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
disable: {},
|
|
136
|
+
notTransferable: {},
|
|
137
|
+
transferable: {
|
|
138
|
+
entry: 'setBalanceToWithdrawAmount',
|
|
139
|
+
initial: 'operation',
|
|
140
|
+
states: {
|
|
141
|
+
operation: {
|
|
142
|
+
on: {
|
|
143
|
+
SUBMIT: {
|
|
144
|
+
target: '#withdraw.cash.transferring',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
calculating: {
|
|
149
|
+
entry: 'resetCharge',
|
|
150
|
+
invoke: {
|
|
151
|
+
src: 'fetchCalculation',
|
|
152
|
+
onDone: {
|
|
153
|
+
target: 'operation',
|
|
154
|
+
actions: 'setCalculatedResult',
|
|
155
|
+
},
|
|
156
|
+
onError: {
|
|
157
|
+
target: 'operation',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
on: {
|
|
163
|
+
SET_NETWORK: {
|
|
164
|
+
actions: 'setNetwork',
|
|
165
|
+
},
|
|
166
|
+
SET_ADDRESS: {
|
|
167
|
+
actions: 'setAddress',
|
|
168
|
+
},
|
|
169
|
+
CALCULATE: {
|
|
170
|
+
target: '.calculating',
|
|
171
|
+
cond: 'isCalculable',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
transferring: {
|
|
176
|
+
invoke: {
|
|
177
|
+
src: 'submitWithdraw',
|
|
178
|
+
onDone: {
|
|
179
|
+
target: 'transferred',
|
|
180
|
+
},
|
|
181
|
+
onError: {
|
|
182
|
+
target: 'transferable.operation',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
transferred: {},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
actions: {
|
|
193
|
+
setUserInfo: assign((context, event) => {
|
|
194
|
+
return {
|
|
195
|
+
userInfo: event.data.userInfo,
|
|
196
|
+
}
|
|
197
|
+
}),
|
|
198
|
+
setSiteConfig: assign((context, event) => {
|
|
199
|
+
return {
|
|
200
|
+
siteConfig: event.data.siteConfig,
|
|
201
|
+
}
|
|
202
|
+
}),
|
|
203
|
+
preset: assign((context, event) => {
|
|
204
|
+
const { userInfo, siteConfig } = event.data
|
|
205
|
+
const { withdraw_rule, withdraw_limit } = userInfo || {}
|
|
206
|
+
const balance = parseFloat(userInfo?.balance)
|
|
207
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
208
|
+
let withdrawLimit
|
|
209
|
+
if (methods.includes('amb')) {
|
|
210
|
+
withdrawLimit = (withdraw_limit + balance) * -1
|
|
211
|
+
} else {
|
|
212
|
+
withdrawLimit = withdraw_limit * -1
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
balance,
|
|
216
|
+
withdrawRuleName: withdraw_rule,
|
|
217
|
+
withdrawLimit,
|
|
218
|
+
}
|
|
219
|
+
}),
|
|
220
|
+
updateWithdrawCondition: assign((context, event) => {
|
|
221
|
+
const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
222
|
+
const tutorialUrls = event.data.adUrl.map((item) => item.url)
|
|
223
|
+
|
|
224
|
+
const { balance, withdrawLimit } = context
|
|
225
|
+
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
226
|
+
|
|
227
|
+
let distance = 0,
|
|
228
|
+
limit = 0,
|
|
229
|
+
amount = 0
|
|
230
|
+
|
|
231
|
+
if (lastMatchedIndex > -1) {
|
|
232
|
+
rules[lastMatchedIndex].match = true
|
|
233
|
+
amount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
234
|
+
limit = rules[lastMatchedIndex].greaterEqualThen
|
|
235
|
+
} else if (withdrawLimit) {
|
|
236
|
+
const diff = withdrawLimit - balance
|
|
237
|
+
limit = withdrawLimit
|
|
238
|
+
if (diff <= 0) {
|
|
239
|
+
amount = balance
|
|
240
|
+
} else {
|
|
241
|
+
distance = diff
|
|
242
|
+
}
|
|
243
|
+
} else if (rules.length > 0) {
|
|
244
|
+
limit = rules[0]?.greaterEqualThen || 0
|
|
245
|
+
distance = Math.max(limit - balance, 0)
|
|
246
|
+
} else {
|
|
247
|
+
amount = balance
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
withdrawDistance: distance,
|
|
252
|
+
withdrawAmount: amount,
|
|
253
|
+
withdrawLimit: limit,
|
|
254
|
+
withdrawRules: rules,
|
|
255
|
+
tutorialUrls,
|
|
256
|
+
}
|
|
257
|
+
}),
|
|
258
|
+
setBalanceToWithdrawAmount: assign((context, event) => {
|
|
259
|
+
return {
|
|
260
|
+
withdrawAmount: context.balance,
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
setCrypto: assign((context, event) => {
|
|
264
|
+
const method = event.data?.[0]
|
|
265
|
+
return {
|
|
266
|
+
crypto: method,
|
|
267
|
+
networks:
|
|
268
|
+
method?.optional.map((value, i) => {
|
|
269
|
+
return {
|
|
270
|
+
label: method?.originalItem?.[i],
|
|
271
|
+
value,
|
|
272
|
+
}
|
|
273
|
+
}) || [],
|
|
274
|
+
}
|
|
275
|
+
}),
|
|
276
|
+
setNetwork: assign((context, event) => {
|
|
277
|
+
return {
|
|
278
|
+
currentNetwork: event.data,
|
|
279
|
+
}
|
|
280
|
+
}),
|
|
281
|
+
setAddress: assign((context, event) => {
|
|
282
|
+
return {
|
|
283
|
+
currentAddress: event.data,
|
|
284
|
+
}
|
|
285
|
+
}),
|
|
286
|
+
setCalculatedResult: assign((context, event) => {
|
|
287
|
+
return {
|
|
288
|
+
charge: event.data.charge,
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
resetCharge: assign((context, event) => {
|
|
292
|
+
return {
|
|
293
|
+
charge: null,
|
|
294
|
+
}
|
|
295
|
+
}),
|
|
296
|
+
recalculateDistance: assign((context, event) => {
|
|
297
|
+
const { balance, withdrawLimit, crypto } = context
|
|
298
|
+
const limit = Math.max(withdrawLimit, crypto?.minimum)
|
|
299
|
+
const distance = Math.max(limit - balance, 0)
|
|
300
|
+
return {
|
|
301
|
+
withdrawDistance: distance,
|
|
302
|
+
withdrawLimit: limit,
|
|
303
|
+
}
|
|
304
|
+
}),
|
|
305
|
+
},
|
|
306
|
+
guards: {
|
|
307
|
+
isFree: (context, event) => {
|
|
308
|
+
return context.userInfo?.withdraw_policy === 'FREE'
|
|
309
|
+
},
|
|
310
|
+
isWithdrawDisable: (context, event) => {
|
|
311
|
+
const { siteConfig } = context
|
|
312
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
313
|
+
return methods.length === 0
|
|
314
|
+
},
|
|
315
|
+
isConvertible: (context, event) => {
|
|
316
|
+
const { balance, withdrawDistance } = context
|
|
317
|
+
return balance > 0 && withdrawDistance === 0
|
|
318
|
+
},
|
|
319
|
+
isTransferable: (context, event) => {
|
|
320
|
+
const { balance, withdrawLimit, withdrawDistance, isTurnoverMode } = context
|
|
321
|
+
if (balance === 0) {
|
|
322
|
+
return false
|
|
323
|
+
}
|
|
324
|
+
if (isTurnoverMode) {
|
|
325
|
+
// not used in funnycash
|
|
326
|
+
return withdrawLimit === 0
|
|
327
|
+
} else {
|
|
328
|
+
return withdrawDistance === 0
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
isCalculable: (context, event) => {
|
|
332
|
+
const { currentNetwork, balance } = context
|
|
333
|
+
return currentNetwork && balance
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
services: {
|
|
337
|
+
fetchWithdrawRules: async (context, event) => {
|
|
338
|
+
return await request.send(api.getCurrentWithdrawRule())
|
|
339
|
+
},
|
|
340
|
+
fetchPaymentConfig: async (context, event) => {
|
|
341
|
+
return await request.send(api.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
342
|
+
},
|
|
343
|
+
submitWithdraw: async (context, event) => {
|
|
344
|
+
const { crypto, currentNetwork, currentAddress, withdrawAmount } = context
|
|
345
|
+
const method = crypto.method
|
|
346
|
+
return await request.send(
|
|
347
|
+
api.submitWithdrawTransaction({
|
|
348
|
+
method,
|
|
349
|
+
amount: withdrawAmount,
|
|
350
|
+
cryptoCurrency: crypto.channel,
|
|
351
|
+
cryptoNetwork: currentNetwork.value,
|
|
352
|
+
targetAddress: currentAddress,
|
|
353
|
+
})
|
|
354
|
+
)
|
|
355
|
+
},
|
|
356
|
+
submitWithdrawFree: async (context, event) => {
|
|
357
|
+
const { currentNetwork, currentAddress } = context
|
|
358
|
+
return await request.send(
|
|
359
|
+
api.convertFreeCredit({
|
|
360
|
+
exchangeType: 1,
|
|
361
|
+
cryptoNetwork: currentNetwork.value,
|
|
362
|
+
targetAddress: currentAddress,
|
|
363
|
+
})
|
|
364
|
+
)
|
|
365
|
+
},
|
|
366
|
+
fetchCalculation: async (context, event) => {
|
|
367
|
+
const { crypto, currentNetwork, withdrawAmount } = context
|
|
368
|
+
const method = crypto.method
|
|
369
|
+
return await request.send(
|
|
370
|
+
api.getWithdrawExpectedResult({
|
|
371
|
+
method,
|
|
372
|
+
amount: withdrawAmount,
|
|
373
|
+
cryptoNetwork: currentNetwork.value,
|
|
374
|
+
})
|
|
375
|
+
)
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
}
|