@jetthai/cuora 1.0.32 → 1.0.33
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 +2 -0
- package/package.json +1 -1
- package/src/machine/withdraw.js +42 -44
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.33](https://github.com/jetthai/cuora-module/compare/v1.0.32...v1.0.33) (2021-10-22)
|
|
6
|
+
|
|
5
7
|
### [1.0.32](https://github.com/jetthai/cuora-module/compare/v1.0.31...v1.0.32) (2021-10-21)
|
|
6
8
|
|
|
7
9
|
### [1.0.31](https://github.com/jetthai/cuora-module/compare/v1.0.30...v1.0.31) (2021-10-21)
|
package/package.json
CHANGED
package/src/machine/withdraw.js
CHANGED
|
@@ -20,7 +20,7 @@ export default function (request) {
|
|
|
20
20
|
withdrawRules: [],
|
|
21
21
|
withdrawLimit: null,
|
|
22
22
|
withdrawAmount: null,
|
|
23
|
-
|
|
23
|
+
withdrawDistance: null,
|
|
24
24
|
tutorialUrls: [],
|
|
25
25
|
balance: null,
|
|
26
26
|
charge: null,
|
|
@@ -29,11 +29,24 @@ export default function (request) {
|
|
|
29
29
|
idle: {
|
|
30
30
|
on: {
|
|
31
31
|
PRESET: {
|
|
32
|
-
target: '
|
|
32
|
+
target: 'preparing',
|
|
33
33
|
actions: ['setSiteConfig', 'setUserInfo', 'preset'],
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
+
preparing: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'fetchPayments',
|
|
40
|
+
onDone: {
|
|
41
|
+
target: 'mode',
|
|
42
|
+
actions: 'setCrypto',
|
|
43
|
+
},
|
|
44
|
+
onError: {
|
|
45
|
+
target: 'fail',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
fail: {},
|
|
37
50
|
mode: {
|
|
38
51
|
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
39
52
|
},
|
|
@@ -44,7 +57,7 @@ export default function (request) {
|
|
|
44
57
|
invoke: {
|
|
45
58
|
src: 'fetchWithdrawRules',
|
|
46
59
|
onDone: {
|
|
47
|
-
target: '
|
|
60
|
+
target: 'checking',
|
|
48
61
|
actions: 'updateWithdrawCondition',
|
|
49
62
|
},
|
|
50
63
|
onError: {
|
|
@@ -52,22 +65,14 @@ export default function (request) {
|
|
|
52
65
|
},
|
|
53
66
|
},
|
|
54
67
|
},
|
|
68
|
+
checking: {
|
|
69
|
+
entry: 'recalculateDistance',
|
|
70
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
71
|
+
},
|
|
55
72
|
notConvertible: {},
|
|
56
73
|
convertible: {
|
|
57
|
-
initial: '
|
|
74
|
+
initial: 'operation',
|
|
58
75
|
states: {
|
|
59
|
-
preparing: {
|
|
60
|
-
invoke: {
|
|
61
|
-
src: 'fetchPayments',
|
|
62
|
-
onDone: {
|
|
63
|
-
target: 'operation',
|
|
64
|
-
actions: 'setCrypto',
|
|
65
|
-
},
|
|
66
|
-
onError: {
|
|
67
|
-
target: '#withdraw.free.notConvertible',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
76
|
operation: {
|
|
72
77
|
on: {
|
|
73
78
|
SET_NETWORK: {
|
|
@@ -118,7 +123,7 @@ export default function (request) {
|
|
|
118
123
|
initial: 'checking',
|
|
119
124
|
states: {
|
|
120
125
|
checking: {
|
|
121
|
-
entry: '
|
|
126
|
+
entry: 'recalculateDistance',
|
|
122
127
|
always: [
|
|
123
128
|
{ target: 'disable', cond: 'isWithdrawDisable' },
|
|
124
129
|
{ target: 'transferable', cond: 'isTransferable' },
|
|
@@ -129,20 +134,8 @@ export default function (request) {
|
|
|
129
134
|
notTransferable: {},
|
|
130
135
|
transferable: {
|
|
131
136
|
entry: 'setBalanceToWithdrawAmount',
|
|
132
|
-
initial: '
|
|
137
|
+
initial: 'operation',
|
|
133
138
|
states: {
|
|
134
|
-
preparing: {
|
|
135
|
-
invoke: {
|
|
136
|
-
src: 'fetchPayments',
|
|
137
|
-
onDone: {
|
|
138
|
-
target: 'operation',
|
|
139
|
-
actions: 'setCrypto',
|
|
140
|
-
},
|
|
141
|
-
onError: {
|
|
142
|
-
target: '#withdraw.cash.checking',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
139
|
operation: {
|
|
147
140
|
on: {
|
|
148
141
|
SET_NETWORK: {
|
|
@@ -227,7 +220,7 @@ export default function (request) {
|
|
|
227
220
|
const { balance, withdrawLimit } = context
|
|
228
221
|
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
229
222
|
|
|
230
|
-
let
|
|
223
|
+
let distance = 0,
|
|
231
224
|
limit,
|
|
232
225
|
amount = 0
|
|
233
226
|
if (lastMatchedIndex > -1) {
|
|
@@ -237,18 +230,17 @@ export default function (request) {
|
|
|
237
230
|
} else if (withdrawLimit) {
|
|
238
231
|
const diff = withdrawLimit - balance
|
|
239
232
|
limit = withdrawLimit
|
|
240
|
-
if (diff
|
|
233
|
+
if (diff <= 0) {
|
|
241
234
|
amount = balance
|
|
242
235
|
} else {
|
|
243
|
-
|
|
236
|
+
distance = diff
|
|
244
237
|
}
|
|
245
238
|
} else {
|
|
246
|
-
|
|
247
|
-
|
|
239
|
+
limit = rules[0]?.greaterEqualThen || 0
|
|
240
|
+
distance = Math.max(limit - balance, 0)
|
|
248
241
|
}
|
|
249
|
-
|
|
250
242
|
return {
|
|
251
|
-
|
|
243
|
+
withdrawDistance: distance,
|
|
252
244
|
withdrawAmount: amount,
|
|
253
245
|
withdrawLimit: limit,
|
|
254
246
|
withdrawRules: rules,
|
|
@@ -286,12 +278,13 @@ export default function (request) {
|
|
|
286
278
|
charge: null,
|
|
287
279
|
}
|
|
288
280
|
}),
|
|
289
|
-
|
|
290
|
-
const { balance, withdrawLimit } = context
|
|
291
|
-
const
|
|
292
|
-
const
|
|
281
|
+
recalculateDistance: assign((context, event) => {
|
|
282
|
+
const { balance, withdrawLimit, crypto } = context
|
|
283
|
+
const limit = Math.max(withdrawLimit, crypto?.minimum)
|
|
284
|
+
const distance = Math.max(limit - balance, 0)
|
|
293
285
|
return {
|
|
294
|
-
|
|
286
|
+
withdrawDistance: distance,
|
|
287
|
+
withdrawLimit: limit,
|
|
295
288
|
}
|
|
296
289
|
}),
|
|
297
290
|
},
|
|
@@ -304,15 +297,20 @@ export default function (request) {
|
|
|
304
297
|
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
305
298
|
return methods.length === 0
|
|
306
299
|
},
|
|
300
|
+
isConvertible: (context, event) => {
|
|
301
|
+
const { balance, withdrawDistance } = context
|
|
302
|
+
return balance > 0 && withdrawDistance === 0
|
|
303
|
+
},
|
|
307
304
|
isTransferable: (context, event) => {
|
|
308
|
-
const { balance, withdrawLimit, isTurnoverMode } = context
|
|
305
|
+
const { balance, withdrawLimit, withdrawDistance, isTurnoverMode } = context
|
|
309
306
|
if (balance === 0) {
|
|
310
307
|
return false
|
|
311
308
|
}
|
|
312
309
|
if (isTurnoverMode) {
|
|
310
|
+
// not used in funnycash
|
|
313
311
|
return withdrawLimit === 0
|
|
314
312
|
} else {
|
|
315
|
-
return
|
|
313
|
+
return withdrawDistance === 0
|
|
316
314
|
}
|
|
317
315
|
},
|
|
318
316
|
isCalculable: (context, event) => {
|