@jetthai/cuora 1.0.92 → 1.0.94
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 +4 -0
- package/package.json +1 -1
- package/src/machine/deposit/manual_vn.js +9 -1
- package/src/machine/withdraw_fc.js +97 -237
- package/src/machine/withdraw_vn.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.94](https://github.com/jetthai/cuora-module/compare/v1.0.93...v1.0.94) (2022-03-01)
|
|
6
|
+
|
|
7
|
+
### [1.0.93](https://github.com/jetthai/cuora-module/compare/v1.0.92...v1.0.93) (2022-02-24)
|
|
8
|
+
|
|
5
9
|
### [1.0.92](https://github.com/jetthai/cuora-module/compare/v1.0.91...v1.0.92) (2022-02-17)
|
|
6
10
|
|
|
7
11
|
### [1.0.91](https://github.com/jetthai/cuora-module/compare/v1.0.90...v1.0.91) (2022-02-14)
|
package/package.json
CHANGED
|
@@ -194,7 +194,7 @@ export default function (request) {
|
|
|
194
194
|
}
|
|
195
195
|
}),
|
|
196
196
|
setBanks: assign((context, event) => {
|
|
197
|
-
const { playerBanks } = context
|
|
197
|
+
const { playerBanks, houseBanks, selectedHouseBank } = context
|
|
198
198
|
|
|
199
199
|
const formattedPlayerBanks = playerBanks.map((bank) => {
|
|
200
200
|
bank.shortName = `${bank.bankCode} ${bank.accountNumber.slice(-5)}`
|
|
@@ -203,8 +203,16 @@ export default function (request) {
|
|
|
203
203
|
|
|
204
204
|
const banks = [...formattedPlayerBanks, ...event.data]
|
|
205
205
|
|
|
206
|
+
const newHouseBanks = houseBanks.map((houseBank) => {
|
|
207
|
+
return { ...houseBank, ...banks.find((bank) => houseBank.bankName === bank.bankCode) }
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
const newSelectedHouseBank = { ...selectedHouseBank, ...banks.find((bank) => selectedHouseBank.bankName === bank.bankCode) }
|
|
211
|
+
|
|
206
212
|
return {
|
|
207
213
|
banks,
|
|
214
|
+
houseBanks: newHouseBanks,
|
|
215
|
+
selectedHouseBank: newSelectedHouseBank,
|
|
208
216
|
selectedUserBank: banks[0],
|
|
209
217
|
userAccountNumber: banks[0].accountNumber,
|
|
210
218
|
userAccountName: banks[0].holderName,
|
|
@@ -6,40 +6,33 @@ export default function (request) {
|
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'withdraw',
|
|
9
|
-
initial: '
|
|
9
|
+
initial: 'loading',
|
|
10
10
|
context: {
|
|
11
|
-
isTurnoverMode: false,
|
|
12
|
-
siteConfig: null,
|
|
13
|
-
userInfo: null,
|
|
14
11
|
crypto: null,
|
|
15
12
|
networks: [],
|
|
16
13
|
currentNetwork: null,
|
|
17
14
|
currentAddress: '',
|
|
18
15
|
withdrawMethods: [],
|
|
19
|
-
withdrawRuleName: null,
|
|
20
16
|
withdrawRules: [],
|
|
21
17
|
withdrawLimit: null,
|
|
22
18
|
withdrawAmount: null,
|
|
23
|
-
|
|
19
|
+
differAmountLimit: null,
|
|
24
20
|
tutorialUrls: [],
|
|
21
|
+
enableWithdraw: false,
|
|
22
|
+
description: {},
|
|
23
|
+
policy: '',
|
|
24
|
+
ruleName: '',
|
|
25
25
|
balance: null,
|
|
26
26
|
charge: null,
|
|
27
|
+
isFree: false,
|
|
27
28
|
},
|
|
28
29
|
states: {
|
|
29
|
-
|
|
30
|
-
on: {
|
|
31
|
-
PRESET: {
|
|
32
|
-
target: 'preparing',
|
|
33
|
-
actions: ['setSiteConfig', 'setUserInfo', 'preset'],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
preparing: {
|
|
30
|
+
loading: {
|
|
38
31
|
invoke: {
|
|
39
|
-
src: '
|
|
32
|
+
src: 'preset',
|
|
40
33
|
onDone: {
|
|
41
|
-
target: '
|
|
42
|
-
actions: 'setCrypto',
|
|
34
|
+
target: 'checking',
|
|
35
|
+
actions: ['setCrypto', 'setWithdrawCondition', 'checkMinimumWithdraw'],
|
|
43
36
|
},
|
|
44
37
|
onError: {
|
|
45
38
|
target: 'fail',
|
|
@@ -47,225 +40,106 @@ export default function (request) {
|
|
|
47
40
|
},
|
|
48
41
|
},
|
|
49
42
|
fail: {},
|
|
50
|
-
|
|
51
|
-
always: [{ target: '
|
|
43
|
+
checking: {
|
|
44
|
+
always: [{ target: 'transferable', cond: 'isTransferable' }, { target: 'notTransferable' }],
|
|
52
45
|
},
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
notTransferable: {},
|
|
47
|
+
transferable: {
|
|
48
|
+
initial: 'operation',
|
|
55
49
|
states: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
},
|
|
50
|
+
operation: {
|
|
51
|
+
on: {
|
|
52
|
+
SUBMIT: [
|
|
53
|
+
{
|
|
54
|
+
target: '#withdraw.exchanging',
|
|
55
|
+
cond: 'isFree',
|
|
81
56
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
entry: 'resetCharge',
|
|
85
|
-
invoke: {
|
|
86
|
-
src: 'fetchCalculation',
|
|
87
|
-
onDone: {
|
|
88
|
-
target: 'operation',
|
|
89
|
-
actions: 'setCalculatedResult',
|
|
90
|
-
},
|
|
91
|
-
onError: {
|
|
92
|
-
target: 'operation',
|
|
93
|
-
},
|
|
57
|
+
{
|
|
58
|
+
target: '#withdraw.transferring',
|
|
94
59
|
},
|
|
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
|
-
},
|
|
60
|
+
],
|
|
108
61
|
},
|
|
109
62
|
},
|
|
110
|
-
|
|
63
|
+
calculating: {
|
|
64
|
+
entry: 'resetCharge',
|
|
111
65
|
invoke: {
|
|
112
|
-
src: '
|
|
66
|
+
src: 'fetchCalculation',
|
|
113
67
|
onDone: {
|
|
114
|
-
target: '
|
|
68
|
+
target: 'operation',
|
|
69
|
+
actions: 'setCalculatedResult',
|
|
115
70
|
},
|
|
116
71
|
onError: {
|
|
117
|
-
target: '
|
|
72
|
+
target: 'operation',
|
|
118
73
|
},
|
|
119
74
|
},
|
|
120
75
|
},
|
|
121
|
-
|
|
76
|
+
},
|
|
77
|
+
on: {
|
|
78
|
+
SET_NETWORK: {
|
|
79
|
+
actions: 'setNetwork',
|
|
80
|
+
},
|
|
81
|
+
SET_ADDRESS: {
|
|
82
|
+
actions: 'setAddress',
|
|
83
|
+
},
|
|
84
|
+
CALCULATE: {
|
|
85
|
+
target: '.calculating',
|
|
86
|
+
cond: 'isCalculable',
|
|
87
|
+
},
|
|
122
88
|
},
|
|
123
89
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
always: [
|
|
130
|
-
{ target: 'disable', cond: 'isWithdrawDisable' },
|
|
131
|
-
{ target: 'transferable', cond: 'isTransferable' },
|
|
132
|
-
{ target: 'notTransferable' },
|
|
133
|
-
],
|
|
90
|
+
exchanging: {
|
|
91
|
+
invoke: {
|
|
92
|
+
src: 'submitWithdrawFree',
|
|
93
|
+
onDone: {
|
|
94
|
+
target: 'transferred',
|
|
134
95
|
},
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
},
|
|
96
|
+
onError: {
|
|
97
|
+
target: 'transferable.operation',
|
|
174
98
|
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
transferring: {
|
|
102
|
+
invoke: {
|
|
103
|
+
src: 'submitWithdraw',
|
|
104
|
+
onDone: {
|
|
105
|
+
target: 'transferred',
|
|
106
|
+
},
|
|
107
|
+
onError: {
|
|
108
|
+
target: 'transferable.operation',
|
|
185
109
|
},
|
|
186
|
-
transferred: {},
|
|
187
110
|
},
|
|
188
111
|
},
|
|
112
|
+
transferred: {},
|
|
189
113
|
},
|
|
190
114
|
},
|
|
191
115
|
{
|
|
192
116
|
actions: {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
}
|
|
117
|
+
setWithdrawCondition: assign((context, event) => {
|
|
118
|
+
const { adUrl, balance, description, differAmountLimit, enableWithdraw, enableWithdrawAmount, policy, ruleName, rules } =
|
|
119
|
+
event.data.withdraw
|
|
249
120
|
|
|
250
121
|
return {
|
|
251
|
-
|
|
252
|
-
withdrawAmount:
|
|
253
|
-
withdrawLimit:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
122
|
+
differAmountLimit: differAmountLimit,
|
|
123
|
+
withdrawAmount: enableWithdrawAmount,
|
|
124
|
+
withdrawLimit: enableWithdraw
|
|
125
|
+
? 0
|
|
126
|
+
: rules.find((rule) => balance < rule.greaterEqualThen)?.greaterEqualThen || parseFloat(balance) + parseFloat(differAmountLimit),
|
|
127
|
+
withdrawRules: rules.filter((rule) => rule.maxWithdrawAmount > 0),
|
|
128
|
+
tutorialUrls: adUrl.map((item) => item.url),
|
|
129
|
+
enableWithdraw,
|
|
130
|
+
description,
|
|
131
|
+
policy,
|
|
132
|
+
ruleName,
|
|
133
|
+
balance,
|
|
134
|
+
isFree: policy === 'FREE',
|
|
261
135
|
}
|
|
262
136
|
}),
|
|
263
137
|
setCrypto: assign((context, event) => {
|
|
264
|
-
const method = event.data?.[0]
|
|
138
|
+
const method = event.data.payment?.[0]
|
|
265
139
|
return {
|
|
266
140
|
crypto: method,
|
|
267
141
|
networks:
|
|
268
|
-
method?.optional
|
|
142
|
+
method?.optional?.map?.((value, i) => {
|
|
269
143
|
return {
|
|
270
144
|
label: method?.originalItem?.[i],
|
|
271
145
|
value,
|
|
@@ -294,40 +168,25 @@ export default function (request) {
|
|
|
294
168
|
charge: null,
|
|
295
169
|
}
|
|
296
170
|
}),
|
|
297
|
-
|
|
298
|
-
const { balance, withdrawLimit, crypto } = context
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
171
|
+
checkMinimumWithdraw: assign((context, event) => {
|
|
172
|
+
const { balance, withdrawLimit, crypto, isFree } = context
|
|
173
|
+
if (!isFree && crypto?.minimum > withdrawLimit) {
|
|
174
|
+
const limit = crypto?.minimum
|
|
175
|
+
const distance = Math.max(limit - balance, 0)
|
|
176
|
+
return {
|
|
177
|
+
differAmountLimit: distance,
|
|
178
|
+
withdrawLimit: limit,
|
|
179
|
+
}
|
|
304
180
|
}
|
|
305
181
|
}),
|
|
306
182
|
},
|
|
307
183
|
guards: {
|
|
308
184
|
isFree: (context, event) => {
|
|
309
|
-
return context.
|
|
310
|
-
},
|
|
311
|
-
isWithdrawDisable: (context, event) => {
|
|
312
|
-
const { siteConfig } = context
|
|
313
|
-
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
314
|
-
return methods.length === 0
|
|
315
|
-
},
|
|
316
|
-
isConvertible: (context, event) => {
|
|
317
|
-
const { balance, withdrawDistance } = context
|
|
318
|
-
return balance > 0 && withdrawDistance === 0
|
|
185
|
+
return context.isFree
|
|
319
186
|
},
|
|
320
187
|
isTransferable: (context, event) => {
|
|
321
|
-
const { balance, withdrawLimit
|
|
322
|
-
|
|
323
|
-
return false
|
|
324
|
-
}
|
|
325
|
-
if (isTurnoverMode) {
|
|
326
|
-
// not used in funnycash
|
|
327
|
-
return withdrawLimit === 0
|
|
328
|
-
} else {
|
|
329
|
-
return withdrawDistance === 0
|
|
330
|
-
}
|
|
188
|
+
const { enableWithdraw, balance, withdrawLimit } = context
|
|
189
|
+
return enableWithdraw && balance >= withdrawLimit
|
|
331
190
|
},
|
|
332
191
|
isCalculable: (context, event) => {
|
|
333
192
|
const { currentNetwork, balance } = context
|
|
@@ -335,11 +194,12 @@ export default function (request) {
|
|
|
335
194
|
},
|
|
336
195
|
},
|
|
337
196
|
services: {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
197
|
+
preset: async (context, event) => {
|
|
198
|
+
const [withdraw, payment] = await Promise.all([
|
|
199
|
+
request.send(api.getCurrentWithdrawRule()),
|
|
200
|
+
request.send(api.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
201
|
+
])
|
|
202
|
+
return { withdraw, payment }
|
|
343
203
|
},
|
|
344
204
|
submitWithdraw: async (context, event) => {
|
|
345
205
|
const { crypto, currentNetwork, currentAddress, withdrawAmount } = context
|
|
@@ -262,7 +262,10 @@ export default function (request) {
|
|
|
262
262
|
const siteConfig = JSON.parse(window.atob(config))
|
|
263
263
|
const method = paymentDetail.find((payment) => payment.methodType === 'manual').method
|
|
264
264
|
const bankList = await request.send(payment.getBankList(method))
|
|
265
|
-
|
|
265
|
+
const newBankInfo = bankInfo.map((item) => {
|
|
266
|
+
return { ...item, ...bankList.find((bank) => bank.bankCode === item.bankCode) }
|
|
267
|
+
})
|
|
268
|
+
return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
266
269
|
},
|
|
267
270
|
fetchPaymentData: async (context, event) => {
|
|
268
271
|
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|