@jetthai/cuora 1.1.94 → 1.1.95
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/.husky/pre-commit +1 -1
- package/CHANGELOG.md +22 -0
- package/package.json +3 -8
- package/src/api/activity.js +13 -1
- package/src/api/payment.js +12 -4
- package/src/machine/activity/deposit_activity.js +13 -4
- package/src/machine/activity/diamond_shop_activity_cash.js +214 -0
- package/src/machine/activity/fafafa_activity.js +26 -15
- package/src/machine/activity/index.js +2 -0
- package/src/machine/activity/ranking_activity.js +11 -2
- package/src/machine/activity/specify_bets_activity.js +25 -3
- package/src/machine/activity/specify_turnover_activity.js +25 -3
- package/src/machine/activity/time_bomb_activity.js +11 -2
- package/src/machine/deposit/crypto_cash.js +243 -0
- package/src/machine/deposit/direct_cash.js +236 -0
- package/src/machine/deposit/index.js +12 -0
- package/src/machine/deposit/loadcard_cash.js +227 -0
- package/src/machine/deposit/manual_cash.js +321 -0
- package/src/machine/deposit/qrcode_cash.js +227 -0
- package/src/machine/deposit/usdt_cash.js +140 -0
- package/src/machine/game_favorite_v2.js +6 -2
- package/src/machine/game_v2_1.js +35 -9
- package/src/machine/index.js +6 -6
- package/src/machine/reward_cash.js +220 -0
- package/src/machine/side_cash.js +110 -0
- package/src/machine/withdraw/crypto_cash.js +313 -0
- package/src/machine/withdraw/index.js +4 -0
- package/src/machine/withdraw/manual_cash.js +267 -0
- package/src/request/request.js +9 -5
- package/src/util/index.js +2 -1
- package/src/util/math.js +4 -0
- package/dist/bundle.mjs +0 -28442
- package/rollup.config.js +0 -12
- package/src/machine/game.js +0 -285
- package/src/machine/game_favorite.js +0 -123
- package/src/machine/game_v2.js +0 -381
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { createMachine, assign, send } from 'xstate'
|
|
2
|
+
import activity from '../api/activity.js'
|
|
3
|
+
import payment from '../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'reward_cash',
|
|
10
|
+
type: 'parallel',
|
|
11
|
+
context: {
|
|
12
|
+
hasAuth: false,
|
|
13
|
+
otherRewardList: [],
|
|
14
|
+
pointsRewardList: [],
|
|
15
|
+
rewardList: [],
|
|
16
|
+
activityNo: null,
|
|
17
|
+
receiveNo: null,
|
|
18
|
+
withdrawRule: {},
|
|
19
|
+
callback: () => {},
|
|
20
|
+
},
|
|
21
|
+
states: {
|
|
22
|
+
timer: {
|
|
23
|
+
initial: 'checking',
|
|
24
|
+
states: {
|
|
25
|
+
checking: {
|
|
26
|
+
always: [
|
|
27
|
+
{
|
|
28
|
+
target: 'loading',
|
|
29
|
+
cond: (context, event) => {
|
|
30
|
+
return context.hasAuth
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
loading: {
|
|
36
|
+
invoke: {
|
|
37
|
+
src: 'fetchRewardList',
|
|
38
|
+
onDone: {
|
|
39
|
+
target: 'pending',
|
|
40
|
+
actions: 'setRewardList',
|
|
41
|
+
},
|
|
42
|
+
onError: {
|
|
43
|
+
target: 'pending',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
pending: {
|
|
48
|
+
after: {
|
|
49
|
+
20000: { target: 'loading' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
on: {
|
|
54
|
+
REFRESH: {
|
|
55
|
+
target: '.loading',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
reward: {
|
|
60
|
+
initial: 'idle',
|
|
61
|
+
states: {
|
|
62
|
+
idle: {
|
|
63
|
+
on: {
|
|
64
|
+
FETCH_WITHDRAW_RULE: {
|
|
65
|
+
target: 'fetching',
|
|
66
|
+
actions: 'setRewardData',
|
|
67
|
+
},
|
|
68
|
+
RECEIVE_REWARD: {
|
|
69
|
+
target: 'receiving',
|
|
70
|
+
actions: 'setCallback',
|
|
71
|
+
},
|
|
72
|
+
RECEIVE_ALL_POINTS: {
|
|
73
|
+
target: 'allPointsReceiving',
|
|
74
|
+
actions: 'setCallback',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
fetching: {
|
|
79
|
+
invoke: {
|
|
80
|
+
src: 'fetchWithdrawRulePreview',
|
|
81
|
+
onDone: {
|
|
82
|
+
target: 'pending',
|
|
83
|
+
actions: 'setWithdrawRulePreview',
|
|
84
|
+
},
|
|
85
|
+
onError: {
|
|
86
|
+
target: 'idle',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
pending: {
|
|
91
|
+
on: {
|
|
92
|
+
RECEIVE_REWARD: {
|
|
93
|
+
target: 'receiving',
|
|
94
|
+
actions: 'setCallback',
|
|
95
|
+
},
|
|
96
|
+
BACK: {
|
|
97
|
+
target: 'idle',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
receiving: {
|
|
102
|
+
invoke: {
|
|
103
|
+
src: 'receiveReward',
|
|
104
|
+
onDone: {
|
|
105
|
+
target: 'received',
|
|
106
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
107
|
+
},
|
|
108
|
+
onError: {
|
|
109
|
+
target: 'idle',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
received: {
|
|
114
|
+
after: {
|
|
115
|
+
0: {
|
|
116
|
+
target: 'idle',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
allPointsReceiving: {
|
|
121
|
+
invoke: {
|
|
122
|
+
src: 'receiveAllPoints',
|
|
123
|
+
onDone: {
|
|
124
|
+
target: 'idle',
|
|
125
|
+
actions: [send({ type: 'REFRESH' }), 'doCallback'],
|
|
126
|
+
},
|
|
127
|
+
onError: {
|
|
128
|
+
target: 'idle',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
on: {
|
|
136
|
+
SET_AUTH: {
|
|
137
|
+
target: '.timer.checking',
|
|
138
|
+
actions: 'setAuth',
|
|
139
|
+
cond: (context, event) => {
|
|
140
|
+
console.log(context.hasAuth, event.data)
|
|
141
|
+
return context.hasAuth !== event.data
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
actions: {
|
|
148
|
+
setAuth: assign((context, event) => {
|
|
149
|
+
return { hasAuth: event.data }
|
|
150
|
+
}),
|
|
151
|
+
setRewardList: assign((context, event) => {
|
|
152
|
+
return {
|
|
153
|
+
otherRewardList: event.data[0]?.data || [],
|
|
154
|
+
pointsRewardList: event.data[1]?.data || [],
|
|
155
|
+
rewardList: event.data[2]?.data || [],
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
setRewardData: assign((context, event) => {
|
|
159
|
+
const { activityNo, receiveNo } = event.data
|
|
160
|
+
return {
|
|
161
|
+
activityNo,
|
|
162
|
+
receiveNo,
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
setCallback: assign((context, event) => {
|
|
166
|
+
return {
|
|
167
|
+
callback: event.data?.callback || (() => {}),
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
doCallback: (context, event) => {
|
|
171
|
+
context.callback()
|
|
172
|
+
},
|
|
173
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
174
|
+
return {
|
|
175
|
+
withdrawRule: event.data,
|
|
176
|
+
}
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
179
|
+
services: {
|
|
180
|
+
fetchRewardList: async (context, event) => {
|
|
181
|
+
const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
|
|
182
|
+
const getPointsRewardAPI = request.send(
|
|
183
|
+
activity.getRewardList({
|
|
184
|
+
rewardType: 'POINTS',
|
|
185
|
+
count: 30,
|
|
186
|
+
appSecret,
|
|
187
|
+
})
|
|
188
|
+
)
|
|
189
|
+
const getOtherRewardAPI = request.send(
|
|
190
|
+
activity.getRewardList({
|
|
191
|
+
rewardType: 'CASH,FREE',
|
|
192
|
+
count: 30,
|
|
193
|
+
appSecret,
|
|
194
|
+
})
|
|
195
|
+
)
|
|
196
|
+
const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
|
|
197
|
+
return [otherRewardList, pointsRewardList, rewardList]
|
|
198
|
+
},
|
|
199
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
200
|
+
const { receiveNo } = context
|
|
201
|
+
const data = await request.send(
|
|
202
|
+
payment.getWithdrawRulePreview({
|
|
203
|
+
applyType: 'activity',
|
|
204
|
+
applyNo: receiveNo,
|
|
205
|
+
amount: null,
|
|
206
|
+
})
|
|
207
|
+
)
|
|
208
|
+
return data
|
|
209
|
+
},
|
|
210
|
+
receiveReward: async (context, event) => {
|
|
211
|
+
const { activityNo, receiveNo, attended } = event.data
|
|
212
|
+
return await request.send(activity.getReward({ activityNo, receiveNo, appSecret, attended }))
|
|
213
|
+
},
|
|
214
|
+
receiveAllPoints: async (context, event) => {
|
|
215
|
+
return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import game from '../api/game.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'side',
|
|
8
|
+
initial: 'inactive',
|
|
9
|
+
context: {
|
|
10
|
+
menu: null,
|
|
11
|
+
},
|
|
12
|
+
states: {
|
|
13
|
+
active: {
|
|
14
|
+
initial: 'loading',
|
|
15
|
+
states: {
|
|
16
|
+
loading: {
|
|
17
|
+
invoke: {
|
|
18
|
+
src: 'getMenu',
|
|
19
|
+
onDone: {
|
|
20
|
+
target: 'idle',
|
|
21
|
+
actions: ['setMenu'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
idle: {
|
|
26
|
+
initial: 'pending',
|
|
27
|
+
states: {
|
|
28
|
+
pending: {
|
|
29
|
+
after: {
|
|
30
|
+
20000: [
|
|
31
|
+
{
|
|
32
|
+
target: 'updating',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
updating: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'fetchUpdateMenu',
|
|
40
|
+
onDone: {
|
|
41
|
+
target: 'pending',
|
|
42
|
+
actions: 'updateMenu',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
on: {
|
|
50
|
+
STOP: {
|
|
51
|
+
target: 'inactive',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
inactive: {
|
|
56
|
+
on: {
|
|
57
|
+
START: {
|
|
58
|
+
target: 'active',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
actions: {
|
|
66
|
+
setMenu: assign((context, event) => {
|
|
67
|
+
const menu = event.data
|
|
68
|
+
addLevelProperty(menu.data, 0)
|
|
69
|
+
return { menu }
|
|
70
|
+
}),
|
|
71
|
+
updateMenu: assign((context, event) => {
|
|
72
|
+
const menu = event.data
|
|
73
|
+
if (menu.data.length) {
|
|
74
|
+
addLevelProperty(menu.data, 0)
|
|
75
|
+
return { menu, defaultMenuItemStack: getDefaultItem(menu.data[0]) }
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
services: {
|
|
80
|
+
getMenu: async (context, event) => {
|
|
81
|
+
return await request.send(game.getListRoot())
|
|
82
|
+
},
|
|
83
|
+
fetchUpdateMenu: async (context, event) => {
|
|
84
|
+
return await request.send(game.getListRoot({ timestamp: context.menu.timestamp }))
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getDefaultItem(node) {
|
|
92
|
+
if (node.sub.length > 0) {
|
|
93
|
+
const stack = getDefaultItem(node.sub[0])
|
|
94
|
+
return [node, ...stack]
|
|
95
|
+
} else {
|
|
96
|
+
return [node]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function addLevelProperty(list, level) {
|
|
101
|
+
const nextLevel = level + 1
|
|
102
|
+
for (let i = 0; i < list.length; i++) {
|
|
103
|
+
list[i].level = level
|
|
104
|
+
|
|
105
|
+
// avoid games in list
|
|
106
|
+
if (!list[i].isGame) {
|
|
107
|
+
addLevelProperty(list[i].sub, nextLevel)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
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: '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: 'fetchWithdrawRule',
|
|
33
|
+
onDone: {
|
|
34
|
+
target: 'checking',
|
|
35
|
+
actions: ['setWithdrawRule', '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: '#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 { paymentDetail } = context
|
|
173
|
+
const selectedCrypto = paymentDetail.find((item) => item.transferType === 'withdraw' && item.category === 'crypto')
|
|
174
|
+
const networks = (selectedCrypto?.networkName || []).map((value, i) => {
|
|
175
|
+
return {
|
|
176
|
+
label: selectedCrypto.networkOptional?.[i],
|
|
177
|
+
value,
|
|
178
|
+
icon: value,
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
console.log('paymentDetail', selectedCrypto.processing)
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
selectedCrypto,
|
|
186
|
+
networks,
|
|
187
|
+
selectedNetwork: networks[0],
|
|
188
|
+
processing: selectedCrypto.processing?.[0],
|
|
189
|
+
}
|
|
190
|
+
}),
|
|
191
|
+
setWithdrawRule: assign((context, event) => {
|
|
192
|
+
return {
|
|
193
|
+
withdrawRule: event.data,
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
setNetwork: assign((context, event) => {
|
|
197
|
+
return {
|
|
198
|
+
selectedNetwork: event.data,
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
setAddress: assign((context, event) => {
|
|
202
|
+
return {
|
|
203
|
+
address: event.data,
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
setAmount: assign((context, event) => {
|
|
207
|
+
return {
|
|
208
|
+
selectedAmount: event.data,
|
|
209
|
+
}
|
|
210
|
+
}),
|
|
211
|
+
setCalculation: assign((context, event) => {
|
|
212
|
+
return {
|
|
213
|
+
calculation: event.data,
|
|
214
|
+
}
|
|
215
|
+
}),
|
|
216
|
+
resetCharge: assign((context, event) => {
|
|
217
|
+
return {
|
|
218
|
+
charge: null,
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
setTransaction: assign((context, event) => {
|
|
222
|
+
const { realAmount } = event.data
|
|
223
|
+
return {
|
|
224
|
+
realAmount,
|
|
225
|
+
}
|
|
226
|
+
}),
|
|
227
|
+
setOtp: assign((context, event) => {
|
|
228
|
+
const { requestId, status, target, ttl } = event.data
|
|
229
|
+
return {
|
|
230
|
+
requestId,
|
|
231
|
+
status,
|
|
232
|
+
target,
|
|
233
|
+
ttl,
|
|
234
|
+
}
|
|
235
|
+
}),
|
|
236
|
+
decreaseTtl: assign((context, evnet) => {
|
|
237
|
+
const second = context.ttl
|
|
238
|
+
return {
|
|
239
|
+
ttl: Math.max(second - 1, 0),
|
|
240
|
+
}
|
|
241
|
+
}),
|
|
242
|
+
setVerificationData: assign((context, event) => {
|
|
243
|
+
const { requestId, ttl, target } = event.data
|
|
244
|
+
return {
|
|
245
|
+
requestId,
|
|
246
|
+
ttl,
|
|
247
|
+
target,
|
|
248
|
+
}
|
|
249
|
+
}),
|
|
250
|
+
setAttachmentType: assign((context, event) => {
|
|
251
|
+
return {
|
|
252
|
+
attachmentType: event.data,
|
|
253
|
+
}
|
|
254
|
+
}),
|
|
255
|
+
setProcessing: assign((context, event) => {
|
|
256
|
+
return {
|
|
257
|
+
processing: event.data,
|
|
258
|
+
}
|
|
259
|
+
}),
|
|
260
|
+
},
|
|
261
|
+
guards: {
|
|
262
|
+
isProcessing: (context, event) => {
|
|
263
|
+
return context.processing
|
|
264
|
+
},
|
|
265
|
+
isCalculable: (context, event) => {
|
|
266
|
+
const { withdrawRule, selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
267
|
+
const maximum = Math.min(withdrawRule.balance, selectedCrypto.maximum)
|
|
268
|
+
return selectedNetwork && selectedAmount && selectedCrypto.minimum <= selectedAmount && selectedAmount <= maximum
|
|
269
|
+
},
|
|
270
|
+
isOtpRequired: (context, event) => {
|
|
271
|
+
return event.data?.status === 'otp-verifying'
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
services: {
|
|
275
|
+
fetchWithdrawRule: async (context, event) => {
|
|
276
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' }))
|
|
277
|
+
},
|
|
278
|
+
submitWithdraw: async (context, event) => {
|
|
279
|
+
const { selectedCrypto, selectedNetwork, address, selectedAmount } = context
|
|
280
|
+
return await request.send(
|
|
281
|
+
api.submitWithdrawTransactionCrypto({
|
|
282
|
+
method: selectedCrypto.method,
|
|
283
|
+
amount: selectedAmount,
|
|
284
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
285
|
+
cryptoNetwork: selectedNetwork.value,
|
|
286
|
+
targetAddress: address,
|
|
287
|
+
})
|
|
288
|
+
)
|
|
289
|
+
},
|
|
290
|
+
fetchCalculation: async (context, event) => {
|
|
291
|
+
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
292
|
+
const method = selectedCrypto.method
|
|
293
|
+
return await request.send(
|
|
294
|
+
api.getWithdrawExpectedResult({
|
|
295
|
+
method,
|
|
296
|
+
amount: selectedAmount,
|
|
297
|
+
cryptoNetwork: selectedNetwork.value,
|
|
298
|
+
})
|
|
299
|
+
)
|
|
300
|
+
},
|
|
301
|
+
resetOtp: async (context, event) => {
|
|
302
|
+
const { requestId, target } = context
|
|
303
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
304
|
+
},
|
|
305
|
+
acknowledge: async (context, event) => {
|
|
306
|
+
const { requestId, target } = context
|
|
307
|
+
const code = event.data
|
|
308
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
}
|